From f1241c99c8900677fb73122029a1ffea872cac51 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Sat, 12 Oct 2024 03:25:22 +0000
Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
compact/tracking/tof_barrel.xml | 36 +--
compact/tracking/tof_endcap.xml | 556 ++++++++++++++++----------------
src/BarrelTOFTracker_geo.cpp | 93 +++---
src/EndcapTOF_geo.cpp | 126 ++++----
4 files changed, 408 insertions(+), 403 deletions(-)
diff --git a/compact/tracking/tof_barrel.xml b/compact/tracking/tof_barrel.xml
index 33fb1266e..1e8bfee61 100644
--- a/compact/tracking/tof_barrel.xml
+++ b/compact/tracking/tof_barrel.xml
@@ -101,17 +101,17 @@
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
-
+
+ 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
+
-
+
-
+
@@ -138,23 +138,23 @@
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -172,10 +172,10 @@
-
+
-
+
diff --git a/compact/tracking/tof_endcap.xml b/compact/tracking/tof_endcap.xml
index 5eb5bb2f8..36f2c5e27 100644
--- a/compact/tracking/tof_endcap.xml
+++ b/compact/tracking/tof_endcap.xml
@@ -238,7 +238,7 @@
-
+
@@ -269,13 +269,13 @@
-
+
-
+
@@ -305,7 +305,7 @@
-
+
@@ -357,287 +357,287 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
(xml_comp_t(ci), _Unicode(keep_layer), false))
+ if (!getAttrOrDefault(xml_comp_t(ci), _Unicode(keep_layer), false))
total_thickness += xml_comp_t(ci).thickness();
}
// the module assembly volume
@@ -175,9 +175,9 @@ 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 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) {
+ 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;
@@ -185,38 +185,39 @@ static Ref_t create_TOFBarrel(Detector& description, xml_h e, SensitiveDetector
++ncomponents;
Box c_box(width / 2, length / 2, thickness / 2);
Volume c_vol;
-
+
xml_coll_t ci(x_comp, _Unicode(inner_tube));
- if(ci) {
- double max_r = 0;
+ if (ci) {
+ double max_r = 0;
for (; ci; ++ci) {
// fill the hole with tube
- xml_comp_t ct = ci;
- max_r = std::max(max_r, ct.rmax());
- Tube c_tube(ct.rmin(), ct.rmax(), length / 2);
+ xml_comp_t ct = ci;
+ 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());
+ 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)));
- }
+ Position(pos_x, pos_y, pos_z + zoff)));
+ }
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)));
+ 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;
+ } 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
+ // 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());
@@ -225,8 +226,7 @@ static Ref_t create_TOFBarrel(Detector& description, xml_h e, SensitiveDetector
c_vol.setSensitiveDetector(sens);
sensitives[m_nam].push_back(pv);
module_thicknesses[m_nam] = {thickness_so_far + thickness / 2.0,
- total_thickness - 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.);
@@ -270,11 +270,10 @@ 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 width = x_comp.width();
+ double length = x_comp.length();
double thickness = x_comp.thickness();
- bool keep_layer = getAttrOrDefault(x_comp, _Unicode(keep_layer), false);
-
+ 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));
@@ -299,31 +298,31 @@ 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");
-
+ 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) {
- 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
+ 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 += tmp_sensors_ydist;
if (ny + 1 == ny_before_ring)
diff --git a/src/EndcapTOF_geo.cpp b/src/EndcapTOF_geo.cpp
index a5568cc40..c011ed99b 100644
--- a/src/EndcapTOF_geo.cpp
+++ b/src/EndcapTOF_geo.cpp
@@ -92,85 +92,88 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s
xml_comp_t x_supp_envelope = x_supp.child(_Unicode(envelope), false);
xml_comp_t x_modFrontLeft = x_det.child(_Unicode(moduleFrontLeft));
- xml_comp_t x_modFrontRight = x_det.child(_Unicode(moduleFrontRight));
+ xml_comp_t x_modFrontRight = x_det.child(_Unicode(moduleFrontRight));
xml_comp_t x_modBackLeft = x_det.child(_Unicode(moduleBackLeft));
- xml_comp_t x_modBackRight = x_det.child(_Unicode(moduleBackRight));
+ xml_comp_t x_modBackRight = x_det.child(_Unicode(moduleBackRight));
- xml_comp_t x_sensor_layout_front_left = x_det.child(_Unicode(sensor_layout_front_left));
- xml_comp_t x_sensor_layout_back_left = x_det.child(_Unicode(sensor_layout_back_left));
+ xml_comp_t x_sensor_layout_front_left = x_det.child(_Unicode(sensor_layout_front_left));
+ xml_comp_t x_sensor_layout_back_left = x_det.child(_Unicode(sensor_layout_back_left));
xml_comp_t x_sensor_layout_front_right = x_det.child(_Unicode(sensor_layout_front_right));
- xml_comp_t x_sensor_layout_back_right = x_det.child(_Unicode(sensor_layout_back_right));
-
- for(bool left : std::vector{true, false}) {
- for(bool front : std::vector{true, false}) {
- int module = (front<<1) + left;
- float ycoord = envelope.rmax() - module_y/2.; // y-center-coord of the top sensor. Start from the top row
- int iy = 0;
+ xml_comp_t x_sensor_layout_back_right = x_det.child(_Unicode(sensor_layout_back_right));
+
+ for (bool left : std::vector{true, false}) {
+ for (bool front : std::vector{true, false}) {
+ int module = (front << 1) + left;
+ float ycoord = envelope.rmax() -
+ module_y / 2.; // y-center-coord of the top sensor. Start from the top row
+ int iy = 0;
xml_comp_t x_sensor_layout = x_sensor_layout_front_left;
- xml_comp_t x_modCurr = x_modFrontLeft;
-
- if(front) {
- if(left) {
- x_sensor_layout = x_sensor_layout_front_left;
- x_modCurr = x_modFrontLeft;
- } else {
- x_sensor_layout = x_sensor_layout_front_right;
- x_modCurr = x_modFrontRight;
- }
+ xml_comp_t x_modCurr = x_modFrontLeft;
+
+ if (front) {
+ if (left) {
+ x_sensor_layout = x_sensor_layout_front_left;
+ x_modCurr = x_modFrontLeft;
+ } else {
+ x_sensor_layout = x_sensor_layout_front_right;
+ x_modCurr = x_modFrontRight;
+ }
} else {
- if(left) {
- x_sensor_layout = x_sensor_layout_back_left;
- x_modCurr = x_modBackLeft;
- } else {
- x_sensor_layout = x_sensor_layout_back_right;
- x_modCurr = x_modBackRight;
- }
- }
+ if (left) {
+ x_sensor_layout = x_sensor_layout_back_left;
+ x_modCurr = x_modBackLeft;
+ } else {
+ x_sensor_layout = x_sensor_layout_back_right;
+ x_modCurr = x_modBackRight;
+ }
+ }
double total_thickness = 0;
// Compute module total thickness from components
xml_coll_t ci(x_modCurr, _U(module_component));
for (ci.reset(), total_thickness = 0.0; ci; ++ci) {
- xml_comp_t x_comp = ci;
+ xml_comp_t x_comp = ci;
bool keep_same_layer = getAttrOrDefault(x_comp, _Unicode(keep_layer), false);
- if(!keep_same_layer)
+ if (!keep_same_layer)
total_thickness += x_comp.thickness();
}
-
- for(xml_coll_t lrow(x_sensor_layout, _Unicode(row)); lrow; ++lrow) {
+ for (xml_coll_t lrow(x_sensor_layout, _Unicode(row)); lrow; ++lrow) {
xml_comp_t x_row = lrow;
double deadspace = getAttrOrDefault(x_row, _Unicode(deadspace), 0);
if (deadspace > 0) {
- ycoord -= deadspace;
- continue;
+ ycoord -= deadspace;
+ continue;
}
double x_offset = getAttrOrDefault(x_row, _Unicode(x_offset), 0);
- int nsensors = getAttrOrDefault(x_row, _Unicode(nsensors), 0);
+ int nsensors = getAttrOrDefault(x_row, _Unicode(nsensors), 0);
// find the sensor id that corrsponds to the rightmost sensor in a board
// we need to know where to apply additional spaces between neighboring board
std::unordered_set sensors_id_board_edge;
- int curr_ix = nsensors; // the first sensor to the right of center has ix of nsensors
- for(xml_coll_t lboard(x_row, _Unicode(board)); lboard; ++lboard) {
+ int curr_ix = nsensors; // the first sensor to the right of center has ix of nsensors
+ for (xml_coll_t lboard(x_row, _Unicode(board)); lboard; ++lboard) {
xml_comp_t x_board = lboard;
int nboard_sensors = getAttrOrDefault(x_board, _Unicode(nsensors), 1);
curr_ix += nboard_sensors;
sensors_id_board_edge.insert(curr_ix);
- sensors_id_board_edge.insert(2*nsensors - curr_ix - 1); // reflected to sensor id on the left
+ sensors_id_board_edge.insert(2 * nsensors - curr_ix -
+ 1); // reflected to sensor id on the left
}
- for (int ix = (left? 0 : nsensors) ; ix < (left? nsensors : 2 * nsensors); ix++) {
+ for (int ix = (left ? 0 : nsensors); ix < (left ? nsensors : 2 * nsensors); ix++) {
// there is a hole in the middle, with radius = x_offset
- float xcoord = (ix - nsensors + 0.5) * (module_x + module_spacing) + ((ix - nsensors < 0)? - x_offset : x_offset);
+ float xcoord = (ix - nsensors + 0.5) * (module_x + module_spacing) +
+ ((ix - nsensors < 0) ? -x_offset : x_offset);
// add board spacing
- if(sensors_id_board_edge.find(ix) != sensors_id_board_edge.end())
- xcoord = (ix - nsensors < 0)? xcoord - board_gap : xcoord + board_gap;
+ if (sensors_id_board_edge.find(ix) != sensors_id_board_edge.end())
+ xcoord = (ix - nsensors < 0) ? xcoord - board_gap : xcoord + board_gap;
//! Note the module ordering is different for front and back side
double module_z = x_supp_envelope.length() / 2.0 + total_thickness / 2;
- if(front) module_z *= -1;
+ if (front)
+ module_z *= -1;
string module_name = Form("module%d_%d_%d", module, ix, iy);
DetElement mod_elt(lay_elt, module_name, module);
@@ -186,7 +189,7 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s
double thickness_so_far = 0.0;
double thickness_sum = -total_thickness / 2.0;
double thickness_carbonsupp = 0.0;
- int sensitive_id = 0;
+ int sensitive_id = 0;
for (xml_coll_t mci(x_modCurr, _U(module_component)); mci; ++mci, ++ncomponents) {
xml_comp_t x_comp = mci;
xml_comp_t x_pos = x_comp.position(false);
@@ -241,7 +244,10 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s
VolPlane surf(c_vol, type, inner_thickness, outer_thickness, u, v, n);
- DetElement comp_de(mod_elt, std::string("de_") + pv.volume().name() + "_" + std::to_string(sensitive_id), module);
+ DetElement comp_de(mod_elt,
+ std::string("de_") + pv.volume().name() + "_" +
+ std::to_string(sensitive_id),
+ module);
comp_de.setPlacement(pv);
auto& comp_de_params =
@@ -252,7 +258,7 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s
//--------------------------------------------
}
bool keep_same_layer = getAttrOrDefault(x_comp, _Unicode(keep_layer), false);
- if(!keep_same_layer) {
+ if (!keep_same_layer) {
thickness_sum += x_comp.thickness();
thickness_so_far += x_comp.thickness();
// apply relative offsets in z-position used to stack components side-by-side
@@ -263,19 +269,19 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s
}
}
- if(front) {
- // only draw support bar on one side
- // if you draw on both sides, they may overlap
- const string suppb_nam =
- Form("suppbar_%d_%d", ix, iy); //_toString(ncomponents, "component%d");
- Box suppb_box((module_x + module_spacing) / 2, thickness_carbonsupp / 2,
- x_supp_envelope.length() / 2);
- Volume suppb_vol(suppb_nam, suppb_box, carbon);
- Transform3D trsupp(RotationZYX(0, 0, 0),
- Position(xcoord, ycoord + module_y / 2 - module_overlap / 2, 0));
- suppb_vol.setVisAttributes(description, "AnlGray");
-
- pv = lay_vol.placeVolume(suppb_vol, trsupp);
+ if (front) {
+ // only draw support bar on one side
+ // if you draw on both sides, they may overlap
+ const string suppb_nam =
+ Form("suppbar_%d_%d", ix, iy); //_toString(ncomponents, "component%d");
+ Box suppb_box((module_x + module_spacing) / 2, thickness_carbonsupp / 2,
+ x_supp_envelope.length() / 2);
+ Volume suppb_vol(suppb_nam, suppb_box, carbon);
+ Transform3D trsupp(RotationZYX(0, 0, 0),
+ Position(xcoord, ycoord + module_y / 2 - module_overlap / 2, 0));
+ suppb_vol.setVisAttributes(description, "AnlGray");
+
+ pv = lay_vol.placeVolume(suppb_vol, trsupp);
}
// module built!