ATLAS Offline Software
Loading...
Searching...
No Matches
python.ISF_Skeleton Namespace Reference

Functions

 fromRunArgs (runArgs)

Variables

 jobPropertiesDisallowed

Function Documentation

◆ fromRunArgs()

python.ISF_Skeleton.fromRunArgs ( runArgs)

Definition at line 13 of file ISF_Skeleton.py.

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

Variable Documentation

◆ jobPropertiesDisallowed

python.ISF_Skeleton.jobPropertiesDisallowed

Definition at line 10 of file ISF_Skeleton.py.