67template <
typename Factory>
70 return {.path = d.
node,
138 .region =
checks::bounds(-3000, 3000, -3430, 3430, 87070, 92070)},
162 for (
const auto& s : cavity) {
163 halfX = s.halfX < halfX ? halfX : s.halfX;
164 halfY = s.halfY < halfY ? halfY : s.halfY;
166 return checks::Box{.x = {.lo = -halfX, .hi = halfX},
167 .y = {.lo = -halfY, .hi = halfY},
168 .z = {.lo = cavity.front().zStart, .hi = cavity.back().zEnd}};
175template <std::
size_t N>
176[[nodiscard]]
constexpr std::size_t
firstOutOfOrder(
const std::array<Slot, N>& slots) {
181template <std::
size_t M>
184 for (
const auto& k : known) {
194template <std::
size_t K>
195[[nodiscard]]
constexpr bool isCutOut(
const std::array<CutOut, K>& cutOuts,
const Slot& a,
197 for (
const auto& c : cutOuts) {
198 if (c.from == a.
path && c.cut == b.
path) {
201 if (c.from == b.
path && c.cut == a.
path) {
213 const std::array<Slot, N>& slots,
const std::array<KnownOverlap, M>& known =
kKnownOverlaps,
214 const std::array<CutOut, K>& cutOuts =
kCutOuts) {
215 for (std::size_t i = 0; i < N; ++i) {
216 const Slot& a = slots.at(i);
217 for (std::size_t j = i + 1; j < N; ++j) {
218 const Slot& b = slots.at(j);
252 "subsystem centres must not decrease along the beam");
254 "two subsystem containers overlap, and the pair is not in kKnownOverlaps or "
255 "kCutOuts, or overlaps beyond its recorded region");
260 "a subsystem container reaches outside the world volume");
262 [](
const KnownOverlap& known) {
263 for (
const auto& a :
kSlots) {
264 for (
const auto& b :
kSlots) {
265 if (a.path == known.a && b.path == known.b) {
272 "a known overlap is gone (or names an unknown subsystem): "
273 "drop it from kKnownOverlaps and close its issue");
276 for (
const auto& a :
kSlots) {
277 for (
const auto& b :
kSlots) {
278 if (a.path == c.from && b.path == c.cut) {
287 "a cut-out names an unknown subsystem, its container has left the cavity, or "
288 "the cavity sticks out of the container it is cut from");
299 return checks::box(px, py, pz + C::s_cavernPosZ, hx, hy, hz);
302 hall(C::s_muonCavernPosX, C::s_muonCavernPosY, C::s_muonCavernPosZ, C::s_muonCavernHalfX,
303 C::s_muonCavernHalfY, C::s_muonCavernHalfZ),
304 hall(C::s_expCavernPosX, C::s_expCavernPosY, C::s_expCavernPosZ, C::s_expCavernHalfX,
305 C::s_expCavernHalfY, C::s_expCavernHalfZ),
306 hall(C::s_stairPosX, C::s_stairPosY, C::s_stairPosZ, C::s_stairHalfX, C::s_stairHalfY,
308 hall(C::s_yokePitPosX, C::s_yokePitPosY, C::s_yokePitPosZ, C::s_yokePitHalfX,
309 C::s_yokePitHalfY, C::s_yokePitHalfZ),
310 hall(C::s_targetPitPosX, C::s_targetPitPosY, C::s_targetPitPosZ, C::s_targetPitHalfX,
311 C::s_targetPitHalfY, C::s_targetPitHalfZ),
327 "a subsystem container reaches into the cavern rock");
336 "the tracker container now fits the experiment hall: drop its exception above");
338 "the tracker container reaches further into the rock than kTrackersIntoFloor");
340 "the calorimeter container now fits the experiment hall: drop its exception above");
343 "the calorimeter container reaches further into the rock than "
344 "kCalorimeterIntoFloor");
376 "the target vacuum box reaches into the hadron stopper envelope");
378 "the target vacuum box reaches into the hadron stopper");
383 "the hadron stopper is outside its EDMS envelope along z");
385 "the muon shield container is outside its EDMS region along z");
388 "the muon shield container is outside its EDMS envelope transversely");
390 "the SND container is outside its EDMS envelope transversely");
392 "the UBT container is outside its EDMS envelope along z");
394 "the decay volume container is outside its EDMS envelope along z");
396 "the decay volume container is outside its EDMS envelope transversely");
398 "the trackers container is outside its EDMS envelope along z");
400 "the trackers container is outside its EDMS envelope transversely");
402 "the magnet container is outside its EDMS envelope along z");
404 "the magnet container is outside its EDMS envelope transversely");
406 "the timing detector container is outside its EDMS envelope transversely");
408 "the calorimeter container is outside its EDMS envelope along z");
410 "the calorimeter container is outside its EDMS envelope transversely");
422 "the SND container now fits the EDMS envelope: assert fitsEnvelopeZ instead");
425 "the SND container deviates from the EDMS envelope by more than "
426 "kNeutrinoDetectorEarlyStart");
428 "the UBT container now fits the EDMS envelope: assert fitsEnvelopeXY instead");
431 "the UBT container exceeds the EDMS envelope by more than "
432 "kUpstreamTaggerExcessX/Y");
434 "the timing detector now fits the EDMS envelope: assert fitsEnvelopeZ instead");
436 "the timing detector deviates from the EDMS envelope by more than "
437 "kTimingDetectorEarlyStart");
460 "a tracker station is outside its EDMS envelope");
463 "the spectrometer magnet must sit between tracker stations 2 and 3");
468 "the tracker-magnet marker must sit in the gap between station 2 and the magnet");
Factory for the Cavern (world volume and rock) geometry.
Definition CavernFactory.h:18
static constexpr auto s_worldHalfY
Definition CavernFactory.h:41
static constexpr auto s_worldHalfZ
Definition CavernFactory.h:42
static constexpr auto s_worldHalfX
Definition CavernFactory.h:40
static constexpr auto s_containerHalfY
Definition MagnetFactory.h:56
static constexpr auto s_containerHalfZ
Definition MagnetFactory.h:57
static constexpr auto s_containerHalfX
Definition MagnetFactory.h:55
static constexpr auto s_areaHalfY
Definition MuonShieldFactory.h:126
static constexpr auto s_areaHalfZ
Definition MuonShieldFactory.h:128
static constexpr MagnetData k_hadronStopper
Row 0: the magnetised hadron stopper, [0, 115, 163.5, 169].
Definition MuonShieldFactory.h:67
static constexpr auto k_sndCavity
Cavity for the SND (veto, target, MGC, HCAL): the SND container's sections (NeutrinoDetectorFactory::...
Definition MuonShieldFactory.h:142
static constexpr auto s_areaHalfX
Definition MuonShieldFactory.h:124
static constexpr auto s_halfX
Bounding box of the sections: the HCAL's cross-section and the full 5.05 m length.
Definition NeutrinoDetectorFactory.h:128
static constexpr auto s_halfY
Definition NeutrinoDetectorFactory.h:129
static constexpr auto s_halfZ
Definition NeutrinoDetectorFactory.h:130
static constexpr auto s_vacuumBoxHalfY
Definition TargetFactory.h:82
static constexpr auto s_vacuumBoxHalfZ
Definition TargetFactory.h:83
static constexpr auto s_vacuumBoxHalfX
Definition TargetFactory.h:81
static constexpr auto s_containerHalfZ
Definition TimingDetectorFactory.h:60
static constexpr auto s_containerHalfX
Definition TimingDetectorFactory.h:58
static constexpr auto s_containerHalfY
Definition TimingDetectorFactory.h:59
static constexpr auto s_halfY
Definition TrackersFactory.h:109
static constexpr auto s_halfZ
Definition TrackersFactory.h:110
static constexpr auto s_trackerMagnetZ
centre
Definition TrackersFactory.h:104
static constexpr auto s_station1Z
Definition TrackersFactory.h:113
static constexpr auto s_trackerMagnetHalfZ
half-depth
Definition TrackersFactory.h:105
static constexpr auto s_station4Z
Definition TrackersFactory.h:116
static constexpr auto s_halfX
Definition TrackersFactory.h:108
static constexpr auto s_containerHalfZ
Definition TrackersFactory.h:119
static constexpr auto s_station3Z
Definition TrackersFactory.h:115
static constexpr auto s_station2Z
Definition TrackersFactory.h:114
static constexpr auto s_halfZ
Definition UpstreamTaggerFactory.h:86
static constexpr auto s_halfX
Definition UpstreamTaggerFactory.h:84
static constexpr auto s_halfY
Definition UpstreamTaggerFactory.h:85
constexpr auto kContainerHalfZ
Definition CalorimeterConstants.h:101
constexpr auto kContainerHalfY
Definition CalorimeterConstants.h:100
constexpr auto kContainerHalfX
Definition CalorimeterConstants.h:99
constexpr std::size_t firstPairFailure(const Range &range, Pred ok)
Index i of the first neighbouring pair (range[i], range[i+1]) for which ok is false,...
Definition StaticChecks.h:134
constexpr Box shrunk(const Box &b, LengthMm d)
b with every face moved inwards by d.
Definition StaticChecks.h:104
constexpr bool overlaps(Span a, Span b)
The intervals share more than a boundary. Touching ends do not overlap.
Definition StaticChecks.h:45
constexpr bool coveredBy(const Box &inner, const std::array< Box, N > &outers)
Whether inner lies within the union of outers.
Definition StaticChecks.h:151
constexpr std::size_t firstFailure(const Range &range, Pred ok)
Index of the first element of range for which ok is false, or npos.
Definition StaticChecks.h:120
constexpr bool contains(Span outer, Span inner, LengthMm tol=0.0 *units::mm)
inner lies within outer, allowing tol of slack at either end.
Definition StaticChecks.h:40
constexpr Box bounds(double x0, double x1, double y0, double y1, double z0, double z1)
Box from its bounds in mm, for writing a known region down literally.
Definition StaticChecks.h:80
constexpr Span span(LengthMm centre, LengthMm half)
Interval of a volume with the given centre and half-length.
Definition StaticChecks.h:35
constexpr std::size_t npos
Returned by the first*() searches when every element passes.
Definition StaticChecks.h:111
constexpr bool overlapsWithin(const Box &a, const Box &b, const Box ®ion, LengthMm tol=1e-6 *units::mm)
The boxes overlap, and only within region.
Definition StaticChecks.h:97
constexpr Box box(LengthMm cx, LengthMm cy, LengthMm cz, LengthMm hx, LengthMm hy, LengthMm hz)
Box with centre (cx, cy, cz) and the given half-lengths.
Definition StaticChecks.h:57
constexpr Envelope kMagnet
Definition Envelopes.h:75
constexpr std::array< Envelope, 3 > kCalorimeter
Definition Envelopes.h:79
constexpr auto kSurroundTaggerThickness
Thickness of the SBT shell around the decay volume (the CSV lists it as a half-width/height of 0....
Definition Envelopes.h:68
constexpr Envelope kUpstreamTagger
Definition Envelopes.h:62
constexpr Envelope kNeutrinoDetector
Definition Envelopes.h:60
constexpr std::array< Envelope, 4 > kTrackerStations
Definition Envelopes.h:69
constexpr Envelope hull(std::string_view name, const std::array< Envelope, N > &parts)
Union of several consecutive envelopes, from the first start to the last end, with the largest transv...
Definition Envelopes.h:89
constexpr Envelope kTimingDetector
Definition Envelopes.h:77
constexpr Envelope kDecayVolume
Definition Envelopes.h:64
constexpr std::array< Envelope, 5 > kMuonShield
Definition Envelopes.h:53
constexpr Envelope kHadronStopper
Definition Envelopes.h:51
constexpr auto mm
Definition Layout.h:61
constexpr auto kTrackerRegion
Tracker stations 1 to 4, including the magnet gap between 2 and 3.
Definition Layout.h:369
constexpr auto kCalorimeterRegion
Split ECAL front and back plus the HCAL.
Definition Layout.h:372
constexpr envelopes::Envelope kDecayVolumeWithSBT
Decay volume plus the SBT shell wrapped around it.
Definition Layout.h:359
constexpr envelopes::Envelope kMuonShieldRegion
Muon shield region: the hadron stopper start to the end of the last magnet.
Definition Layout.h:352
constexpr auto zero
Definition Layout.h:62
Where each subsystem container sits in the world volume.
Definition Layout.h:40
constexpr bool isCutOut(const std::array< CutOut, K > &cutOuts, const Slot &a, const Slot &b)
One of the pair has the other's shape cut out of it (listed in cutOuts), and the other lies within th...
Definition Layout.h:195
constexpr checks::Box kWorld
The world volume built by CavernFactory, centred on the origin.
Definition Layout.h:229
constexpr checks::Span trackerStation(LengthMm centreZ)
Absolute z-span of one tracker station.
Definition Layout.h:442
constexpr Slot kUpstreamTagger
Definition Layout.h:96
constexpr auto kUpstreamTaggerExcessX
Definition Layout.h:416
constexpr std::array kCavities
The halls CavernFactory cuts out of the rock, in the world frame.
Definition Layout.h:295
constexpr std::size_t firstOutOfOrder(const std::array< Slot, N > &slots)
Centres never decrease along the slot list.
Definition Layout.h:176
constexpr Slot kDecayVolume
Definition Layout.h:99
constexpr std::array kSlots
All subsystems, in placement order (upstream to downstream).
Definition Layout.h:120
constexpr std::array kCutOuts
The SND sits in a cavity of the muon-shield container (#117).
Definition Layout.h:154
constexpr bool isKnownOverlap(const std::array< KnownOverlap, M > &known, const Slot &a, const Slot &b)
The pair is listed in known and overlaps no further than its region.
Definition Layout.h:182
constexpr auto kCalorimeterIntoFloor
Definition Layout.h:334
constexpr auto kNeutrinoDetectorEarlyStart
Definition Layout.h:415
constexpr std::size_t firstUnexpectedOverlap(const std::array< Slot, N > &slots, const std::array< KnownOverlap, M > &known=kKnownOverlaps, const std::array< CutOut, K > &cutOuts=kCutOuts)
Index of the first slot that overlaps a later one, unless the pair is a known overlap that has not gr...
Definition Layout.h:212
constexpr std::array kTrackerStationZ
Definition Layout.h:446
constexpr Slot kTarget
Definition Layout.h:80
constexpr Slot kTrackers
The factory positions its stations relative to s_containerCentreZ, so the container goes there and th...
Definition Layout.h:105
constexpr Slot kTimingDetector
Definition Layout.h:112
constexpr auto kTrackersIntoFloor
Definition Layout.h:333
constexpr Slot slotOf(LengthMm halfX, LengthMm halfY, LengthMm halfZ)
A factory's slot: its registered placement (descriptor()) together with its container half-lengths.
Definition Layout.h:68
constexpr auto kTimingDetectorEarlyStart
Definition Layout.h:418
constexpr auto kUpstreamTaggerExcessY
Definition Layout.h:417
constexpr Slot kMuonShield
Definition Layout.h:84
constexpr bool fitsEnvelopeZ(const Slot &slot, const envelopes::Envelope &env, LengthMm tol=1e-6 *detail::mm)
Container lies inside the envelope along the beam (with tol of slack, for values that are equal on pa...
Definition Layout.h:234
constexpr Slot kCalorimeter
Definition Layout.h:116
constexpr std::array kKnownOverlaps
Definition Layout.h:134
constexpr Slot kMagnet
Definition Layout.h:108
constexpr Slot kNeutrinoDetector
z 22.94-27.99 m, in the end of muon-shield magnet M5 and the whole of M6 (FairShip TRY_2026).
Definition Layout.h:92
constexpr bool isInCavity(const Slot &slot)
The container lies within the halls taken together: the muon shield runs from TCC8 across the step in...
Definition Layout.h:318
constexpr bool fitsEnvelopeXY(const Slot &slot, const envelopes::Envelope &env, LengthMm tolX=detail::zero, LengthMm tolY=detail::zero)
Container stays inside the envelope's largest transverse size (with tolX and tolY of slack).
Definition Layout.h:241
constexpr auto kEnvelopeHalfZ
Definition SBTConstants.h:88
constexpr auto kEnvelopeHalfX
Definition SBTConstants.h:86
constexpr auto kEnvelopeHalfY
Definition SBTConstants.h:87
mp_units::quantity< mm > LengthMm
Spellings for struct members and function parameters.
Definition Units.h:39
constexpr auto mm
Definition Units.h:27
A subsystem's self-description: everything the assembler needs.
Definition SubsystemDescriptor.h:20
double z_mm
placement translation Z, beam direction (mm)
Definition SubsystemDescriptor.h:26
int id
GeoIdentifierTag.
Definition SubsystemDescriptor.h:23
double x_mm
placement translation X (mm)
Definition SubsystemDescriptor.h:24
const char * node
GeoNameTag, e.g. "/SHiP/calorimeter".
Definition SubsystemDescriptor.h:22
double y_mm
placement translation Y (mm)
Definition SubsystemDescriptor.h:25
Axis-aligned box.
Definition StaticChecks.h:50
Span z
Definition StaticChecks.h:53
Closed interval along one axis.
Definition StaticChecks.h:29
LengthMm hi
Definition StaticChecks.h:31
LengthMm lo
Definition StaticChecks.h:30
Definition Envelopes.h:28
constexpr LengthMm maxHalfWidth() const
Definition Envelopes.h:38
constexpr LengthMm maxHalfHeight() const
Definition Envelopes.h:41
constexpr checks::Span z() const
Definition Envelopes.h:37
A container with a cavity of another container's shape cut out of it.
Definition Layout.h:147
std::string_view cut
Definition Layout.h:149
std::string_view from
Definition Layout.h:148
checks::Box hole
Definition Layout.h:150
Two containers that overlap, although Geant4 does not support overlapping siblings.
Definition Layout.h:128
std::string_view a
Definition Layout.h:129
std::string_view b
Definition Layout.h:130
checks::Box region
Definition Layout.h:131
LengthMm x
Definition Layout.h:47
LengthMm halfZ
Definition Layout.h:52
LengthMm z
Definition Layout.h:49
constexpr checks::Box box() const
Definition Layout.h:54
LengthMm halfY
Definition Layout.h:51
LengthMm y
Definition Layout.h:48
LengthMm halfX
Definition Layout.h:50
constexpr checks::Span zSpan() const
Definition Layout.h:57
int id
Definition Layout.h:46
std::string_view path
Definition Layout.h:45