Skip to content

Commit f220c7c

Browse files
committed
Negative staggering for L6
1 parent 5c367c1 commit f220c7c

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

Detectors/Upgrades/ALICE3/TRK/simulation/src/TRKLayer.cxx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ TRKMLLayer::TRKMLLayer(int layerNumber, std::string layerName, float rInn, float
248248
mOuterRadius = rInn;
249249
mInnerRadius = rInn - mChipThickness;
250250
mIsFlipped = true;
251+
mStaggerOffset = -staggerOffset;
251252
LOGP(info, "Layer {} is flipped: sensor and metal stack positions are switched", mLayerNumber);
252253
}
253254
}
@@ -321,12 +322,12 @@ void TRKMLLayer::createLayer(TGeoVolume* motherVolume)
321322

322323
std::pair<float, float> TRKMLLayer::getBoundingRadii(double staveWidth) const
323324
{
324-
// Get the baseline RMin from the base class (the inner boundary remains the same)
325-
auto [radiusMin, defaultRadiusMax] = TRKSegmentedLayer::getBoundingRadii(staveWidth);
325+
// Get the baseline RMin from the base class
326+
auto [defaultRadiusMin, defaultRadiusMax] = TRKSegmentedLayer::getBoundingRadii(staveWidth);
326327

327-
// If we are not in the staggered layers (3 and 4), return the baseline values
328+
// If we are not in the staggered layers, return the baseline values
328329
if (mLayerNumber != 3 && mLayerNumber != 4) {
329-
return {radiusMin, defaultRadiusMax};
330+
return {defaultRadiusMin, defaultRadiusMax};
330331
}
331332

332333
/*// For staggered layers, we must recalculate RMax based on the outer shifted row
@@ -340,22 +341,40 @@ std::pair<float, float> TRKMLLayer::getBoundingRadii(double staveWidth) const
340341
341342
const float radiusMax = std::sqrt(avgRadiusOuter * avgRadiusOuter + 0.25 * staveSizeX * staveSizeX + 0.25 * staveSizeY * staveSizeY + avgRadiusOuter * 2. * deltaForTiltOuter);*/
342343

343-
// For staggered layers, we must recalculate ONLY the radiusMax based on the outer shifted row (staggered barycenter)
344344
const float avgRadiusInner = 0.5 * (mInnerRadius + mOuterRadius);
345-
const float avgRadiusOuter = avgRadiusInner + mStaggerOffset;
345+
const float avgRadiusStaggered = avgRadiusInner + mStaggerOffset;
346346

347347
const float staveSizeX = staveWidth;
348348
const float staveSizeY = mOuterRadius - mInnerRadius;
349349
const float alpha = TMath::DegToRad() * std::abs(mTiltAngle);
350350

351-
// The maximum radius uses avgRadiusOuter instead of avgRadiusInner
352-
float u_max = avgRadiusOuter * std::sin(alpha) + staveSizeX / 2.0;
353-
float v_max = avgRadiusOuter * std::cos(alpha) + staveSizeY / 2.0;
354-
float radiusMax = std::sqrt(u_max * u_max + v_max * v_max);
355-
356351
const float precisionMargin = 0.05f;
357352

358-
return {radiusMin, radiusMax + precisionMargin};
353+
// If the layer is NOT flipped (e.g., Layer 4), the stagger goes outwards
354+
// Therefore, we must recalculate only the maximum radius based on the outer shifted row
355+
if (!mIsFlipped) {
356+
float u_max = avgRadiusStaggered * std::sin(alpha) + staveSizeX / 2.0;
357+
float v_max = avgRadiusStaggered * std::cos(alpha) + staveSizeY / 2.0;
358+
float radiusMax = std::sqrt(u_max * u_max + v_max * v_max);
359+
360+
return {defaultRadiusMin, radiusMax + precisionMargin};
361+
}
362+
// If the layer IS flipped (e.g., Layer 3), the stagger goes inwards
363+
// Therefore, we must recalculate only the minimum radius based on the inner shifted row
364+
else {
365+
double perpDistance = avgRadiusStaggered * std::cos(alpha) - staveSizeY / 2.0;
366+
double projDistance = avgRadiusStaggered * std::sin(alpha);
367+
double newRadiusMin;
368+
369+
if (projDistance <= staveSizeX / 2.0) {
370+
newRadiusMin = perpDistance;
371+
} else {
372+
double u_min = projDistance - staveSizeX / 2.0;
373+
newRadiusMin = std::sqrt(u_min * u_min + perpDistance * perpDistance);
374+
}
375+
376+
return {newRadiusMin - precisionMargin, defaultRadiusMax};
377+
}
359378
}
360379

361380
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)