ATLAS Offline Software
SimulationHelpers.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 from SimulationConfig.SimEnums import CalibrationRun, CavernBackground, LArParameterization, SimulationFlavour
3 
4 
5 def getDetectorsFromRunArgs(flags, runArgs):
6  """Generate detector list based on runtime arguments."""
7  if hasattr(runArgs, 'detectors'):
8  detectors = set(runArgs.detectors)
9  else:
10  from AthenaConfiguration.AutoConfigFlags import getDefaultDetectors
11  detectors = set(getDefaultDetectors(flags.GeoModel.AtlasVersion, flags.GeoModel.SQLiteDB, flags.GeoModel.SQLiteDBFullPath, includeForward=False))
12 
13  # Support switching on Forward Detectors
14  if hasattr(runArgs, 'LucidOn'):
15  detectors.add('Lucid')
16  if hasattr(runArgs, 'ZDCOn'):
17  detectors.add('ZDC')
18  if hasattr(runArgs, 'AFPOn'):
19  detectors.add('AFP')
20  if hasattr(runArgs, 'ALFAOn'):
21  detectors.add('ALFA')
22  if hasattr(runArgs, 'FwdRegionOn'):
23  detectors.add('FwdRegion')
24  # TODO here support switching on Cavern geometry
25  # if hasattr(runArgs, 'CavernOn'):
26  # detectors.add('Cavern')
27 
28  # Fatras does not support simulating the BCM, so have to switch that off
29  if flags.Sim.ISF.Simulator.usesFatras():
30  try:
31  detectors.remove('BCM')
32  except ValueError:
33  pass
34 
35  return detectors
36 
37 
39  """Set flags to take care of Neutron BG"""
40  flags.Sim.CavernBackground = CavernBackground.Signal
41 
42 
43 def enableCalHits(flags):
44  """Turns on calibration hits for LAr and Tile"""
45  flags.Sim.CalibrationRun = CalibrationRun.LArTile
46  # deactivate incompatible optimizations
47  flags.Sim.LArParameterization = LArParameterization.NoFrozenShowers
48  flags.Sim.NRRThreshold = False
49  flags.Sim.NRRWeight = False
50  flags.Sim.PRRThreshold = False
51  flags.Sim.PRRWeight = False
52 
53 
54 def enableCalHitsZDC(flags):
55  """Turns on calibration hits for ZDC only"""
56  flags.Sim.CalibrationRun = CalibrationRun.ZDC
57  # deactivate incompatible optimizations
58  flags.Sim.LArParameterization = LArParameterization.NoFrozenShowers
59  flags.Sim.NRRThreshold = False
60  flags.Sim.NRRWeight = False
61  flags.Sim.PRRThreshold = False
62  flags.Sim.PRRWeight = False
63 
64 
65 def enableCalHitsAll(flags):
66  """Turns on calibration hits for LAr, Tile and ZDC"""
67  flags.Sim.CalibrationRun = CalibrationRun.LArTileZDC
68  # deactivate incompatible optimizations
69  flags.Sim.LArParameterization = LArParameterization.NoFrozenShowers
70  flags.Sim.NRRThreshold = False
71  flags.Sim.NRRWeight = False
72  flags.Sim.PRRThreshold = False
73  flags.Sim.PRRWeight = False
74 
75 
76 def enableParticleID(flags):
77  """Mods to have primary particle barcode signature on for calorimeter calibration hits."""
78  flags.Sim.ParticleID=True
79 
80 
82  """ """
83  flags.Sim.OptionalUserActionList += ['G4DebuggingTools.G4DebuggingToolsConfig.VerboseSelectorToolCfg']
84 
85 
86 def enableFastCaloSim(flags):
87  # Set LArParametrization to FastCaloSim
88  flags.Sim.LArParameterization = LArParameterization.FastCaloSim
89  # Deacticate dead material hits for calibration run
90  flags.Sim.CalibrationRun = CalibrationRun.Off
91  # Set simulator name as metadata
92  flags.Sim.ISF.Simulator = SimulationFlavour.ATLFAST3MT
93 
94 
95 def useVerboseTracking(flags):
96  # Use verbose G4 tracking
97  flags.Sim.G4Commands += ['/tracking/verbose 1']
98 
99 
100 
102  flags.Sim.G4Stepper = 'SimpleRunge'
103 
104 
106  flags.Sim.G4Stepper = 'ClassicalRK4'
107 
108 
110  flags.Sim.G4Stepper = 'NystromRK4'
111 
112 
114  """ """
115  flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.FastIDKillerToolCfg']
python.AutoConfigFlags.getDefaultDetectors
def getDefaultDetectors(geoTag, sqliteDB, sqliteDBFullPath, includeForward=False)
Definition: AutoConfigFlags.py:148
python.SimulationHelpers.useSimpleRungeStepper
def useSimpleRungeStepper(flags)
Change the field stepper.
Definition: SimulationHelpers.py:101
python.SimulationHelpers.enableCalHits
def enableCalHits(flags)
Definition: SimulationHelpers.py:43
python.SimulationHelpers.useVerboseTracking
def useVerboseTracking(flags)
Definition: SimulationHelpers.py:95
python.SimulationHelpers.enableCalHitsZDC
def enableCalHitsZDC(flags)
Definition: SimulationHelpers.py:54
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.SimulationHelpers.enableCalHitsAll
def enableCalHitsAll(flags)
Definition: SimulationHelpers.py:65
python.SimulationHelpers.useClassicalRK4Stepper
def useClassicalRK4Stepper(flags)
Definition: SimulationHelpers.py:105
python.SimulationHelpers.enableFastCaloSim
def enableFastCaloSim(flags)
Definition: SimulationHelpers.py:86
python.SimulationHelpers.useNystromRK4Stepper
def useNystromRK4Stepper(flags)
Definition: SimulationHelpers.py:109
python.SimulationHelpers.enableVerboseSelector
def enableVerboseSelector(flags)
Definition: SimulationHelpers.py:81
python.SimulationHelpers.enableParticleID
def enableParticleID(flags)
Definition: SimulationHelpers.py:76
python.SimulationHelpers.enableG4SignalCavern
def enableG4SignalCavern(flags)
Definition: SimulationHelpers.py:38
python.SimulationHelpers.getDetectorsFromRunArgs
def getDetectorsFromRunArgs(flags, runArgs)
Definition: SimulationHelpers.py:5
python.SimulationHelpers.enableFastIDKiller
def enableFastIDKiller(flags)
Definition: SimulationHelpers.py:113