SHiP Geometry
SHiP experiment geometry implementation using GeoModel.
Loading...
Searching...
No Matches
SBTConstants.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Copyright (C) CERN for the benefit of the SHiP Collaboration
3
4#pragma once
5
7
8#include <algorithm>
9#include <string_view>
10
20
21using units::LengthMm;
22using units::mm;
23
37struct SBTParams {
38 // ── Frustum envelope ────────────────────────────────────────────────
41 LengthMm xHalfExit = 2000.0 * mm;
42 LengthMm yHalfExit = 3000.0 * mm;
43 LengthMm totalLength = 50000.0 * mm;
44 int nSubFrustum = 10;
45 LengthMm yFloor = -3000.0 * mm;
46 LengthMm zEntrance = -25000.0 * mm;
47
48 // ── H-beam cross-section (HEA 260 approximation) ────────────────────
53
54 // ── Sensor containers / cells ───────────────────────────────────────
57 int nCells = 6;
59
60 // ── Helium decay region ─────────────────────────────────────────────
61 // Gap left between the helium and the innermost SBT material, measured
62 // along the coordinate axis. Must be >= 0; SBTEnvelope enforces that and
63 // is the only consumer. It is not a safety margin — the default of 1 um is
64 // simply enough to stop the helium and the SBT sharing a surface, which
65 // Geant4's navigator handles badly. 0 is legal and gives exact
66 // face-to-face contact.
68};
69
79inline constexpr SBTParams kSBT{};
80
81// ── Air container enclosing the SBT structure + sensors and helium ──────
82// The experiment's fixed envelope allocation for the decay region. Not an SBT
83// dimension and deliberately not part of SBTParams: nothing is derived from
84// it, and the three static_asserts at the bottom of this header are bounds the
85// SBT must fit *inside*, not parameters it is built *from*.
86inline constexpr auto kEnvelopeHalfX = 2200.0 * mm;
87inline constexpr auto kEnvelopeHalfY = 3300.0 * mm;
88inline constexpr auto kEnvelopeHalfZ = 25200.0 * mm;
89
90// ── Materials (names in Materials) ──────────────────────────────────
91inline constexpr std::string_view kAirMaterial = "Air"; // envelope container
92inline constexpr std::string_view kSteelMaterial = "Iron"; // H-beam structure
93inline constexpr std::string_view kWallMaterial = "Aluminium"; // sensor cell walls
94inline constexpr std::string_view kScintillatorMaterial = "LAB"; // sensor cells
95inline constexpr std::string_view kHeliumMaterial = "PressurisedHe90"; // decay region
96
97// ── Derived quantities ──────────────────────────────────────────────────
98//
99// Convention for everything below: the parameters come last and default to
100// kSBT. Last rather than first because most of these already have a
101// meaningful leading argument (a Z, a half-width) and a defaulted parameter
102// cannot precede a non-defaulted one. The parameter is named `params`, not
103// `p`, because `p` is the conventional loop variable for a HeliumPiece in
104// SBTEnvelope and in the tests.
105
107constexpr LengthMm subLength(const SBTParams& params = kSBT) {
108 return params.totalLength / params.nSubFrustum;
109}
110
111constexpr LengthMm webHeight(const SBTParams& params = kSBT) {
112 return params.hbeamHeight - 2.0 * params.hbeamFlangeThickness;
113}
114
115constexpr int nWalls(const SBTParams& params = kSBT) {
116 return params.nCells + 1;
117}
118
119// ── Frustum profile ─────────────────────────────────────────────────────
121constexpr LengthMm zExit(const SBTParams& params = kSBT) {
122 return params.zEntrance + params.totalLength;
123}
124
125constexpr double xGrowth(const SBTParams& params = kSBT) {
126 return units::ratio((params.xHalfExit - params.xHalfEntrance) / params.totalLength);
127}
128
129constexpr double yGrowth(const SBTParams& params = kSBT) {
130 return units::ratio((params.yHalfExit - params.yHalfEntrance) / params.totalLength);
131}
132
133constexpr LengthMm xHalfAt(LengthMm z, const SBTParams& params = kSBT) {
134 return params.xHalfEntrance + (z - params.zEntrance) * xGrowth(params);
135}
136
137constexpr LengthMm yHalfAt(LengthMm z, const SBTParams& params = kSBT) {
138 return params.yHalfEntrance + (z - params.zEntrance) * yGrowth(params);
139}
140
141constexpr LengthMm zSubLo(int s, const SBTParams& params = kSBT) {
142 return params.zEntrance + s * subLength(params);
143}
144
145// ── H-beam cross-section primitives ─────────────────────────────────────
147constexpr LengthMm hbeamFlangeOffset(const SBTParams& params = kSBT) {
148 return 0.5 * params.hbeamHeight - 0.5 * params.hbeamFlangeThickness;
149}
150
151constexpr LengthMm hbeamHalfHeight(const SBTParams& params = kSBT) {
152 return 0.5 * params.hbeamHeight;
153}
154
155// ══════════════════════════════════════════════════════════════════════
156// PLACEMENT PRIMITIVES — the single source of truth.
157//
158// These are THE definitions of where SBT material sits. Both builders
159// place volumes with them, and SBTEnvelope derives the helium inner
160// envelope from them, so a change to any rule below propagates to the
161// helium automatically and the two can never drift apart.
162// Do not open-code these expressions anywhere else.
163// ══════════════════════════════════════════════════════════════════════
164
168constexpr LengthMm zSplitOffset(const SBTParams& params = kSBT) {
169 return 0.5 * params.hbeamHeight + 0.5 * params.hbeamFlangeThickness;
170}
171
172// --- Side (±X) scintillator containers -------------------------------
175 return 0.5 * params.containerThickness;
176}
177
178constexpr LengthMm sideContainerCentreX(LengthMm xHalf, const SBTParams& params = kSBT) {
179 return xHalf - 0.5 * params.hbeamFlangeWidth - sideContainerHalfThickness(params);
180}
181
182constexpr LengthMm sideSensorInnerX(LengthMm xHalf, const SBTParams& params = kSBT) {
183 return sideContainerCentreX(xHalf, params) - sideContainerHalfThickness(params);
184}
185
186// --- Top/bottom (±Y) scintillator containers -------------------------
189 return 0.5 * params.containerThickness - params.sensorClearance;
190}
191
192constexpr LengthMm topBottomContainerCentreY(LengthMm yHalf, const SBTParams& params = kSBT) {
193 return yHalf - 0.5 * params.containerThickness;
194}
195
196constexpr LengthMm topBottomSensorInnerY(LengthMm yHalf, const SBTParams& params = kSBT) {
197 return topBottomContainerCentreY(yHalf, params) - topBottomContainerHalfThickness(params);
198}
199
208constexpr LengthMm topBottomAvailX(LengthMm xHalf, const SBTParams& params = kSBT) {
209 return xHalf - 0.5 * params.hbeamFlangeWidth - 1.0 * mm;
210}
211
212// --- Top/bottom longitudinal beams -----------------------------------
213// NOTE: these beams *straddle* the scintillator plane — the outer flange
214// sits above it, the web is omitted (it would pass through the cells),
215// and the INNER FLANGE HANGS BELOW IT, INSIDE THE DECAY REGION. It, not
216// the scintillator, is the innermost material in ±Y.
218constexpr LengthMm longBeamCentreY(LengthMm yHalf, const SBTParams& params = kSBT) {
219 return yHalf - 0.5 * webHeight(params);
220}
221
222namespace detail {
223
239constexpr double sqrtConst(double v) {
240 if (v <= 0.0) {
241 return 0.0;
242 }
243 double x = v;
244 double prev = 0.0;
245 for (int i = 0; i < 200 && x != prev; ++i) {
246 prev = x;
247 x = 0.5 * (x + (v / x));
248 }
249 return x;
250}
251
253constexpr double longBeamTaper(const SBTParams& params = kSBT) {
254 const double g = yGrowth(params);
255 return sqrtConst(1.0 + (g * g));
256}
257
258} // namespace detail
259
265constexpr LengthMm longBeamInnerY(LengthMm yHalf, const SBTParams& params = kSBT) {
266 return longBeamCentreY(yHalf, params) - hbeamHalfHeight(params) * detail::longBeamTaper(params);
267}
268
269// ── Compile-time validation ─────────────────────────────────────────────
270//
271// Whether an arbitrary SBTParams is buildable at all is SBTEnvelope's
272// leavesDecayRegion(), which the tests exercise on configurations that must
273// not build. What follows constrains the *shipped* parameters only.
274
279constexpr bool isWellFormed(const SBTParams& params = kSBT) {
280 return params.totalLength > 0.0 * mm && params.xHalfEntrance > 0.0 * mm &&
281 params.yHalfEntrance > 0.0 * mm && params.xHalfExit > 0.0 * mm &&
282 params.yHalfExit > 0.0 * mm && params.hbeamFlangeWidth > 0.0 * mm &&
283 params.hbeamFlangeThickness > 0.0 * mm && params.hbeamWebThickness > 0.0 * mm &&
284 params.containerThickness > 0.0 * mm && params.cellWallThickness > 0.0 * mm &&
285 params.nSubFrustum > 0 && params.nCells > 0 && params.sensorClearance > 0.0 * mm &&
286 params.sensorClearance < 0.5 * params.containerThickness &&
287 params.hbeamHeight > 2.0 * params.hbeamFlangeThickness &&
288 params.heliumClearance >= 0.0 * mm;
289}
290
291static_assert(isWellFormed(kSBT),
292 "the shipped SBT parameters are not self-consistent: check positivity, the "
293 "sensor clearance against the container thickness, and the flange thickness "
294 "against the beam height");
295static_assert(zSplitOffset(kSBT) < subLength(kSBT),
296 "the sensor containers' flat piece no longer fits inside a sub-frustum; "
297 "reduce nSubFrustum or hbeamHeight");
298static_assert(nWalls(kSBT) * kSBT.cellWallThickness < zSplitOffset(kSBT) &&
300 "the cell walls do not fit both pieces of a split sensor container");
301
302// The SBT structure must fit the fixed decay-volume envelope. Bounds on the
303// outermost structure reach; with the current values the reaches are
304// ~2130 / ~3259 / ~25130 mm, inside the 2200 / 3300 / 25200 envelope.
305// X: vertical columns sit at the wider of the two frustum faces, with a
306// half-flange overhang.
307// Y: top/bottom cross-beams are shifted a full beam-height above yHalfExit
308// (plus a small frustum-growth term); +10 pads the assembly standoff.
309// Z: the structure spans [zEntrance, zExit()]; cross-beam flanges extend
310// half a flange-width beyond the end rows.
311//
312// These bound kSBT against the envelope allocation and are deliberately not
313// part of isWellFormed(): the parameter sweep in test_decayvolume varies the
314// frustum well past this allocation on purpose, and builds into a generous
315// throwaway container precisely because of it.
316static_assert(std::max(kSBT.xHalfEntrance, kSBT.xHalfExit) + 0.5 * kSBT.hbeamFlangeWidth <=
318 "SBT structure pierces the decay-volume envelope in X");
319static_assert(kSBT.yHalfExit + kSBT.hbeamHeight + 0.5 * kSBT.hbeamFlangeWidth * yGrowth(kSBT) +
320 10.0 * mm <=
322 "SBT structure pierces the decay-volume envelope in Y");
323static_assert(std::max(kSBT.zEntrance < 0.0 * mm ? -kSBT.zEntrance : kSBT.zEntrance,
324 zExit(kSBT) < 0.0 * mm ? -zExit(kSBT) : zExit(kSBT)) +
325 0.5 * kSBT.hbeamFlangeWidth <=
327 "SBT structure pierces the decay-volume envelope in Z");
328
329} // namespace SHiP::geometry::sbt
Definition SBTConstants.h:222
constexpr double sqrtConst(double v)
Square root of v, usable in a constant expression.
Definition SBTConstants.h:239
constexpr double longBeamTaper(const SBTParams &params=kSBT)
Taper factor of a top/bottom longitudinal beam, 1/cos(atan(yGrowth)).
Definition SBTConstants.h:253
Compile-time parameters of the Surround Background Tagger (SBT).
Definition SBTConstants.h:19
constexpr SBTParams kSBT
The shipped SBT.
Definition SBTConstants.h:79
constexpr LengthMm subLength(const SBTParams &params=kSBT)
Length of one sub-frustum along Z.
Definition SBTConstants.h:107
constexpr auto kEnvelopeHalfZ
Definition SBTConstants.h:88
constexpr LengthMm yHalfAt(LengthMm z, const SBTParams &params=kSBT)
Half-extent of the frustum envelope in Y at a given Z.
Definition SBTConstants.h:137
constexpr LengthMm webHeight(const SBTParams &params=kSBT)
Clear web height = height - 2*flange thickness.
Definition SBTConstants.h:111
constexpr std::string_view kSteelMaterial
Definition SBTConstants.h:92
constexpr LengthMm zSubLo(int s, const SBTParams &params=kSBT)
Z of the start of sub-frustum s.
Definition SBTConstants.h:141
constexpr LengthMm sideContainerCentreX(LengthMm xHalf, const SBTParams &params=kSBT)
|X| of a side container's centroid, given the local frustum half-width.
Definition SBTConstants.h:178
constexpr std::string_view kWallMaterial
Definition SBTConstants.h:93
constexpr double xGrowth(const SBTParams &params=kSBT)
dx_half/dz of the frustum (dimensionless).
Definition SBTConstants.h:125
constexpr bool isWellFormed(const SBTParams &params=kSBT)
Are params self-consistent, before asking whether they leave a decay region?
Definition SBTConstants.h:279
constexpr LengthMm hbeamHalfHeight(const SBTParams &params=kSBT)
Reach of a flange's outer surface from the beam axis = h/2.
Definition SBTConstants.h:151
constexpr std::string_view kAirMaterial
Definition SBTConstants.h:91
constexpr auto kEnvelopeHalfX
Definition SBTConstants.h:86
constexpr LengthMm longBeamCentreY(LengthMm yHalf, const SBTParams &params=kSBT)
|Y| of a top/bottom longitudinal beam's axis.
Definition SBTConstants.h:218
constexpr LengthMm zExit(const SBTParams &params=kSBT)
Exit-face Z in the DecayVolume local frame.
Definition SBTConstants.h:121
constexpr std::string_view kHeliumMaterial
Definition SBTConstants.h:95
constexpr double yGrowth(const SBTParams &params=kSBT)
dy_half/dz of the frustum (dimensionless).
Definition SBTConstants.h:129
constexpr auto kEnvelopeHalfY
Definition SBTConstants.h:87
constexpr LengthMm hbeamFlangeOffset(const SBTParams &params=kSBT)
Offset of a flange's mid-plane from the beam axis.
Definition SBTConstants.h:147
constexpr LengthMm xHalfAt(LengthMm z, const SBTParams &params=kSBT)
Half-extent of the frustum envelope in X at a given Z.
Definition SBTConstants.h:133
constexpr LengthMm zSplitOffset(const SBTParams &params=kSBT)
Z offset, from the start of a sub-frustum, of the column front-flange outer edge.
Definition SBTConstants.h:168
constexpr auto mm
Definition Units.h:27
constexpr LengthMm sideContainerHalfThickness(const SBTParams &params=kSBT)
Half-thickness of a side container in X.
Definition SBTConstants.h:174
constexpr LengthMm longBeamInnerY(LengthMm yHalf, const SBTParams &params=kSBT)
|Y| reached by a longitudinal beam's inner flange surface.
Definition SBTConstants.h:265
constexpr LengthMm topBottomAvailX(LengthMm xHalf, const SBTParams &params=kSBT)
Half-extent in X available to top/bottom containers.
Definition SBTConstants.h:208
constexpr LengthMm topBottomContainerHalfThickness(const SBTParams &params=kSBT)
Half-thickness of a top/bottom container in Y.
Definition SBTConstants.h:188
constexpr int nWalls(const SBTParams &params=kSBT)
Number of aluminium walls per container (nCells + 1).
Definition SBTConstants.h:115
constexpr LengthMm topBottomSensorInnerY(LengthMm yHalf, const SBTParams &params=kSBT)
|Y| of a top/bottom container's innermost face.
Definition SBTConstants.h:196
constexpr LengthMm sideSensorInnerX(LengthMm xHalf, const SBTParams &params=kSBT)
|X| of a side container's innermost face.
Definition SBTConstants.h:182
constexpr LengthMm topBottomContainerCentreY(LengthMm yHalf, const SBTParams &params=kSBT)
|Y| of a top/bottom container's centroid.
Definition SBTConstants.h:192
constexpr std::string_view kScintillatorMaterial
Definition SBTConstants.h:94
mp_units::quantity< mm > LengthMm
Spellings for struct members and function parameters.
Definition Units.h:39
constexpr double ratio(mp_units::quantity< one > q)
Dimensionless quantity -> plain double (counts, growth slopes, and inputs to GeoGenfun / Eigen,...
Definition Units.h:82
constexpr auto mm
Definition Units.h:27
constexpr auto mm
Definition Units.h:27
Every dimension the SBT geometry is parameterised by.
Definition SBTConstants.h:37
LengthMm yHalfEntrance
Definition SBTConstants.h:40
int nCells
Definition SBTConstants.h:57
LengthMm xHalfEntrance
Definition SBTConstants.h:39
LengthMm totalLength
Definition SBTConstants.h:43
LengthMm hbeamWebThickness
Definition SBTConstants.h:52
LengthMm hbeamFlangeThickness
Definition SBTConstants.h:51
LengthMm cellWallThickness
Definition SBTConstants.h:56
int nSubFrustum
Definition SBTConstants.h:44
LengthMm sensorClearance
Definition SBTConstants.h:58
LengthMm yHalfExit
Definition SBTConstants.h:42
LengthMm xHalfExit
Definition SBTConstants.h:41
LengthMm zEntrance
Definition SBTConstants.h:46
LengthMm hbeamHeight
Definition SBTConstants.h:49
LengthMm hbeamFlangeWidth
Definition SBTConstants.h:50
LengthMm containerThickness
Definition SBTConstants.h:55
LengthMm heliumClearance
Definition SBTConstants.h:67
LengthMm yFloor
Definition SBTConstants.h:45