265def configure(run, ship_geo):
266
267 if not hasattr(ship_geo, "DecayVolumeMedium"):
268 raise ValueError("DecayVolumeMedium is not defined, possibly old (incompatible) geometry!")
269 if not hasattr(ship_geo, "muShieldGeo"):
270 ship_geo.muShieldGeo = None
271 if not hasattr(ship_geo.Bfield, "x"):
272 ship_geo.Bfield.x = 3.0 * u.m
273 if not hasattr(ship_geo, "cave"):
274 ship_geo.cave = AttrDict(z=0 * u.cm)
275 ship_geo.cave.floorHeightMuonShield = 5 * u.m
276 ship_geo.cave.floorHeightTankA = 4.5 * u.m
277 ship_geo.cave.floorHeightTankB = 2.0 * u.m
278 if not hasattr(ship_geo, "SND"):
279 ship_geo.SND = True
280
281
282 run.SetMaterials("media.geo")
283
284
285
286 cave = ROOT.ShipCave(ship_geo.muShield.z)
287 cave.SetGeometryFileName("caveWithAir.geo")
288 detectorList.append(cave)
289
290 TargetStation = ROOT.ShipTargetStation(
291 "TargetStation",
292 ship_geo.target.length,
293 ship_geo.target.z,
294 ship_geo.target.nS,
295 ship_geo.target.HeT,
296 )
297
298 TargetStation.SetLayerPosMat(
299 ship_geo.target.xy, ship_geo.target.slices_length, ship_geo.target.slices_gap, ship_geo.target.slices_material
300 )
301 detectorList.append(TargetStation)
302
303
304 if ship_geo.SND:
305 for design in ship_geo.SND_design:
306 if design == 2:
307
308 configure_snd_mtc(os.path.join(os.environ["FAIRSHIP"], "geometry", "MTC_config.yaml"), ship_geo)
309 configure_snd_siliconTarget(
310 os.path.join(os.environ["FAIRSHIP"], "geometry", "SiliconTarget_config.yaml"), ship_geo
311 )
312 elif design == 1:
313 configure_snd_old(
314 os.path.join(os.environ["FAIRSHIP"], "geometry", "snd_config_old.yaml"),
315 ship_geo.UpstreamTagger.Z_Position
316 - 8 * u.cm
317 - 5 * u.cm,
318 ship_geo.cave.floorHeightMuonShield,
319 )
320 else:
321 print(f"Warning: SND design {design} is not recognized.")
322
323 in_params = list(ship_geo.muShield.params)
324
325 MuonShield = ROOT.ShipMuonShield(
326 in_params,
327 ship_geo.muShield.z,
328 ship_geo.muShield.WithConstField,
329 ship_geo.SC_mag,
330 )
331
332 if ship_geo.SND:
333
334 if 2 in getattr(ship_geo, "SND_design", []):
335 MuonShield.SetSNDSpace(
336 hole=True,
337 hole_dx=(ship_geo.mtc_geo.width + 5.0 * u.cm) / 2.0,
338 hole_dy=(ship_geo.mtc_geo.height + 5.0 * u.cm) / 2.0,
339 )
340 detectorList.append(MuonShield)
341
342 if not hasattr(ship_geo, "magnetDesign"):
343
344 ship_geo.magnetDesign = 4
345 ship_geo.Bfield.YokeWidth = 200.0 * u.cm
346 ship_geo.Bfield.YokeDepth = 200.0 * u.cm
347 ship_geo.Bfield.CoilThick = 25.0 * u.cm
348 if ship_geo.strawDesign > 1:
349 if ship_geo.magnetDesign > 3:
350 B = ship_geo.Bfield
351 magnet = ROOT.ShipMagnet(
352 "Magnet",
353 "SHiP Magnet",
354 B.z,
355 ship_geo.magnetDesign,
356 B.x,
357 B.y,
358 ship_geo.cave.floorHeightTankB,
359 B.YokeWidth,
360 B.YokeDepth,
361 B.CoilThick,
362 )
363
364 else:
365 magnet = ROOT.ShipMagnet(
366 "Magnet",
367 "SHiP Magnet",
368 ship_geo.Bfield.z,
369 ship_geo.magnetDesign,
370 ship_geo.Bfield.x,
371 ship_geo.Bfield.y,
372 ship_geo.cave.floorHeightTankB,
373 )
374 else:
375 magnet = ROOT.ShipMagnet("Magnet", "SHiP Magnet", ship_geo.Bfield.z)
376 detectorList.append(magnet)
377
378 fairship = os.environ["FAIRSHIP"]
379
380 configure_veto(
381 os.path.join(fairship, f"geometry/veto_config_{ship_geo.DecayVolumeMedium}.yaml"),
382 ship_geo.decayVolume.z0,
383 )
384
385 configure_strawtubes(
386 os.path.join(os.environ["FAIRSHIP"], "geometry", "strawtubes_config.yaml"),
387 ship_geo,
388 )
389
390 if ship_geo.EcalOption == 2:
391 SplitCal = ROOT.splitcal("SplitCal", ROOT.kTRUE)
392 x = ship_geo.SplitCal
393 SplitCal.SetThickness(
394 x.ActiveECALThickness,
395 x.ActiveHCALThickness,
396 x.FilterECALThickness,
397 x.FilterECALThickness_first,
398 x.FilterHCALThickness,
399 x.ActiveECAL_gas_Thickness,
400 )
401 SplitCal.SetMaterial(
402 x.ActiveECALMaterial,
403 x.ActiveHCALMaterial,
404 x.FilterECALMaterial,
405 x.FilterHCALMaterial,
406 )
407 SplitCal.SetNSamplings(x.nECALSamplings, x.nHCALSamplings, x.ActiveHCAL)
408 SplitCal.SetZStart(x.ZStart)
409 SplitCal.SetXMax(x.XMax)
410 SplitCal.SetYMax(x.YMax)
411 SplitCal.SetEmpty(
412 x.Empty,
413 x.BigGap,
414 x.ActiveECAL_gas_gap,
415 x.first_precision_layer,
416 x.second_precision_layer,
417 x.third_precision_layer,
418 x.num_precision_layers,
419 )
420 SplitCal.SetNModules(x.NModulesInX, x.NModulesInY)
421 SplitCal.SetNStrips(x.NStripsPerModule)
422 SplitCal.SetStripSize(x.StripHalfWidth, x.StripHalfLength)
423 detectorList.append(SplitCal)
424
425 upstreamTagger = ROOT.UpstreamTagger("UpstreamTagger", ROOT.kTRUE)
426 upstreamTagger.SetZposition(ship_geo.UpstreamTagger.Z_Position)
427 upstreamTagger.SetBoxDimensions(
428 ship_geo.UpstreamTagger.BoxX, ship_geo.UpstreamTagger.BoxY, ship_geo.UpstreamTagger.BoxZ
429 )
430 detectorList.append(upstreamTagger)
431
432 timeDet = ROOT.TimeDet("TimeDet", ROOT.kTRUE)
433 timeDet.SetZposition(ship_geo.TimeDet.z)
434 timeDet.SetBarZspacing(ship_geo.TimeDet.dzBarRow, ship_geo.TimeDet.dzBarCol)
435 timeDet.SetBarZ(ship_geo.TimeDet.zBar)
436 timeDet.SetSizeX(2 * ship_geo.TimeDet.DX)
437 timeDet.SetSizeY(2 * ship_geo.TimeDet.DY)
438 detectorList.append(timeDet)
439
440
441 if not hasattr(ship_geo.Bfield, "fieldMap"):
442 if ship_geo.strawDesign == 4 or ship_geo.strawDesign == 10:
443 fMagField = ROOT.ShipBellField(
444 "wilfried",
445 ship_geo.Bfield.max,
446 ship_geo.Bfield.z,
447 2,
448 ship_geo.Yheight / 2.0 * u.m,
449 )
450 else:
451 fMagField = ROOT.ShipBellField(
452 "wilfried",
453 ship_geo.Bfield.max,
454 ship_geo.Bfield.z,
455 1,
456 ship_geo.Yheight / 2.0 * u.m,
457 )
458 run.SetField(fMagField)
459
460 exclusionList = []
461
462
463
464 for x in detectorList:
465 if x.GetName() in exclusionList:
466 continue
467 run.AddModule(x)
468
469 detElements = {}
470 for x in run.GetListOfModules():
471 detElements[x.GetName()] = x
472 return detElements