diff --git a/compact/tracking/definitions_craterlake.xml b/compact/tracking/definitions_craterlake.xml
index e11e6dbe8..3963c0ec5 100644
--- a/compact/tracking/definitions_craterlake.xml
+++ b/compact/tracking/definitions_craterlake.xml
@@ -41,15 +41,18 @@
Main parameters for Barrel TOF layers
Barrel TOF region
-
-
+
+
+
+
+
Forward TOF region
-
-
+
+
diff --git a/compact/tracking/tof_barrel.xml b/compact/tracking/tof_barrel.xml
index 7a1b6949a..1e8bfee61 100644
--- a/compact/tracking/tof_barrel.xml
+++ b/compact/tracking/tof_barrel.xml
@@ -63,19 +63,21 @@
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
-
-
-
-
@@ -91,52 +93,104 @@
insideTrackingVolume="true">
+ rmin="BarrelTOF_rmin - 1*mm"
+ rmax="BarrelTOF_rmax + 1*mm"
+ length="BarrelTOF_length"
+ />
Tracker Barrel Modules
-
-
+
+ keep_layer means the next module is located at the same thickness level
+ so you can place component side by side
+ Just make sure all components you placed side by side share the same thickness
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
-
-
+
+
-
-
+
+
+
-
-
+
+
-
-
+
+
+
-
-
+
+
+
-
+
+
diff --git a/compact/tracking/tof_endcap.xml b/compact/tracking/tof_endcap.xml
index e0c78530b..ebec385ff 100644
--- a/compact/tracking/tof_endcap.xml
+++ b/compact/tracking/tof_endcap.xml
@@ -107,7 +107,7 @@
1 um padding to not have layer and module touch (ACTS requirement)
-
+
@@ -122,8 +122,8 @@
-
-
+
+
@@ -133,19 +133,25 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
@@ -155,12 +161,14 @@
-
+
+
-
+
+
@@ -205,7 +213,7 @@
reflect="false">
-
+
@@ -218,19 +226,99 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -244,13 +332,16 @@
-
+
+
+ zstart="ForwardTOF_zmin"
+ xoffset="EndcapTOF_Module_length_design/2"
+ />
@@ -261,13 +352,300 @@
rmin="ForwardTOFLayer_rmin"
rmax="ForwardTOFLayer_rmax"
length="12*mm"
- zstart="ForwardTOF_zmin" />
+ zstart="ForwardTOF_zmin"
+ xoffset="EndcapTOF_Module_length_design/2" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ spacing="EndcapTOF_Module_spacing"
+ board_gap="EndcapTOF_Board_spacing" />
@@ -280,8 +658,8 @@
-
- system:8,layer:4,module:8,idx:7,idy:5,x:32:-16,y:-16
+
+ system:8,layer:4,module:2,idx:5,idy:5,ids:6,x:36:-12,y:-16
diff --git a/src/BarrelTOFTracker_geo.cpp b/src/BarrelTOFTracker_geo.cpp
index 6a9cf6c75..6598bc961 100644
--- a/src/BarrelTOFTracker_geo.cpp
+++ b/src/BarrelTOFTracker_geo.cpp
@@ -136,7 +136,8 @@ static Ref_t create_TOFBarrel(Detector& description, xml_h e, SensitiveDetector
// Compute module total thickness from components
xml_coll_t ci(x_mod, _U(module_component));
for (ci.reset(), total_thickness = 0.0; ci; ++ci) {
- total_thickness += xml_comp_t(ci).thickness();
+ if (!getAttrOrDefault(xml_comp_t(ci), _Unicode(keep_layer), false))
+ total_thickness += xml_comp_t(ci).thickness();
}
// the module assembly volume
Assembly m_vol(m_nam);
@@ -174,18 +175,49 @@ static Ref_t create_TOFBarrel(Detector& description, xml_h e, SensitiveDetector
xml_comp_t x_comp = mci;
xml_comp_t x_pos = x_comp.position(false);
xml_comp_t x_rot = x_comp.rotation(false);
- auto make_box = [&](double pos_x = 0, double pos_y = 0, double pos_z = 0, double rot_x = 0,
- double rot_y = 0, double rot_z = 0, bool z_stacking = true) {
+ auto make_box = [&](double width, double length, double thickness, double pos_x = 0,
+ double pos_y = 0, double pos_z = 0, double rot_x = 0, double rot_y = 0,
+ double rot_z = 0, bool z_stacking = true) {
+ // Utility variable for the relative z-offset based off the previous components
+ const double zoff = thickness_sum + thickness / 2.0;
+
const string c_nam = _toString(ncomponents, "component%d");
++ncomponents;
- Box c_box(x_comp.width() / 2, x_comp.length() / 2, x_comp.thickness() / 2);
- Volume c_vol(c_nam, c_box, description.material(x_comp.materialStr()));
+ Box c_box(width / 2, length / 2, thickness / 2);
+ Volume c_vol;
+
+ xml_coll_t ci_tube(x_comp, _Unicode(inner_tube));
+ if (ci_tube) {
+ double max_r = 0;
+ for (; ci_tube; ++ci_tube) {
+ // fill the hole with tube
+ xml_comp_t ct = ci_tube;
+ max_r = std::max(max_r, ct.rmax());
+ Tube c_tube(ct.rmin(), ct.rmax(), length / 2);
+ Volume c_tubevol(c_nam + ct.nameStr(), c_tube, description.material(ct.materialStr()));
+ if (ct.visStr() != "")
+ c_tubevol.setVisAttributes(description, ct.visStr());
+ m_vol.placeVolume(c_tubevol, Transform3D(RotationZYX(0, 0, -M_PI / 2),
+ Position(pos_x, pos_y, pos_z + zoff)));
+ }
- // Utility variable for the relative z-offset based off the previous components
- const double zoff = thickness_sum + x_comp.thickness() / 2.0;
+ Tube c_fbox(0, max_r, length / 2 + 1);
+ SubtractionSolid c_sbox(c_box, c_fbox,
+ Transform3D(RotationZYX(0, 0, -M_PI / 2),
+ Position(0, 0, 0))); //pos_x, pos_y, pos_z + zoff)));
+
+ c_vol = Volume(c_nam, c_sbox, description.material(x_comp.materialStr()));
+ } else
+ c_vol = Volume(c_nam, c_box, description.material(x_comp.materialStr()));
+
+ Volume test;
+ test = c_vol;
+
+ // center if off by half the box length if box length is cut in half
Position c_pos(pos_x, pos_y, pos_z + zoff);
RotationZYX c_rot(rot_z, rot_y, rot_x);
pv = m_vol.placeVolume(c_vol, Transform3D(c_rot, c_pos));
+
c_vol.setRegion(description, x_comp.regionStr());
c_vol.setLimitSet(description, x_comp.limitsStr());
c_vol.setVisAttributes(description, x_comp.visStr());
@@ -193,9 +225,8 @@ static Ref_t create_TOFBarrel(Detector& description, xml_h e, SensitiveDetector
pv.addPhysVolID("sensor", sensor_number++);
c_vol.setSensitiveDetector(sens);
sensitives[m_nam].push_back(pv);
- module_thicknesses[m_nam] = {thickness_so_far + x_comp.thickness() / 2.0,
- total_thickness - thickness_so_far -
- x_comp.thickness() / 2.0};
+ module_thicknesses[m_nam] = {thickness_so_far + thickness / 2.0,
+ total_thickness - thickness_so_far - thickness / 2.0};
// -------- create a measurement plane for the tracking surface attched to the sensitive volume -----
Vector3D u(-1., 0., 0.);
@@ -219,8 +250,8 @@ static Ref_t create_TOFBarrel(Detector& description, xml_h e, SensitiveDetector
//--------------------------------------------
}
if (z_stacking) {
- thickness_sum += x_comp.thickness();
- thickness_so_far += x_comp.thickness();
+ thickness_sum += thickness;
+ thickness_so_far += thickness;
// apply relative offsets in z-position used to stack components side-by-side
thickness_sum += pos_z;
thickness_so_far += pos_z;
@@ -239,6 +270,11 @@ static Ref_t create_TOFBarrel(Detector& description, xml_h e, SensitiveDetector
pos_y = x_pos.y(0);
pos_z = x_pos.z(0);
}
+ double width = x_comp.width();
+ double length = x_comp.length();
+ double thickness = x_comp.thickness();
+ bool keep_layer = getAttrOrDefault(x_comp, _Unicode(keep_layer), false);
+
if (x_comp.hasChild(_Unicode(GridSensors))) {
auto x_comp_t = x_comp.child(_Unicode(GridSensors));
// x-distance between centers of neighboring sensors
@@ -262,23 +298,40 @@ static Ref_t create_TOFBarrel(Detector& description, xml_h e, SensitiveDetector
// || || ||
// ring_extra_width is the extra width between boundaries of the sensor boundaries (including dead space)
double ring_extra_width = getAttrOrDefault(x_comp_t, _Unicode(ring_extra_width), 0);
+ auto half_length_str =
+ getAttrOrDefault(x_comp_t, _Unicode(half_length), "none");
double current_x = start_x;
for (int nx = 0; nx < nsensors_x; ++nx) {
double current_y = start_y;
for (int ny = 0; ny < nsensors_y; ++ny) {
- make_box(current_x, current_y, start_z, rot_x, rot_y, rot_z,
- ((nx == nsensors_x - 1) &&
- (ny == nsensors_y - 1))); // all sensors are located at the same z-layer
+ double sensor_length = length;
+ double tmp_sensors_ydist = sensors_ydist;
+ // when we draw half a sensor, the center has to be shifted by 0.25 times the length of a sensor
+ // distance between centers to the next sensor also has to be reduced by 0.25 times the length of a sensor
+ if ((half_length_str == "left" || half_length_str == "both") && ny == 0) {
+ sensor_length = 0.5 * length;
+ current_y += 0.25 * length;
+ tmp_sensors_ydist -= 0.25 * length;
+ }
+ // same idea, but when you are drawing to the right, the right sensor center has to move in -y direction
+ if ((half_length_str == "right" || half_length_str == "both") && ny == nsensors_y - 1) {
+ sensor_length = 0.5 * length;
+ current_y -= 0.25 * length;
+ }
+ make_box(width, sensor_length, thickness, current_x, current_y, start_z, rot_x, rot_y,
+ rot_z,
+ (((nx == nsensors_x - 1) && (ny == nsensors_y - 1))) &&
+ !keep_layer); // all sensors are located at the same z-layer
// increment z-layers only at the end, after the last sensor is added
- current_y += sensors_ydist;
+ current_y += tmp_sensors_ydist;
if (ny + 1 == ny_before_ring)
current_y += ring_extra_width;
}
current_x += sensors_xdist;
}
} else
- make_box(pos_x, pos_y, pos_z, rot_x, rot_y, rot_z);
+ make_box(width, length, thickness, pos_x, pos_y, pos_z, rot_x, rot_y, rot_z, !keep_layer);
}
}
diff --git a/src/EndcapTOF_geo.cpp b/src/EndcapTOF_geo.cpp
index c4edc64a8..5e6c0c01c 100644
--- a/src/EndcapTOF_geo.cpp
+++ b/src/EndcapTOF_geo.cpp
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
-// Copyright (C) 2022 Nicolas Schmidt
+// Copyright (C) 2022 - 2024, Nicolas Schmidt, Chun Yuen Tsang
/** \addtogroup Trackers Trackers
* \brief Type: **Endcap Tracker with TOF**.
- * \author N. Schmidt
*
* \ingroup trackers
*
@@ -19,6 +18,7 @@
#include "XML/Utilities.h"
#include
#include