SHiP Geometry
SHiP experiment geometry implementation using GeoModel.
Loading...
Searching...
No Matches
CalorimeterConstants.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 <array>
9#include <numbers>
10#include <span>
11
19
31
32// ── Module geometry (mm) ────────────────────────────────────────────────
33inline constexpr auto kPlateXY = 2160.0 * units::mm;
34inline constexpr auto kLeadThickness = 3.0 * units::mm;
35inline constexpr auto kScintThickness = 10.0 * units::mm;
36inline constexpr auto kHplThickness = 10.0 * units::mm;
37inline constexpr auto kFiberDiameter = 1.2 * units::mm;
38inline constexpr auto kFiberCoreDiameter = 1.0 * units::mm;
39inline constexpr auto kIronThickness = 170.0 * units::mm;
40
42inline constexpr auto kAirGap = 1000.0 * units::mm;
44inline constexpr auto kGapEcalHcal = 100.0 * units::mm;
45
46// Bar pitch (physical constant, independent of plate size)
47inline constexpr auto kWidePVTBarPitch = 60.0 * units::mm;
48inline constexpr auto kThinPSBarPitch = 10.0 * units::mm;
49
50// Module tiling: modules touch (pitch = plate size)
51inline constexpr int kModuleNX = 2;
52inline constexpr int kModuleNY = 3;
53inline constexpr auto kModulePitchX = kPlateXY;
54inline constexpr auto kModulePitchY = kPlateXY;
55
56// ── Layer sequences ─────────────────────────────────────────────────────
57//
58// The `using enum` is confined to each initialiser: at namespace scope in a
59// public header it would make Absorber, AirGap, WidePVT_H ... visible
60// unqualified throughout SHiP::geometry::calo for every includer, which is most
61// of what enum class is for.
62
86
88inline constexpr auto kHcalLayers = [] {
89 using enum LayerCode;
90 return std::array{
93 };
94}();
95
96// ── Fixed container envelope ────────────────────────────────────────────
97// These match the SHiP subsystem envelope from subsystem_envelopes.csv
98// and must not change — tests and the consistency check depend on them.
99inline constexpr auto kContainerHalfX = 3000.0 * units::mm; // 3.00 m
100inline constexpr auto kContainerHalfY = 3500.0 * units::mm; // 3.50 m
101inline constexpr auto kContainerHalfZ = 1450.0 * units::mm; // 1.45 m
102
103// ── Derived quantities ──────────────────────────────────────────────────
104
107constexpr units::LengthMm layerThickness(LayerCode code, units::LengthMm absorberThickness) {
108 using enum LayerCode;
109 switch (code) {
110 case Absorber:
111 return absorberThickness;
112 case WidePVT_H:
113 case WidePVT_V:
114 case ThinPS_H:
115 case ThinPS_V:
116 return kScintThickness;
117 case FibreHPL_Y:
118 case FibreHPL_X:
119 return kHplThickness;
120 case AirGap:
121 return kAirGap;
122 }
123 return 0.0 * units::mm; // unreachable: all enumerators covered (-Wswitch)
124}
125
127constexpr units::LengthMm sectionZ(std::span<const LayerCode> codes,
128 units::LengthMm absorberThickness) {
129 auto z = 0.0 * units::mm;
130 for (const LayerCode code : codes) {
131 z += layerThickness(code, absorberThickness);
132 }
133 return z;
134}
135
137inline constexpr auto kTotalStackZ =
139
144constexpr int sectionVolumeCount(std::span<const LayerCode> codes) {
145 using enum LayerCode;
146 int n = 0;
147 for (const LayerCode code : codes) {
148 n += code == AirGap ? 0 : 1;
149 }
150 return n;
151}
152
154inline constexpr int kVolsPerModule =
156
158inline constexpr int kWidePVTBarCount = static_cast<int>(units::ratio(kPlateXY / kWidePVTBarPitch));
159inline constexpr int kThinPSBarCount = static_cast<int>(units::ratio(kPlateXY / kThinPSBarPitch));
160
161// ── HPL fibre layout ────────────────────────────────────────────────────
162//
163// Three hexagonally close-packed rows of touching fibres (pitch = one fibre
164// diameter), centred in the casing:
165//
166// sublayer 0: n_mid - 1 fibres, z = -r√3
167// sublayer 1: n_mid fibres, z = 0 (n_mid = floor(casingXY / pitch))
168// sublayer 2: n_mid - 1 fibres, z = +r√3
169//
170// Every row is centred on 0 across the layer, so the outer rows sit half a
171// pitch off the middle row and each middle fibre nests between two outer
172// ones. The calorimeter digitiser relies on these exact centres.
173
175inline constexpr int kHplSublayers = 3;
176
179 return fibreDiameter * (1.0 + std::numbers::sqrt3);
180}
181
183constexpr int fibresPerSublayer(int sublayer, units::LengthMm casingXY = kPlateXY,
184 units::LengthMm fibreDiameter = kFiberDiameter) {
185 // The tolerance keeps a ratio that should be whole, but comes out a few
186 // ulp below it, from losing a fibre to truncation.
187 constexpr double kTolerance = 1e-9;
188 const int nMid = static_cast<int>(units::ratio(casingXY / fibreDiameter) + kTolerance);
189 return sublayer == 1 ? nMid : nMid - 1;
190}
191
196
198constexpr FibreCentre fibreCentre(int sublayer, int index, units::LengthMm casingXY = kPlateXY,
199 units::LengthMm fibreDiameter = kFiberDiameter) {
200 const int n = fibresPerSublayer(sublayer, casingXY, fibreDiameter);
201 const auto dz = 0.5 * fibreDiameter * std::numbers::sqrt3;
202 return {.across = (index - 0.5 * (n - 1)) * fibreDiameter, .z = (sublayer - 1) * dz};
203}
204
206inline constexpr int kFibresPerHpl = [] {
207 int n = 0;
208 for (int s = 0; s < kHplSublayers; ++s) {
209 n += fibresPerSublayer(s);
210 }
211 return n;
212}();
213
214// ── Compile-time validation ──────────────────────────────────────────────
215static_assert(!kEcalLayers.empty() && !kHcalLayers.empty());
216static_assert(kEcalLayers.size() == 89, "transcription guard: 89 entries in the ECAL sequence");
217static_assert(kModuleNX > 0 && kModuleNY > 0);
220 "plate size must be a whole number of wide PVT bars");
221static_assert(kThinPSBarCount * kThinPSBarPitch == kPlateXY,
222 "plate size must be a whole number of thin PS bars");
223static_assert(hplMinCasingZ() <= kHplThickness,
224 "close-packed HPL fibre stack exceeds the casing thickness");
225static_assert(fibresPerSublayer(1) * kFiberDiameter <= kPlateXY,
226 "middle HPL fibre row exceeds the casing");
227static_assert(fibresPerSublayer(0) == fibresPerSublayer(1) - 1 &&
229 "outer HPL fibre rows hold one fibre fewer than the middle row");
230static_assert(kFibresPerHpl == 5398, "transcription guard: 1799 + 1800 + 1799 fibres per HPL");
231static_assert(kTotalStackZ == 2600.0 * units::mm,
232 "transcription guard: 40 lead + 40 scint + 8 HPL + 1 air gap in the ECAL "
233 "(1600 mm), 100 mm gap, 5 iron + 5 scint in the HCAL (900 mm)");
234static_assert(kTotalStackZ <= 2.0 * kContainerHalfZ, "layer stack exceeds the container in Z");
235static_assert(0.5 * kPlateXY + 0.5 * (kModuleNX - 1) * kModulePitchX <= kContainerHalfX,
236 "module array exceeds the container in X");
237static_assert(0.5 * kPlateXY + 0.5 * (kModuleNY - 1) * kModulePitchY <= kContainerHalfY,
238 "module array exceeds the container in Y");
239
240} // namespace SHiP::geometry::calo
Compile-time parameters of the SHiP calorimeter geometry.
Definition CalorimeterConstants.h:18
constexpr auto kModulePitchY
Definition CalorimeterConstants.h:54
constexpr auto kAirGap
Air gap within the ECAL layer sequence (mm).
Definition CalorimeterConstants.h:42
constexpr units::LengthMm sectionZ(std::span< const LayerCode > codes, units::LengthMm absorberThickness)
Z extent of one calorimeter section.
Definition CalorimeterConstants.h:127
constexpr int kThinPSBarCount
Definition CalorimeterConstants.h:159
LayerCode
Layer types used in the ECAL/HCAL layer sequences.
Definition CalorimeterConstants.h:21
@ FibreHPL_X
HPL fibre layer, fibres along X.
Definition CalorimeterConstants.h:27
@ ThinPS_H
Thin PS bar layer, bars along X (H orientation).
Definition CalorimeterConstants.h:24
@ WidePVT_V
Wide PVT bar layer, bars along Y (V orientation).
Definition CalorimeterConstants.h:23
@ WidePVT_H
Wide PVT bar layer, bars along X (H orientation).
Definition CalorimeterConstants.h:22
@ Absorber
Absorber plate (Lead in ECAL, Iron in HCAL).
Definition CalorimeterConstants.h:28
@ FibreHPL_Y
HPL fibre layer, fibres along Y.
Definition CalorimeterConstants.h:26
@ ThinPS_V
Thin PS bar layer, bars along Y (V orientation).
Definition CalorimeterConstants.h:25
@ AirGap
Air gap (no volume, just advances z cursor).
Definition CalorimeterConstants.h:29
constexpr auto kFiberCoreDiameter
Definition CalorimeterConstants.h:38
constexpr auto kFiberDiameter
Definition CalorimeterConstants.h:37
constexpr auto kHplThickness
Definition CalorimeterConstants.h:36
constexpr auto kContainerHalfZ
Definition CalorimeterConstants.h:101
constexpr int kFibresPerHpl
Fibres in one HPL layer, summed over its sublayers.
Definition CalorimeterConstants.h:206
constexpr auto kModulePitchX
Definition CalorimeterConstants.h:53
constexpr int kModuleNX
Definition CalorimeterConstants.h:51
constexpr auto kContainerHalfY
Definition CalorimeterConstants.h:100
constexpr auto kWidePVTBarPitch
Definition CalorimeterConstants.h:47
constexpr int fibresPerSublayer(int sublayer, units::LengthMm casingXY=kPlateXY, units::LengthMm fibreDiameter=kFiberDiameter)
Fibres in sublayer sublayer (0 … kHplSublayers - 1).
Definition CalorimeterConstants.h:183
constexpr auto kTotalStackZ
Total Z extent of one ECAL+gap+HCAL stack.
Definition CalorimeterConstants.h:137
constexpr units::LengthMm layerThickness(LayerCode code, units::LengthMm absorberThickness)
Z advance of one layer of the given type.
Definition CalorimeterConstants.h:107
constexpr auto kContainerHalfX
Definition CalorimeterConstants.h:99
constexpr auto kPlateXY
Definition CalorimeterConstants.h:33
constexpr int kHplSublayers
Number of fibre sublayers (rows) in one HPL layer.
Definition CalorimeterConstants.h:175
constexpr auto kThinPSBarPitch
Definition CalorimeterConstants.h:48
constexpr int sectionVolumeCount(std::span< const LayerCode > codes)
Child volumes one section contributes to the container, per module.
Definition CalorimeterConstants.h:144
constexpr auto kIronThickness
Definition CalorimeterConstants.h:39
constexpr int kModuleNY
Definition CalorimeterConstants.h:52
constexpr FibreCentre fibreCentre(int sublayer, int index, units::LengthMm casingXY=kPlateXY, units::LengthMm fibreDiameter=kFiberDiameter)
Centre of fibre index in sublayer sublayer, in the casing frame.
Definition CalorimeterConstants.h:198
constexpr auto kScintThickness
Definition CalorimeterConstants.h:35
constexpr auto kEcalLayers
ECAL layer sequence.
Definition CalorimeterConstants.h:64
constexpr auto kHcalLayers
HCAL layer sequence (Absorber means iron here rather than lead).
Definition CalorimeterConstants.h:88
constexpr int kWidePVTBarCount
Bars per layer, from the plate size and the bar pitch.
Definition CalorimeterConstants.h:158
constexpr auto kGapEcalHcal
Gap between the ECAL and HCAL stacks (mm).
Definition CalorimeterConstants.h:44
constexpr units::LengthMm hplMinCasingZ(units::LengthMm fibreDiameter=kFiberDiameter)
Smallest casing thickness that holds the close-packed stack: 2r(1 + √3).
Definition CalorimeterConstants.h:178
constexpr int kVolsPerModule
Child volumes one module contributes to the container.
Definition CalorimeterConstants.h:154
constexpr auto kLeadThickness
Definition CalorimeterConstants.h:34
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
Definition CalorimeterConstants.h:192
units::LengthMm z
through the casing, relative to its midplane
Definition CalorimeterConstants.h:194
units::LengthMm across
across the fibres, in the casing plane (X or Y)
Definition CalorimeterConstants.h:193