SHiP Geometry
SHiP experiment geometry implementation using GeoModel.
Loading...
Searching...
No Matches
MuonShieldFactory.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
9
10#include <algorithm>
11#include <array>
12#include <cstddef>
13
14class GeoPhysVol;
15
16namespace SHiP::geometry {
17
18class Materials;
19
24 const char* name;
27
28 [[nodiscard]] constexpr units::LengthMm zEnd() const { return zStart + 2.0 * halfZ; }
29 [[nodiscard]] constexpr units::LengthMm zCentre() const { return zStart + halfZ; }
30};
31
52 public:
53 explicit MuonShieldFactory(Materials& materials);
54 ~MuonShieldFactory() = default;
55
56 [[nodiscard]] GeoPhysVol* build();
57
59
60 // Source: FairShip python/geometry_config.py, shield_db["TRY_2026"], one
61 // row [Zgap, dZ, dX, dY] in cm per magnet. The half-sizes are (dX, dY, dZ).
62 // Each magnet starts its Zgap after the previous one ends, and the first
63 // row starts at the hadron stopper's front face, 2.14 m (FairShip
64 // hadronAbsorber.z, and the EDMS envelope).
65
67 static constexpr MagnetData k_hadronStopper{.name = "magn_absorb",
68 .zStart = 2140.0 * units::mm,
69 .halfX = 1635.0 * units::mm,
70 .halfY = 1690.0 * units::mm,
71 .halfZ = 1150.0 * units::mm};
72
74 static constexpr std::array<MagnetData, 7> k_magnets{{
75 // [15, 150, 136, 80]
76 {.name = "magn_1",
77 .zStart = 4590.0 * units::mm,
78 .halfX = 1360.0 * units::mm,
79 .halfY = 800.0 * units::mm,
80 .halfZ = 1500.0 * units::mm},
81 // [30, 225, 149, 89]
82 {.name = "magn_2",
83 .zStart = 7890.0 * units::mm,
84 .halfX = 1490.0 * units::mm,
85 .halfY = 890.0 * units::mm,
86 .halfZ = 2250.0 * units::mm},
87 // [16, 225, 155.2, 85]
88 {.name = "magn_3",
89 .zStart = 12550.0 * units::mm,
90 .halfX = 1552.0 * units::mm,
91 .halfY = 850.0 * units::mm,
92 .halfZ = 2250.0 * units::mm},
93 // [15, 225, 159.2, 60]
94 {.name = "magn_4",
95 .zStart = 17200.0 * units::mm,
96 .halfX = 1592.0 * units::mm,
97 .halfY = 600.0 * units::mm,
98 .halfZ = 2250.0 * units::mm},
99 // [16, 131, 134, 52]
100 {.name = "magn_5",
101 .zStart = 21860.0 * units::mm,
102 .halfX = 1340.0 * units::mm,
103 .halfY = 520.0 * units::mm,
104 .halfZ = 1310.0 * units::mm},
105 // [15, 168, 150, 63]
106 {.name = "magn_6",
107 .zStart = 24630.0 * units::mm,
108 .halfX = 1500.0 * units::mm,
109 .halfY = 630.0 * units::mm,
110 .halfZ = 1680.0 * units::mm},
111 // [19, 200, 171, 127]
112 {.name = "magn_7",
113 .zStart = 28180.0 * units::mm,
114 .halfX = 1710.0 * units::mm,
115 .halfY = 1270.0 * units::mm,
116 .halfZ = 2000.0 * units::mm},
117 }};
118
122 static constexpr auto s_zStart = k_hadronStopper.zStart;
123 static constexpr auto s_zEnd = k_magnets.back().zEnd();
124 static constexpr auto s_areaHalfX = std::ranges::max(
125 k_hadronStopper.halfX, std::ranges::max(k_magnets, {}, &MagnetData::halfX).halfX);
126 static constexpr auto s_areaHalfY = std::ranges::max(
127 k_hadronStopper.halfY, std::ranges::max(k_magnets, {}, &MagnetData::halfY).halfY);
128 static constexpr auto s_areaHalfZ = 0.5 * (s_zEnd - s_zStart);
129 static constexpr auto s_centreZ = 0.5 * (s_zStart + s_zEnd);
130
137
142 static constexpr auto k_sndCavity = [] {
143 using NDF = NeutrinoDetectorFactory;
144 static_assert(NDF::descriptor().x_mm == 0.0 && NDF::descriptor().y_mm == 0.0,
145 "the SND cavity assumes the SND is centred on the beam axis");
146 const auto origin = NDF::descriptor().z_mm * units::mm;
147 std::array<CavitySection, NDF::k_sections.size()> cavity{};
148 for (std::size_t i = 0; i < cavity.size(); ++i) {
149 const auto& s = NDF::k_sections.at(i);
150 cavity.at(i) = {.zStart = origin + s.zStart,
151 .zEnd = origin + s.zEnd,
152 .halfX = s.halfX,
153 .halfY = s.halfY};
154 }
155 return cavity;
156 }();
157
159 [[nodiscard]] static constexpr bool cuts(const CavitySection& section,
160 const MagnetData& magnet) {
161 return magnet.zStart < section.zEnd && section.zStart < magnet.zEnd();
162 }
163
165 [[nodiscard]] static constexpr bool hasSndCavity(const MagnetData& magnet) {
166 return std::ranges::any_of(k_sndCavity,
167 [&magnet](const CavitySection& s) { return cuts(s, magnet); });
168 }
169
176 static constexpr SubsystemDescriptor descriptor() {
177 using units::gm;
178 return {.name = "MuonShield",
179 .node = "/SHiP/muon_shield",
180 .id = 2,
181 .x_mm = 0.0,
182 .y_mm = 0.0,
183 .z_mm = gm(s_centreZ),
184 .isWorld = false};
185 }
186
187 private:
188 Materials& m_materials;
189};
190
191} // namespace SHiP::geometry
MuonShieldFactory(Materials &materials)
Definition MuonShieldFactory.cpp:145
Central material manager for the SHiP detector.
Definition Materials.h:22
static constexpr auto s_areaHalfY
Definition MuonShieldFactory.h:126
static constexpr SubsystemDescriptor descriptor()
This subsystem's self-description (name, node, id, placement).
Definition MuonShieldFactory.h:176
static constexpr auto s_centreZ
Definition MuonShieldFactory.h:129
static constexpr auto s_zEnd
Definition MuonShieldFactory.h:123
GeoPhysVol * build()
Definition MuonShieldFactory.cpp:147
MuonShieldFactory(Materials &materials)
Definition MuonShieldFactory.cpp:145
static constexpr auto s_zStart
The container spans the shield exactly: the hadron stopper's upstream face to M7's downstream face,...
Definition MuonShieldFactory.h:122
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
MuonShieldMagnet MagnetData
Definition MuonShieldFactory.h:58
static constexpr bool hasSndCavity(const MagnetData &magnet)
Some of the SND cavity lies in this magnet, so it is cut out.
Definition MuonShieldFactory.h:165
static constexpr auto s_areaHalfX
Definition MuonShieldFactory.h:124
static constexpr bool cuts(const CavitySection &section, const MagnetData &magnet)
The cavity section overlaps the magnet's iron along z.
Definition MuonShieldFactory.h:159
static constexpr std::array< MagnetData, 7 > k_magnets
Rows 1-7: the shield magnets M1-M7.
Definition MuonShieldFactory.h:74
Factory for the Scattering and Neutrino Detector (SND).
Definition NeutrinoDetectorFactory.h:54
mp_units::quantity< mm > LengthMm
Spellings for struct members and function parameters.
Definition Units.h:39
constexpr double gm(mp_units::quantity< U, Rep > q)
Length quantity -> GeoModel raw double (GeoModel native unit: mm).
Definition Units.h:47
constexpr auto mm
Definition Units.h:27
Definition DetectorBuilder.h:8
constexpr double gm(mp_units::quantity< U, Rep > q)
Length quantity -> GeoModel raw double (GeoModel native unit: mm).
Definition Units.h:47
One step of the SND cavity, in the world frame: a box on the beam axis from zStart to zEnd.
Definition MuonShieldFactory.h:133
One step of the SND cavity, in the world frame: a box on the beam axis from zStart to zEnd.
Definition MuonShieldFactory.h:133
units::LengthMm halfX
Definition MuonShieldFactory.h:135
units::LengthMm zStart
Definition MuonShieldFactory.h:134
units::LengthMm zEnd
Definition MuonShieldFactory.h:134
units::LengthMm halfY
Definition MuonShieldFactory.h:135
One muon-shield magnet: a solid iron box on the beam axis, from its upstream face in the world frame.
Definition MuonShieldFactory.h:23
units::LengthMm halfY
Definition MuonShieldFactory.h:26
units::LengthMm zStart
Definition MuonShieldFactory.h:25
units::LengthMm halfX
Definition MuonShieldFactory.h:26
constexpr units::LengthMm zEnd() const
Definition MuonShieldFactory.h:28
const char * name
Definition MuonShieldFactory.h:24
units::LengthMm halfZ
Definition MuonShieldFactory.h:26
constexpr units::LengthMm zCentre() const
Definition MuonShieldFactory.h:29
A subsystem's self-description: everything the assembler needs.
Definition SubsystemDescriptor.h:20