133):
134 """
135 Create geometry configuration with specified parameters.
136
137 Args:
138 DecayVolumeMedium: Medium in decay volume ("helium" or "vacuums"), default: "helium"
139 Yheight: Height of vacuum tank in meters, default: 6.0
140 strawDesign: Straw tube design (4=Aluminium frame, 10=steel frame), default: 10
141 shieldName: Name of shield configuration, default: "TRY_2026"
142 nuTargetPassive: Target type (0=with active layers, 1=only passive), default: 1
143 SND: Enable SND detector, default: True
144 SND_design: SND design options (list of design numbers), default: [2]
145 TARGET_YAML: Path to target YAML configuration file, default: "$FAIRSHIP/geometry/target_config.yaml"
146
147 Returns:
148 Config: Geometry configuration object
149 """
150
151 if SND_design is None:
152 SND_design = [2]
153 if TARGET_YAML is None:
154 TARGET_YAML = os.path.expandvars("$FAIRSHIP/geometry/target_config.yaml")
155
156
157 c = Config()
158 c.DecayVolumeMedium = DecayVolumeMedium
159 c.SND = SND
160
161 if not isinstance(SND_design, list):
162 SND_design = [SND_design]
163 c.SND_design = SND_design
164 c.target_yaml = TARGET_YAML
165 print("Info: Target using configuration:", c.target_yaml)
166
167 if not shieldName:
168 raise ValueError("shieldName must not be empty!")
169
170 c.shieldName = shieldName
171
172
173 c.Yheight = Yheight * u.m
174 extraVesselLength = 10 * u.m
175 windowBulge = 25 * u.cm
176 c.strawDesign = strawDesign
177 c.magnetDesign = 4
178
179 c.cave = AttrDict()
180 c.cave.floorHeightMuonShield = 5 * u.m
181 c.cave.floorHeightTankA = 4.2 * u.m
182 if strawDesign == 10:
183 c.cave.floorHeightMuonShield = c.cave.floorHeightTankA
184 c.cave.floorHeightTankB = 2 * u.m
185
186 c.cave.TCC8_length = 170 * u.m
187 c.cave.ECN3_length = 100.81 * u.m
188 c.cave.stair_step_length = 0.82 * u.m
189
190
191 c.cave.z_transition = 21.37 * u.m
192 c.cave.zEnd = c.cave.z_transition + c.cave.ECN3_length
193 set_ecn3_cavern(c)
194
195 with open(c.target_yaml) as file:
196 targetconfig = yaml.safe_load(file)
197 c.target = AttrDict(targetconfig["target"])
198 if "version" not in c.target:
199 c.target.version = 1
200
201 c.target.slices_length = []
202 c.target.slices_gap = []
203 c.target.slices_material = []
204
205 for i in range(c.target.Nplates):
206 for j in range(c.target.N[i]):
207 if len(c.target.L) == 1:
208 c.target.slices_length.append(c.target.L[0])
209 else:
210 c.target.slices_length.append(c.target.L[i])
211 if len(c.target.G) == 1:
212 c.target.slices_gap.append(c.target.G[0])
213 else:
214 c.target.slices_gap.append(c.target.G[i])
215 if len(c.target.M) == 1:
216 c.target.slices_material.append(c.target.M[0])
217 else:
218 c.target.slices_material.append(c.target.M[i])
219
220 c.target.slices_gap[c.target.nS - 1] = 0
221 print(c.target.slices_material, c.target.slices_length, c.target.slices_gap)
222
223 target_length = 0
224 for width, gap in zip(c.target.slices_length, c.target.slices_gap):
225 target_length += width + gap
226 c.target.length = target_length
227
228
229 c.target.z0 = 0
230 c.target.z = c.target.z0 + c.target.length / 2.0
231
232 c.hadronAbsorber = AttrDict()
233
234
235
236
237
238
239 c.target.length_fixed = 158.64 * u.cm
240
241 c.hadronAbsorber.z = (
242 c.target.z0
243 + c.target.length_fixed
244 + 96.1 * u.mm
245 + 250 * u.mm
246 + 207.5 * u.mm
247 )
248
249
250 c.muShield = AttrDict()
251
252 c.muShield.z = c.hadronAbsorber.z
253
254 params = shield_db[shieldName]["params"]
255 c.muShield.params = params
256
257
258 c.muShield.length = sum(line[0] + line[1] * 2 for line in params)
259 c.muShield.nMagnets = len(params)
260
261 c.muShield.Zgap = []
262 c.muShield.half_length = []
263 c.muShield.Entrance = []
264
265 for line in params:
266 c.muShield.Zgap.append(line[0])
267 c.muShield.half_length.append(line[1])
268
269
270 for i in range(len(c.muShield.Zgap)):
271 if i == 0:
272
273 c.muShield.Entrance.append(c.muShield.z + c.muShield.Zgap[i])
274 else:
275
276 c.muShield.Entrance.append(
277 c.muShield.Entrance[i - 1] + c.muShield.half_length[i - 1] * 2 + c.muShield.Zgap[i]
278 )
279
280 c.muShield.params = [item for sublist in params for item in sublist]
281
282 c.decayVolume = AttrDict()
283
284
285 c.decayVolume.length = 50 * u.m
286
287
288
289 c.z = 89.72 * u.m
290 c.decayVolume.z = c.z - 31.450 * u.m
291 c.decayVolume.z0 = c.decayVolume.z - c.decayVolume.length / 2.0
292 veto_yaml = os.path.expandvars(f"$FAIRSHIP/geometry/veto_config_{DecayVolumeMedium}.yaml")
293 with open(veto_yaml) as f:
294 veto_config = yaml.safe_load(f)
295 c.decayVolume.xEndInner = veto_config["xendInner"] * u.cm
296 c.decayVolume.yEndInner = veto_config["yendInner"] * u.cm
297
298 c.chambers = AttrDict()
299 magnetIncrease = 100.0 * u.cm
300
301 if strawDesign != 4 and strawDesign != 10:
302 raise ValueError(f"straw design {strawDesign} is not supported, use strawDesign = 4 or 10")
303 else:
304 c.chambers.Tub1length = 2.5 * u.m
305 c.chambers.Tub2length = 17.68 * u.m + extraVesselLength / 2.0
306 c.chambers.Tub3length = 0.8 * u.m
307 c.chambers.Tub4length = 2.0 * u.m + magnetIncrease / 2.0
308 c.chambers.Tub5length = 0.8 * u.m
309 c.chambers.Tub6length = 0.1 * u.m + windowBulge / 2.0
310 c.chambers.Rmin = 245.0 * u.cm
311 c.chambers.Rmax = 250.0 * u.cm
312
313 c.xMax = 2 * u.m
314 TrGap = 2 * u.m
315 TrMagGap = 3.5 * u.m
316
317 z4 = c.z + TrMagGap + TrGap
318 c.TrackStation4 = AttrDict(z=z4)
319 z3 = c.z + TrMagGap
320 c.TrackStation3 = AttrDict(z=z3)
321 z2 = c.z - TrMagGap
322 c.TrackStation2 = AttrDict(z=z2)
323 z1 = c.z - TrMagGap - TrGap
324 c.TrackStation1 = AttrDict(z=z1)
325
326
327
328 c.Chamber1 = AttrDict(z=c.decayVolume.z0 + c.chambers.Tub1length)
329 c.Chamber6 = AttrDict(z=z4 + 30.0 * u.cm + windowBulge / 2.0)
330
331 c.Bfield = AttrDict()
332 c.Bfield.z = c.z
333 c.Bfield.max = 0
334 c.Bfield.y = c.Yheight
335 c.Bfield.x = 2.4 * u.m
336 c.Bfield.fieldMap = "files/2026_07_02_MainSpectrometerField_V21_2455.root"
337 if c.magnetDesign > 3:
338 c.Bfield.YokeWidth = 0.8 * u.m
339 c.Bfield.YokeDepth = 1.4 * u.m
340 c.Bfield.CoilThick = 25.0 * u.cm
341 c.Bfield.x = 2.2 * u.m
342 c.Bfield.y = 3.5 * u.m
343
344
345 c.TimeDet = AttrDict()
346 c.TimeDet.dzBarRow = 1.2 * u.cm
347 c.TimeDet.dzBarCol = 9.0 * u.cm
348 c.TimeDet.zBar = 1 * u.cm
349 c.TimeDet.DZ = (c.TimeDet.dzBarRow + c.TimeDet.dzBarCol + c.TimeDet.zBar) / 2
350 c.TimeDet.DX = 275 * u.cm
351 c.TimeDet.DY = 325 * u.cm
352
353
354 c.TimeDet.z = 37.870 * u.m + c.decayVolume.z + c.TimeDet.zBar / 2
355
356
357
358 c.CaloScoringPlane = AttrDict()
359 c.CaloScoringPlane.DX = 4 * u.m
360 c.CaloScoringPlane.DY = 6 * u.m
361 c.CaloScoringPlane.DZ = 1 * u.mm
362
363
364 c.CaloScoringPlane.PositionResolution = 0.0 * u.cm
365 c.CaloScoringPlane.TimeResolution = 0.0
366 c.CaloScoringPlane.ForwardOnly = True
367 c.CaloScoringPlane.IgnoredPdg = [12, 14, 16]
368
369
370 c.CaloScoringPlane.z = 38.900 * u.m + c.decayVolume.z + c.CaloScoringPlane.DZ / 2
371 if c.CaloScoringPlane.z + c.CaloScoringPlane.DZ / 2 >= c.cave.zEnd:
372 raise ValueError(
373 f"CaloScoringPlane ends at z = {c.CaloScoringPlane.z + c.CaloScoringPlane.DZ / 2} cm, "
374 f"beyond the downstream ECN3 wall at {c.cave.zEnd} cm"
375 )
376
377
378 c.strawtubesDigi = AttrDict()
379 c.strawtubesDigi.v_drift = 1.0 / (30 * u.ns / u.mm)
380 c.strawtubesDigi.sigma_spatial = 0.012 * u.cm
381
382
383 c.tauMudet = AttrDict()
384 c.tauMudet.Ztot = 3 * u.m
385 c.tauMudet.zMudetC = c.muShield.z + c.muShield.length / 2.0 - c.tauMudet.Ztot / 2.0 - 70 * u.cm
386
387 set_upstream_tagger(c)
388
389
390 c.nuTargetPassive = nuTargetPassive
391
392 return c