14 from AthenaCommon.Logging
import logging
15 log = logging.getLogger(
'AtlasG4_tf')
16 log.info(
'****************** STARTING Simulation *****************')
18 log.info(
'**** Transformation run arguments')
19 log.info(
str(runArgs))
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
29 from AthenaConfiguration.Enums
import ProductionStep
30 flags.Common.ProductionStep = ProductionStep.Simulation
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")
39 flags.Sim.ISF.Simulator = SimulationFlavour.AtlasG4
42 flags.Sim.ISFRun =
False
45 from SimuJobTransforms.SimulationHelpers
import getDetectorsFromRunArgs
49 if hasattr(runArgs,
'beamType'):
50 if runArgs.beamType ==
'cosmics':
51 flags.Beam.Type = BeamType.Cosmics
52 flags.Sim.CavernBackground = CavernBackground.Off
60 if hasattr(runArgs,
'inputEVNTFile'):
61 flags.Input.Files = runArgs.inputEVNTFile
62 elif hasattr(runArgs,
'inputEVNT_TRFile'):
63 flags.Input.Files = runArgs.inputEVNT_TRFile
68 if flags.Beam.Type
is BeamType.Cosmics:
69 flags.Sim.ReadTR =
True
70 flags.Sim.CosmicFilterVolumeNames = [
'Muon']
71 detectors.add(
'Cavern')
72 elif hasattr(runArgs,
"trackRecordType")
and runArgs.trackRecordType==
"stopped":
73 flags.Sim.ReadTR =
True
74 log.error(
'Stopped Particle simulation is not supported yet')
76 detectors.add(
'Cavern')
77 flags.Sim.CavernBackground = CavernBackground.Read
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')
90 log.debug(
'No inputEVNTFile provided. OK, as performing cosmics simulation.')
92 if hasattr(runArgs,
'outputHITSFile'):
93 if runArgs.outputHITSFile ==
'None':
94 flags.Output.HITSFileName =
''
96 flags.Output.HITSFileName = runArgs.outputHITSFile
97 if hasattr(runArgs,
"outputEVNT_TRFile"):
102 flags.Output.EVNT_TRFileName = runArgs.outputEVNT_TRFile
103 if hasattr(runArgs,
"trackRecordType")
and runArgs.trackRecordType==
"stopped":
105 log.error(
'Stopped Particle simulation not supported yet!')
106 elif flags.Beam.Type
is BeamType.Cosmics:
111 detectors.add(
'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')
117 if hasattr(runArgs,
'conditionsTag'):
118 flags.IOVDb.GlobalTag = runArgs.conditionsTag
121 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorFlags
125 from PerfMonComps.PerfMonConfigHelpers
import setPerfmonFlagsFromRunArgs
138 from SimulationConfig.SimConfigFlags
import simulationRunArgsToFlags
159 from PyUtils.AMITagHelperConfig
import AMITagCfg
166 log.info(
"Run G4AtlasAlg in " +
str(time.time()-tic) +
" seconds")
168 sys.exit(
not sc.isSuccess())