@@ -143,11 +143,10 @@ std::pair<double, double> calculate_y_range(
143143 * Rin: the inner radius of the layer
144144 * x_left: the x position of the left edge of the sensor to be placed
145145 * kSensorStack: the number of sensors to be stacked on top of each other
146- * tolerance: the tolerance to be subtracted from the maximum y position to avoid
147- * placing sensors too close to the edge. If this is negative, it effectively
148- * means that you can place sensors beyond the nominal disc edge
149- * y_start: the y positions to start placing sensors,
150- * for positive and negative y respectively
146+ * y_ranges: the y positions to start and end placing sensors,
147+ * for positive and negative y respectively
148+ * absAllowedYRange: the absolute y range allowed for placing sensors,
149+ * used to cut placement if they go past allowed tolerances
151150 */
152151void FT3Module::fill_stave (PosNegPositionTypes& y_positions, double Rin, double Rout,
153152 double x_left, unsigned kSensorStack , PositionRangeType y_ranges,
@@ -550,6 +549,13 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
550549 unsigned volume_count = 0 ; // give each subvolume a unique ID
551550 // stave triangle cross sections are the same for every stave (direction based)
552551 std::array<std::array<double , 3 >, 4 > staveTriangles = buildStaveTriangle (direction);
552+ // declare vector with number of 2xn sensor stacks (modules) -- only used for logging
553+ // each entry is a vector, where each entry is the number of modules of that stack height
554+ std::vector<std::vector<unsigned >> nSensorStackCountPerStave (
555+ staveConfig.x_midpoints .size (),
556+ std::vector<unsigned >(Constants::kSensorsPerStack .size (), 0 )
557+ );
558+ std::vector<unsigned > nSensorStackTotal (Constants::kSensorsPerStack .size (), 0 );
553559 for (unsigned i_stave = 0 ; i_stave < staveConfig.x_midpoints .size (); i_stave++) {
554560 y_positionsPosNeg.emplace_back (PosNegPositionTypes{PositionTypes{}, PositionTypes{}});
555561 const int staveID = Constants::staveIdxToID (i_stave, staveConfig.x_midpoints .size ());
@@ -559,16 +565,21 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
559565 // default positive and negative starting points has a gap around x-axis for symmetry
560566 double stave_half_length = staveConfig.y_lengths [i_stave] / 2 ;
561567 PositionRangeType y_ranges;
562- if (ft3Params.placeSensorInMiddleOfStave ) {
568+ if (ft3Params.placeSensorStackInMiddleOfStave ) {
563569 /*
564- * We want a sensor to cross over the x-axis for coverage at y=0
570+ * We want a sensor stack to cross over the x-axis for coverage at y=0
565571 * N.B. not necessarily exactly mirrored, only if stack gap is the same
566- * as the gap between sensors in a stack.
572+ * as the gap between sensors in a stack. Since we start filling with the
573+ * first value in the kSensorsPerStack vector, we offset the first position
574+ * by half of that.
575+ *
576+ * NOTE: TODO: in case the stave is too short to fit one full stack over the middle,
577+ * then we will not be able to place anything since the bottom right/left point of
578+ * the module will already be outside of acceptable bounds -- killing further placement.
567579 */
568- y_ranges = {{-Constants::sensor2x1_height / 2 ,
569- stave_half_length},
570- {-Constants::sensor2x1_height / 2 - Constants::stackGap,
571- -stave_half_length}};
580+ double stackHeight = Constants::getStackHeight (Constants::kSensorsPerStack [0 ]);
581+ y_ranges = {{-stackHeight / 2 , stave_half_length},
582+ {-stackHeight / 2 - Constants::stackGap, -stave_half_length}};
572583 } else {
573584 /*
574585 * Otherwise have a gap around y=0, so sensors are not placed there.
@@ -658,11 +669,35 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
658669
659670 // now add the sensor positions on the stave
660671 for (unsigned i_kSens = 0 ; i_kSens < Constants::kSensorsPerStack .size (); i_kSens++) {
672+ unsigned nModulesCurr = y_positionsPosNeg.back ().first .size ()
673+ + y_positionsPosNeg.back ().second .size ();
661674 fill_stave (y_positionsPosNeg.back (), Rin, Rout, x_left,
662675 Constants::kSensorsPerStack [i_kSens], y_ranges,
663676 absAllowedYRange);
677+ unsigned nModulesAdded = y_positionsPosNeg.back ().first .size ()
678+ + y_positionsPosNeg.back ().second .size ()
679+ - nModulesCurr;
680+ nSensorStackCountPerStave[i_stave][i_kSens] = nModulesAdded;
681+ nSensorStackTotal[i_kSens] += nModulesAdded;
664682 }
683+ std::string moduleDebugStr = " Module size counts for layer " + std::to_string (layerNumber)
684+ + " in direction " + std::to_string (direction) + " :\n " ;
685+ for (unsigned i_kSens = 0 ; i_kSens < Constants::kSensorsPerStack .size (); i_kSens++) {
686+ moduleDebugStr += " \t " + std::to_string (nSensorStackCountPerStave[i_stave][i_kSens])
687+ + " modules with " + std::to_string (Constants::kSensorsPerStack [i_kSens])
688+ + " sensors stacked\n " ;
689+ }
690+ LOG (debug) << moduleDebugStr;
691+ }
692+ std::string totalModuleInfoStr =
693+ " Total module size counts for layer " + std::to_string (layerNumber) +
694+ " in direction " + std::to_string (direction) + " :\n " ;
695+ for (unsigned i_kSens = 0 ; i_kSens < Constants::kSensorsPerStack .size (); i_kSens++) {
696+ totalModuleInfoStr += " \t " + std::to_string (nSensorStackTotal[i_kSens])
697+ + " modules with " + std::to_string (Constants::kSensorsPerStack [i_kSens])
698+ + " sensors stacked\n " ;
665699 }
700+ LOG (info) << totalModuleInfoStr;
666701
667702 // Create volumes for the sensors and the support materials on top of the stave
668703 for (unsigned i_stave = 0 ; i_stave < staveConfig.x_midpoints .size (); i_stave++) {
0 commit comments