Skip to content

Commit 99a136e

Browse files
committed
Bugfix: Stack correctly by using previous stack height in fill_stave, and move in correct direction when placing sensors later
1 parent 02284a8 commit 99a136e

1 file changed

Lines changed: 35 additions & 11 deletions

File tree

Detectors/Upgrades/ALICE3/FT3/simulation/src/FT3Module.cxx

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,40 +169,48 @@ void FT3Module::fill_stave(PosNegPositionTypes& y_positions, double Rin, double
169169
// in case a big tolerance is given, cut on the given range instead
170170
double max_sensor_y_abs = std::min(absAllowedYRange.second, y_ranges.first.second);
171171

172-
double y_top; // top half of the xy grid
172+
double y_top; // top half of the xy grid, y>0
173173
// either start at given value (adjusted for tolerance), or at last placed sensors
174174
if (!y_positions.first.empty()) { // sensors already placed
175-
y_top = y_positions.first.back().first + sensorAbsStackYShift;
175+
double previousStackHeight = Constants::getStackHeight(y_positions.first.back().second);
176+
y_top = y_positions.first.back().first + previousStackHeight + Constants::stackGap;
176177
} else if (y_ranges.first.first < absAllowedYRange.first) {
177178
// given starting y is lower than the minimum allowed y, start at the latter.
178179
y_top = absAllowedYRange.first;
179180
} else {
180181
// given starting y is acceptable, start there
181182
y_top = y_ranges.first.first;
182183
}
184+
LOG(info) << "\tFT3Module: Filling stave at x = " << x_left << " with sensors starting at y = " << y_top
185+
<< " with stack height " << kSensorStack;
183186
while ( (y_top + sensorStackHeight) <= max_sensor_y_abs ) {
184187
y_positions.first.emplace_back(y_top, kSensorStack);
185188
y_top += sensorAbsStackYShift;
186189
}
190+
LOG(info) << "\t\tFilled until y = " << y_top;
187191

188192
// now we do the same for the negative y positions
189193
// they do not have to be exactly mirrored, hence done separately
190194
double y_bottom;
191195
if (!y_positions.second.empty()) {
192196
// subtract instead to move further down
193-
y_bottom = y_positions.second.back().first - sensorAbsStackYShift;
197+
double previousStackHeight = Constants::getStackHeight(y_positions.second.back().second);
198+
y_bottom = y_positions.second.back().first - previousStackHeight - Constants::stackGap;
194199
} else if (y_ranges.second.first > -absAllowedYRange.first) {
195200
// given starting y is closer to x-axis than max allowed y, start at the latter.
196201
y_bottom = -absAllowedYRange.first;
197202
} else {
198203
// given starting y is acceptable, start there
199204
y_bottom = y_ranges.second.first;
200205
}
206+
LOG(info) << "\tFT3Module: Filling stave at x = " << x_left << " with sensors starting at y = " << y_bottom
207+
<< " with stack height " << kSensorStack;
201208
// fill in the sensors on negative y
202209
while ( (y_bottom - sensorStackHeight) >= -max_sensor_y_abs ) {
203210
y_positions.second.emplace_back(y_bottom, kSensorStack);
204211
y_bottom -= sensorAbsStackYShift;
205212
}
213+
LOG(info) << "\t\tFilled until y = " << y_bottom;
206214
}
207215

208216
/*
@@ -328,6 +336,9 @@ void FT3Module::addStaveVolume(
328336
*volume_count,
329337
combiTrans);
330338
(*volume_count)++;
339+
LOG(info) << "\tFT3Module: Added stave volume " << volumeName
340+
<< " at x = " << x_mid << ", y = " << y_mid << ", z = " << z_shift
341+
<< " with length " << staveLengthToUse;
331342
}
332343

333344
/*
@@ -536,6 +547,9 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
536547
mirrorStaveAroundX = y_midpoint_it->second.second;
537548
y_ranges.first = {y_midpoint - stave_half_length, y_midpoint + stave_half_length};
538549
y_ranges.second = {-y_midpoint + stave_half_length, -y_midpoint - stave_half_length};
550+
LOG(info) << "Stave " << staveID << " has defined midpoint at y = " << y_midpoint
551+
<< ", y_ranges=(" << y_ranges.first.first << ", " << y_ranges.first.second
552+
<< ") & (" << y_ranges.second.first << ", " << y_ranges.second.second << ")";
539553
}
540554

541555
// Define tolerances for cutting staves and placing sensors
@@ -555,6 +569,9 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
555569
std::string stave_volume_name =
556570
"Stave_" + std::to_string(i_stave) + "_" + std::to_string(layerNumber) +
557571
"_" + std::to_string(direction);
572+
LOG(info) << "\tFT3Module: Adding stave volume " << stave_volume_name
573+
<< " at x = " << Constants::x_midpoints[i_stave] << ", y = " << y_midpoint
574+
<< ", z = " << mZ + z_stave_shift_abs;
558575
addStaveVolume(
559576
motherVolume, stave_volume_name, direction, &volume_count,
560577
Constants::y_lengths[i_stave], tolerance_inner, tolerance_outer,
@@ -581,6 +598,9 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
581598
}
582599
// Now create the mirrored stave
583600
if (mirrorStaveAroundXAxis) {
601+
LOG(info) << "\tFT3Module: Adding stave volume " << stave_volume_name
602+
<< " at x = " << Constants::x_midpoints[i_stave] << ", y = " << y_midpoint
603+
<< ", z = " << mZ + z_stave_shift_abs;
584604
addStaveVolume(
585605
motherVolume, stave_volume_name + "_mirrored", direction, &volume_count,
586606
Constants::y_lengths[i_stave], tolerance_inner, tolerance_outer,
@@ -626,17 +646,14 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
626646
}
627647

628648
for (unsigned i_y_pos = 0; i_y_pos < y_positionsPosNeg[i_stave].first.size(); i_y_pos++) {
629-
for (unsigned i_y_sign = 0; i_y_sign < 2; i_y_sign++) {
649+
for (int y_sign = -1; y_sign < 2; y_sign+=2) {
630650
// place sensors at positive and negative y
631-
const auto& positions = (i_y_sign == 0) ? y_positionsPosNeg[i_stave].first
651+
const auto& positions = (y_sign == 1) ? y_positionsPosNeg[i_stave].first
632652
: y_positionsPosNeg[i_stave].second;
653+
// define starting midpoint: y = y_start +- distance to middle of sensor
654+
double y_mid = positions[i_y_pos].first + y_sign * Constants::sensor2x1_height / 2;
633655
for (unsigned i_sens = 0; i_sens < positions[i_y_pos].second; i_sens++) {
634656
TGeoVolume* sensor;
635-
double y_mid = // y = y_start + (height + gap of one sensor) * sensor index
636-
positions[i_y_pos].first +
637-
(Constants::sensor2x1_height + Constants::sensor2x1_gap) * i_sens +
638-
Constants::sensor2x1_height / 2; // and add half height to get the middle of the sensor
639-
640657
// ------------ (1) Silicon sensor ------------
641658
// left single sensor of the 2x1
642659
double z_mid = z_offset_to_silicon * z_offset_multiplier + z_stave_shift;
@@ -649,6 +666,11 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
649666
motherVolume, layerNumber, direction, &volume_count,
650667
x_mid + Constants::active_width / 2, y_mid, z_mid, false
651668
);
669+
if (i_stave == 3) {
670+
LOG(info) << "\tFT3Module: Adding sensor on "
671+
<< (y_sign == 0 ? "positive" : "negative") << " y side, sensor "
672+
<< i_sens << " out of " << positions[i_y_pos].second << " at y = " << y_mid;
673+
}
652674

653675
// ------------ (2) Epoxy glue layer between silicon and copper (FPC) ------------
654676
z_mid = z_offset_to_glue_Si * z_offset_multiplier + z_stave_shift;
@@ -674,8 +696,10 @@ void FT3Module::create_layout_staveGeo(double mZ, int layerNumber, int direction
674696
motherVolume, layerNumber, direction, &volume_count,
675697
x_mid, y_mid, z_mid, "CarbonKapton"
676698
);
699+
// increment to next sensor: (height + gap of one sensor)
700+
y_mid += y_sign * (Constants::sensor2x1_height + Constants::sensor2x1_gap);
677701
} // sensors in stack
678-
} // for i_y_sign (writing of positive or negative y positions)
702+
} // for y_sign (writing of positive or negative y positions)
679703
} // i_y_pos
680704
} // i_stave
681705

0 commit comments

Comments
 (0)