1313// / \brief Implementation of the FT3Module class
1414
1515#include " FT3Simulation/FT3Module.h"
16+ #include " FT3Base/FT3BaseParam.h"
1617#include < TGeoManager.h>
1718#include < TGeoMaterial.h>
1819#include < TGeoMedium.h>
@@ -102,8 +103,7 @@ double calculate_y_circle(double x, double radius)
102103 * for positive and negative y respectively
103104 */
104105void FT3Module::fill_stave (PosNegPositionTypes& y_positions, double Rout,
105- double Rin, double x_left,
106- unsigned kSensorStack , double tolerance,
106+ double x_left, unsigned kSensorStack , double tolerance,
107107 std::pair<double , double > y_start={0 , 0 })
108108{
109109 // start with upper half of the stave, then mirror to the bottom half
@@ -314,6 +314,7 @@ void FT3Module::create_layout_scopingV3(double mZ, int layerNumber, int directio
314314 << layerNumber << " , Direction " << direction;
315315
316316 FT3Module::initialize_materials ();
317+ auto & ft3Params = o2::ft3::FT3BaseParam::Instance ();
317318
318319 // initialise all y_positions, vector over all staves
319320 std::vector<PosNegPositionTypes> y_positionsPosNeg;
@@ -322,28 +323,41 @@ void FT3Module::create_layout_scopingV3(double mZ, int layerNumber, int directio
322323 y_positionsPosNeg.emplace_back (PosNegPositionTypes{PositionTypes{}, PositionTypes{}});
323324
324325 double y_midpoint = 0 .;
326+ // default positive and negative starting points has a gap around x-axis
327+ std::pair<double , double > y_start{0 ., Constants::sensor2x1_gap};
325328 const int staveID = Constants::staveIdxToID (i_stave);
326329 auto y_midpoint_it = Constants::staveID_to_y_midpoint.find (staveID);
327- if ( y_midpoint_it != Constants::staveID_to_y_midpoint.end () ) { // there is a defined midpoint for this stave
330+ if ( y_midpoint_it != Constants::staveID_to_y_midpoint.end () ) {
331+ // there is a defined midpoint for this stave, use this for starting points
328332 y_midpoint = y_midpoint_it->second ; // avoid double map lookup
329333 double y_start_pos = y_midpoint - Constants::y_lengths[i_stave] / 2 ;
330- // currently we have the same positions on positive and negative x
331- // place the first sensor tile, assume it fits
332- y_positionsPosNeg.back ().first .emplace_back (y_start_pos, Constants::kSensorsPerStack ); // positive
333- y_positionsPosNeg.back ().second .emplace_back (-y_start_pos, Constants::kSensorsPerStack ); // negative
334- } else {
335- // midpoint is zero, i.e., the start point for x>0 & y>0 is y=0
336- // while y_start for x>0, y<0 is -Constants::sensor2x1_gap
337- y_positionsPosNeg.back ().first .emplace_back (0 , Constants::kSensorsPerStack ); // positive
338- y_positionsPosNeg.back ().second .emplace_back (-Constants::sensor2x1_gap, Constants::kSensorsPerStack ); // negative
339334 }
335+
340336 double x_left = Constants::x_midpoints[i_stave] - Constants::sensor2x1_width / 2 ;
341- // fill_stave(y_positionsPosNeg, Rout, Rin, x_left, Constants::kSensorsPerStack, -3);
342- LOG (info) << " FT3Module: Filling Stave " << staveID << " (x = " << Constants::x_midpoints[i_stave]
343- << " ) with sensors. Starting y positions: "
344- << y_positionsPosNeg.back ().first .front ().first << " (positive), "
345- << y_positionsPosNeg.back ().second .front ().first << " (negative)." ;
346- fill_stave (y_positionsPosNeg.back (), Rout, Rin, x_left, 1 , -1 ); // easiest: just do with 2x1 for now
337+ double x_right = x_left + Constants::sensor2x1_width;
338+ double tolerance = -Constants::sensor_stack_height; // allow one sensor placement beyond
339+ // cut staves on nominal inner radius if specified
340+ if (ft3Params.cutStavesOnNominalRadius ) {
341+ double min_y_at_x;
342+ if (x_left * x_right < 0 ) {
343+ // stave crosses y-axis, so we start at y=Rin
344+ min_y_at_x = Rin;
345+ } else if (x_left > 0 ) {
346+ // stave is on the right side, so minimum y is at x_left
347+ min_y_at_x = calculate_y_circle (x_left, Rin);
348+ } else {
349+ // stave is on the left side, so minimum y is at x_right
350+ min_y_at_x = calculate_y_circle (x_right, Rin);
351+ }
352+ y_start = {min_y_at_x, -min_y_at_x};
353+ tolerance = 0 .; // no tolerance in case of cutting at nominal radius
354+ }
355+ // fill_stave(y_positionsPosNeg, Rout, x_left, Constants::kSensorsPerStack, -3);
356+ LOG (info) << " FT3Module: Filling Stave " << staveID << " (x = "
357+ << Constants::x_midpoints[i_stave] << " ) with sensors. Starting y positions: "
358+ << y_start.first << " (positive), " << y_start.second << " (negative)." ;
359+ fill_stave (y_positionsPosNeg.back (), Rout, x_left, Constants::kSensorsPerStack ,
360+ tolerance, y_start);
347361 }
348362
349363 unsigned sensor_count = 0 ;
0 commit comments