3 from AthenaConfiguration.AthConfigFlags
import AthConfigFlags, isGaudiEnv
4 from AthenaConfiguration.AutoConfigFlags
import GetFileMD
5 from AthenaConfiguration.Enums
import BeamType, LHCPeriod
6 from SimulationConfig.SimEnums
import BeamPipeSimMode, CalibrationRun, CavernBackground, \
7 LArParameterization, SimulationFlavour, TruthStrategy, VertexSource
13 scf = AthConfigFlags()
14 scf.addFlag(
"Sim.ParticleID",
False)
16 def _checkCalibrationRun(prevFlags):
17 if prevFlags.Sim.ISF.Simulator
not in [SimulationFlavour.FullG4MT, SimulationFlavour.FullG4MT_QS, SimulationFlavour.PassBackG4MT, SimulationFlavour.AtlasG4, SimulationFlavour.AtlasG4_QS] \
18 or prevFlags.Sim.LArParameterization
is not LArParameterization.NoFrozenShowers:
19 return CalibrationRun.Off
20 return CalibrationRun.DeadLAr
22 scf.addFlag(
"Sim.CalibrationRun", _checkCalibrationRun, type=CalibrationRun)
24 scf.addFlag(
"Sim.CavernBackground", CavernBackground.Off, type=CavernBackground)
25 scf.addFlag(
"Sim.ReadTR",
False)
26 scf.addFlag(
"Sim.WorldRRange",
False)
27 scf.addFlag(
"Sim.WorldZRange",
False)
29 def _barcodeOffsetFromTruthStrategy(prevFlags):
30 if prevFlags.Sim.TruthStrategy
in [TruthStrategy.MC15, TruthStrategy.MC18, TruthStrategy.MC18LLP]:
34 def _checkSimBarcodeOffsetConf(prevFlags):
36 if prevFlags.Input.Files:
37 mdstring =
GetFileMD(prevFlags.Input.Files).
get(
"SimBarcodeOffset",
"0")
38 simBarcodeOffset = eval(mdstring)
39 if not simBarcodeOffset:
40 simBarcodeOffset = _barcodeOffsetFromTruthStrategy(prevFlags)
41 return simBarcodeOffset
43 def _regenerationIncrementFromTruthStrategy(prevFlags):
44 if prevFlags.Sim.TruthStrategy
in [TruthStrategy.MC15, TruthStrategy.MC18, TruthStrategy.MC18LLP]:
48 def _checkRegenerationIncrementConf(prevFlags):
50 if prevFlags.Input.Files:
51 mdstring =
GetFileMD(prevFlags.Input.Files).
get(
"RegenerationIncrement",
"0")
52 regenInc = eval(mdstring)
54 regenInc = _regenerationIncrementFromTruthStrategy(prevFlags)
58 scf.addFlag(
"Sim.SimBarcodeOffset", _checkSimBarcodeOffsetConf)
60 scf.addFlag(
"Sim.RegenerationIncrement", _checkRegenerationIncrementConf)
63 scf.addFlag(
"Sim.TwissFileBeam1",
False)
64 scf.addFlag(
"Sim.TwissFileBeam2",
False)
65 scf.addFlag(
"Sim.TwissEnergy",
lambda prevFlags :
float(prevFlags.Beam.Energy))
66 scf.addFlag(
"Sim.TwissFileBeta", 90.*m)
67 scf.addFlag(
"Sim.TwissFileNomReal",
'nominal')
68 scf.addFlag(
"Sim.TwissFileVersion",
"v02")
71 scf.addFlag(
"Sim.ReleaseGeoModel",
False)
72 scf.addFlag(
"Sim.SimplifiedGeoPath",
"")
73 scf.addFlag(
"Sim.RecordFlux",
False)
74 scf.addFlag(
"Sim.TruthStrategy",
lambda prevFlags : TruthStrategy.Validation
if prevFlags.Sim.ISF.ValidationMode
else TruthStrategy.MC12,
76 scf.addFlag(
"Sim.UseShadowEvent",
lambda prevFlags : prevFlags.Sim.ISF.Simulator.isQuasiStable())
77 scf.addFlag(
"Sim.G4Commands", [
"/run/verbose 2"])
78 scf.addFlag(
"Sim.FlagAbortedEvents",
False)
79 scf.addFlag(
"Sim.KillAbortedEvents",
True)
80 scf.addFlag(
"Sim.IncludeParentsInG4Event",
False)
83 scf.addFlag(
"Sim.DoFullChain",
False)
85 def _check_G4_version(prevFlags):
94 from AthenaConfiguration.Enums
import ProductionStep
95 if prevFlags.Common.ProductionStep
not in [ProductionStep.Simulation, ProductionStep.FastChain]:
96 if prevFlags.Input.Files:
97 version =
GetFileMD(prevFlags.Input.Files).
get(
"G4Version",
"")
99 from os
import environ
100 version =
str(environ.get(
"G4VERS",
""))
101 if prevFlags.Input.isMC
and isGaudiEnv()
and not version:
102 raise ValueError(
"Unknown G4 version")
105 scf.addFlag(
"Sim.G4Version", _check_G4_version)
107 def _checkPhysicsListConf(prevFlags):
108 physicsList =
"FTFP_BERT_ATL"
109 if prevFlags.Input.Files:
110 physicsList =
GetFileMD(prevFlags.Input.Files).
get(
"PhysicsList",
"")
113 physicsList =
GetFileMD(prevFlags.Input.Files).
get(
"physicsList",
"FTFP_BERT_ATL")
116 scf.addFlag(
"Sim.PhysicsList", _checkPhysicsListConf)
117 scf.addFlag(
"Sim.NeutronTimeCut", 150.)
118 scf.addFlag(
"Sim.NeutronEnergyCut", -1.)
119 scf.addFlag(
"Sim.ApplyEMCuts",
False)
120 scf.addFlag(
"Sim.MuonFieldOnlyInCalo",
False)
123 scf.addFlag(
"Sim.RecordStepInfo",
False)
124 scf.addFlag(
"Sim.StoppedParticleFile",
"")
125 scf.addFlag(
"Sim.BeamPipeSimMode", BeamPipeSimMode.Normal, type=BeamPipeSimMode)
126 scf.addFlag(
"Sim.LArParameterization", LArParameterization.NoFrozenShowers, type=LArParameterization)
128 scf.addFlag(
"Sim.TRTRangeCut",
129 lambda prevFlags:
float(
GetFileMD(prevFlags.Input.Files).
get(
'TRTRangeCut', 30.0)))
132 scf.addFlag(
"Sim.VertexSource", VertexSource.CondDB, type=VertexSource)
133 scf.addFlag(
"Sim.VertexTimeSmearing",
lambda prevFlags:
134 prevFlags.Beam.Type == BeamType.Collisions
and prevFlags.GeoModel.Run >= LHCPeriod.Run4)
136 def _checkVertexTimeWidth(prevFlags):
138 vertexTimeWidth = default
139 if prevFlags.Input.Files:
140 vertexTimeWidth =
GetFileMD(prevFlags.Input.Files).
get(
"VertexTimeWidth", default)
141 return vertexTimeWidth
143 scf.addFlag(
"Sim.VertexTimeWidth", _checkVertexTimeWidth)
146 scf.addFlag(
"Sim.NRRThreshold",
False)
147 scf.addFlag(
"Sim.NRRWeight",
False)
148 scf.addFlag(
"Sim.PRRThreshold",
False)
149 scf.addFlag(
"Sim.PRRWeight",
False)
150 scf.addFlag(
"Sim.OptionalUserActionList", [])
153 scf.addFlag(
"Sim.G4Stepper",
"AtlasRK4")
154 scf.addFlag(
"Sim.G4EquationOfMotion",
"")
155 scf.addFlag(
"Sim.UsingGeant4",
True)
160 scf.addFlag(
"Sim.CosmicFilterVolumeNames", [
"InnerDetector"])
161 scf.addFlag(
"Sim.CosmicFilterID",
False)
162 scf.addFlag(
"Sim.CosmicFilterPTmin",
False)
163 scf.addFlag(
"Sim.CosmicFilterPTmax",
False)
164 scf.addFlag(
"Sim.CosmicPtSlice",
"Off")
167 scf.addFlag(
"Sim.ISFRun",
False)
169 def _checkSimulationFlavour(prevFlags):
170 simulator = SimulationFlavour.Unknown
171 if prevFlags.Input.Files:
172 simFlavour =
GetFileMD(prevFlags.Input.Files).
get(
"Simulator",
"")
174 simFlavour =
GetFileMD(prevFlags.Input.Files).
get(
"SimulationFlavour",
"")
176 simulator = SimulationFlavour(simFlavour)
179 if simFlavour
in [
'default']:
180 simulator = SimulationFlavour.AtlasG4
181 elif simFlavour
in [
'MC12G4',
'FullG4']:
182 simulator = SimulationFlavour.FullG4MT
183 elif simFlavour
in [
'FullG4_QS',
'FullG4_LongLived']:
184 simulator = SimulationFlavour.FullG4MT_QS
185 elif simFlavour
in [
'PassBackG4']:
186 simulator = SimulationFlavour.PassBackG4MT
187 elif simFlavour
in [
'ATLFASTII']:
188 simulator = SimulationFlavour.ATLFASTIIMT
189 elif simFlavour
in [
'ATLFASTIIF']:
190 simulator = SimulationFlavour.ATLFASTIIFMT
191 elif simFlavour
in [
'ATLFAST3']:
192 simulator = SimulationFlavour.ATLFAST3MT
193 elif simFlavour
in [
'ATLFAST3_QS']:
194 simulator = SimulationFlavour.ATLFAST3MT_QS
197 simulator = SimulationFlavour.Unknown
200 scf.addFlag(
"Sim.ISF.Simulator", _checkSimulationFlavour, type=SimulationFlavour)
201 scf.addFlag(
"Sim.ISF.DoTimeMonitoring",
True)
202 scf.addFlag(
"Sim.ISF.DoMemoryMonitoring",
True)
203 scf.addFlag(
"Sim.ISF.ValidationMode",
False)
204 scf.addFlag(
"Sim.ISF.ReSimulation",
False)
205 scf.addFlag(
"Sim.ISF.UseTrackingGeometryCond",
False)
207 def _decideHITSMerging(prevFlags):
209 if prevFlags.Sim.ISF.Simulator.isFullSim()
and prevFlags.Sim.LArParameterization!=LArParameterization.FastCaloSim:
214 elif prevFlags.Sim.ISF.Simulator.usesFatras()
and prevFlags.Sim.ISF.Simulator.usesFastCaloSim():
219 elif prevFlags.Sim.ISF.Simulator.usesFastCaloSim()
or prevFlags.Sim.LArParameterization
is LArParameterization.FastCaloSim:
224 elif prevFlags.Sim.ISF.Simulator
in [SimulationFlavour.Unknown]:
230 raise ValueError(
"Invalid simulator")
231 return {
"ID": doID,
"CALO": doCALO,
"MUON": doMUON,
"ITk": doITk}
233 scf.addFlag(
"Sim.ISF.HITSMergingRequired", _decideHITSMerging)
235 scf.addFlag(
"Sim.FastCalo.ParamsInputFilename",
"FastCaloSim/MC23/TFCSparam_AF3_MC23_Sep23.root")
236 scf.addFlag(
"Sim.FastCalo.RunOnGPU",
False)
237 scf.addFlag(
"Sim.FastCalo.CaloCellsName",
"AllCalo")
238 scf.addFlag(
"Sim.FastCalo.doEMECFCS",
False)
242 scf.addFlag(
"Sim.FastChain.BCID", [1])
244 scf.addFlag(
"Sim.FastChain.PUWeights_lar_em", [1.0])
245 scf.addFlag(
"Sim.FastChain.PUWeights_lar_hec", [1.0])
246 scf.addFlag(
"Sim.FastChain.PUWeights_lar_bapre", [1.0])
247 scf.addFlag(
"Sim.FastChain.PUWeights_tile", [1.0])
250 scf.addFlag(
"Sim.Fatras.RandomStreamName",
"FatrasRnd")
251 scf.addFlag(
"Sim.Fatras.G4RandomStreamName",
"FatrasG4")
252 scf.addFlag(
"Sim.Fatras.TrkExRandomStreamName",
"TrkExRnd")
254 scf.addFlag(
"Sim.Fatras.MomCutOffSec", 50.)
255 scf.addFlag(
"Sim.Fatras.HadronIntProb", 1.)
256 scf.addFlag(
"Sim.Fatras.GaussianMixtureModel",
True)
257 scf.addFlag(
"Sim.Fatras.BetheHeitlerScale", 1.)
259 scf.addFlag(
"Sim.BeamPipeCut", 100.0)
260 scf.addFlag(
"Sim.TightMuonStepping",
False)
262 scf.addFlag(
'Sim.GenerationConfiguration',
'NONE')
268 """Fill simulation configuration flags from run arguments."""
269 if hasattr(runArgs,
"DataRunNumber"):
270 flags.Input.RunNumbers = [runArgs.DataRunNumber]
271 flags.Input.OverrideRunNumber =
True
272 flags.Input.LumiBlockNumbers = [1]
274 if hasattr(runArgs,
"jobNumber"):
275 flags.Input.JobNumber = runArgs.jobNumber
277 if hasattr(runArgs,
"physicsList"):
278 flags.Sim.PhysicsList = runArgs.physicsList
280 if hasattr(runArgs,
"truthStrategy"):
281 flags.Sim.TruthStrategy = TruthStrategy(runArgs.truthStrategy)