ATLAS Offline Software
Functions | Variables
python.G4AtlasAlg_Skeleton Namespace Reference

Functions

def fromRunArgs (runArgs)
 

Variables

 jobPropertiesDisallowed
 

Function Documentation

◆ fromRunArgs()

def python.G4AtlasAlg_Skeleton.fromRunArgs (   runArgs)

Definition at line 13 of file G4AtlasAlg_Skeleton.py.

13 def fromRunArgs(runArgs):
14  from AthenaCommon.Logging import logging
15  log = logging.getLogger('AtlasG4_tf')
16  log.info('****************** STARTING Simulation *****************')
17 
18  log.info('**** Transformation run arguments')
19  log.info(str(runArgs))
20 
21  log.info('**** Setting-up configuration flags')
22  from AthenaConfiguration.AllConfigFlags import initConfigFlags
23  from AthenaConfiguration.Enums import BeamType
24  from SimulationConfig.SimEnums import CalibrationRun, CavernBackground, SimulationFlavour
25  flags = initConfigFlags()
26  commonRunArgsToFlags(runArgs, flags)
27 
28  # Set ProductionStep
29  from AthenaConfiguration.Enums import ProductionStep
30  flags.Common.ProductionStep = ProductionStep.Simulation
31 
32  # Set the simulator
33  if hasattr(runArgs, 'simulator'):
34  flags.Sim.ISF.Simulator = SimulationFlavour(runArgs.simulator)
35  allowedSimulators = [SimulationFlavour.AtlasG4, SimulationFlavour.AtlasG4_QS]
36  if flags.Sim.ISF.Simulator not in allowedSimulators:
37  raise RuntimeError("simulator argument not in allowed list of simulators")
38  else:
39  flags.Sim.ISF.Simulator = SimulationFlavour.AtlasG4
40 
41  # This is not ISF
42  flags.Sim.ISFRun = False
43 
44  # Generate detector list
45  from SimuJobTransforms.SimulationHelpers import getDetectorsFromRunArgs
46  detectors = getDetectorsFromRunArgs(flags, runArgs)
47 
48  # Beam Type
49  if hasattr(runArgs,'beamType'):
50  if runArgs.beamType == 'cosmics':
51  flags.Beam.Type = BeamType.Cosmics
52  flags.Sim.CavernBackground = CavernBackground.Off
53 
54  # Setup input: Three possible cases:
55  # 1) inputEVNTFile (normal)
56  # 2) inputEVNT_TRFile (TrackRecords from pre-simulated events,
57  # used with TrackRecordGenerator)
58  # 3) no input file (on-the-fly generation - typically ParticleGun
59  # or CosmicGenerator)
60  if hasattr(runArgs, 'inputEVNTFile'):
61  flags.Input.Files = runArgs.inputEVNTFile
62  elif hasattr(runArgs, 'inputEVNT_TRFile'):
63  flags.Input.Files = runArgs.inputEVNT_TRFile
64  # Three common cases here:
65  # 2a) Cosmics simulation
66  # 2b) Stopped particle simulation
67  # 2c) Cavern background simulation
68  if flags.Beam.Type is BeamType.Cosmics:
69  flags.Sim.ReadTR = True
70  flags.Sim.CosmicFilterVolumeNames = ['Muon']
71  detectors.add('Cavern') # simulate the cavern with a cosmic TR file
72  elif hasattr(runArgs,"trackRecordType") and runArgs.trackRecordType=="stopped":
73  flags.Sim.ReadTR = True
74  log.error('Stopped Particle simulation is not supported yet')
75  else:
76  detectors.add('Cavern') # simulate the cavern
77  flags.Sim.CavernBackground = CavernBackground.Read
78  else:
79  # Common cases
80  # 3a) ParticleGun
81  # 3b) CosmicGenerator
82  flags.Input.Files = []
83  flags.Input.isMC = True
84  log.info('No inputEVNTFile provided. Assuming that you are running a generator on the fly.')
85  if flags.Beam.Type is BeamType.Cosmics:
86  flags.Sim.CosmicFilterVolumeNames = [getattr(runArgs, "CosmicFilterVolume", "InnerDetector")]
87  flags.Sim.CosmicFilterVolumeNames += [getattr(runArgs, "CosmicFilterVolume2", "NONE")]
88  flags.Sim.CosmicPtSlice = getattr(runArgs, "CosmicPtSlice", 'NONE')
89  detectors.add('Cavern') # simulate the cavern when generating cosmics on-the-fly
90  log.debug('No inputEVNTFile provided. OK, as performing cosmics simulation.')
91 
92  if hasattr(runArgs, 'outputHITSFile'):
93  if runArgs.outputHITSFile == 'None':
94  flags.Output.HITSFileName = ''
95  else:
96  flags.Output.HITSFileName = runArgs.outputHITSFile
97  if hasattr(runArgs, "outputEVNT_TRFile"):
98  # Three common cases
99  # 1b) Write TrackRecords for Cavern background
100  # 1c) Write TrackRecords for Stopped particles
101  # 3b) CosmicGenerator
102  flags.Output.EVNT_TRFileName = runArgs.outputEVNT_TRFile
103  if hasattr(runArgs,"trackRecordType") and runArgs.trackRecordType=="stopped":
104  # Case 1c)
105  log.error('Stopped Particle simulation not supported yet!')
106  elif flags.Beam.Type is BeamType.Cosmics:
107  # Case 3b)
108  pass
109  else:
110  #Case 1b) Cavern Background
111  detectors.add('Cavern') # simulate the cavern
112  flags.Sim.CalibrationRun = CalibrationRun.Off
113  flags.Sim.CavernBackground = CavernBackground.Write
114  if not (hasattr(runArgs, 'outputHITSFile') or hasattr(runArgs, "outputEVNT_TRFile")):
115  log.warning('No outputHITSFile or outputEVNT_TRFile defined')
116 
117  if hasattr(runArgs, 'conditionsTag'):
118  flags.IOVDb.GlobalTag = runArgs.conditionsTag
119 
120  # Setup detector flags
121  from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
122  setupDetectorFlags(flags, detectors, toggle_geometry=True)
123 
124  # Setup perfmon flags from runargs
125  from PerfMonComps.PerfMonConfigHelpers import setPerfmonFlagsFromRunArgs
126  setPerfmonFlagsFromRunArgs(flags, runArgs)
127 
128  # Pre-include
129  processPreInclude(runArgs, flags)
130 
131  # Special Configuration preInclude
133 
134  # Pre-exec
135  processPreExec(runArgs, flags)
136 
137  # Common simulation runtime arguments
138  from SimulationConfig.SimConfigFlags import simulationRunArgsToFlags
139  simulationRunArgsToFlags(runArgs, flags)
140 
141  # To respect --athenaopts
142  flags.fillFromArgs()
143 
144  # Lock flags
145  flags.lock()
146 
147  cfg = CommonSimulationCfg(flags, log)
148 
149  # Special Configuration postInclude
150  specialConfigPostInclude(flags, cfg)
151 
152  # Post-include
153  processPostInclude(runArgs, flags, cfg)
154 
155  # Post-exec
156  processPostExec(runArgs, flags, cfg)
157 
158  # Write AMI tag into in-file metadata
159  from PyUtils.AMITagHelperConfig import AMITagCfg
160  cfg.merge(AMITagCfg(flags, runArgs))
161 
162  import time
163  tic = time.time()
164  # Run the final accumulator
165  sc = cfg.run()
166  log.info("Run G4AtlasAlg in " + str(time.time()-tic) + " seconds")
167 
168  sys.exit(not sc.isSuccess())

Variable Documentation

◆ jobPropertiesDisallowed

python.G4AtlasAlg_Skeleton.jobPropertiesDisallowed

Definition at line 10 of file G4AtlasAlg_Skeleton.py.

python.TransformUtils.processPreExec
def processPreExec(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:41
python.TransformUtils.processPostExec
def processPostExec(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:50
python.CommonSimulationSteering.CommonSimulationCfg
def CommonSimulationCfg(flags, log)
Definition: CommonSimulationSteering.py:35
python.TransformUtils.processPostInclude
def processPostInclude(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:69
python.TransformUtils.processPreInclude
def processPreInclude(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:62
python.CommonSimulationSteering.specialConfigPostInclude
def specialConfigPostInclude(flags, cfg)
Definition: CommonSimulationSteering.py:29
python.PerfMonConfigHelpers.setPerfmonFlagsFromRunArgs
def setPerfmonFlagsFromRunArgs(flags, runArgs)
Definition: PerfMonConfigHelpers.py:3
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:289
python.SimConfigFlags.simulationRunArgsToFlags
def simulationRunArgsToFlags(runArgs, flags)
Definition: SimConfigFlags.py:267
python.CommonSimulationSteering.specialConfigPreInclude
def specialConfigPreInclude(flags)
Definition: CommonSimulationSteering.py:23
python.AMITagHelperConfig.AMITagCfg
def AMITagCfg(flags, runArgs=None, fixBroken=False)
Definition: AMITagHelperConfig.py:77
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.SimulationHelpers.getDetectorsFromRunArgs
def getDetectorsFromRunArgs(flags, runArgs)
Definition: SimulationHelpers.py:5
python.G4AtlasAlg_Skeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: G4AtlasAlg_Skeleton.py:13