1 """Construct ConfigFlags for Digitization
3 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 from AthenaConfiguration.AutoConfigFlags
import GetFileMD
6 from AthenaConfiguration.AthConfigFlags
import AthConfigFlags
7 from AthenaConfiguration.Enums
import ProductionStep
8 from SimulationConfig.SimEnums
import PixelRadiationDamageSimulationType
12 """Return a valid value for Digitization.BeamIntensity, which
13 matches the specified constBunchSpacing
15 if type(constBunchSpacing)
is not int:
16 raise TypeError(
"constBunchSpacing must be int, "
17 "not %s" %
type(constBunchSpacing).__name__)
18 if constBunchSpacing % 25 != 0:
19 raise ValueError(
"constBunchSpacing must be a multiple of 25, "
20 "not %s" % constBunchSpacing)
23 if constBunchSpacing == 25:
28 nBunches = (constBunchSpacing//25) - 2
29 pattern += nBunches*[0.0]
34 """Return an AthConfigFlags object with required flags"""
35 flags = AthConfigFlags()
38 def _checkDigiSteeringConf(prevFlags):
39 digiSteeringConf =
"StandardPileUpToolsAlg"
40 if prevFlags.Input.Files:
41 digiSteeringConf =
GetFileMD(prevFlags.Input.Files).
get(
"digiSteeringConf",
"StandardPileUpToolsAlg")
42 return digiSteeringConf
44 flags.addFlag(
"Digitization.DigiSteeringConf", _checkDigiSteeringConf)
46 flags.addFlag(
"Digitization.DoInnerDetectorNoise",
lambda prevFlags:
not prevFlags.Common.isOverlay)
48 flags.addFlag(
"Digitization.DoXingByXingPileUp",
False)
50 flags.addFlag(
"Digitization.DoCaloNoise",
lambda prevFlags:
not prevFlags.Common.isOverlay)
52 flags.addFlag(
"Digitization.EnableCaloHSTruthRecoInputs",
False)
54 flags.addFlag(
"Digitization.HighGainFCal",
False)
56 flags.addFlag(
"Digitization.HighGainEMECIW",
True)
58 flags.addFlag(
"Digitization.PileUp",
59 lambda prevFlags:
GetFileMD(prevFlags.Input.Files).
get(
"pileUp",
"False") !=
"False")
61 flags.addFlag(
"Digitization.UseUpdatedTGCConditions",
False)
63 flags.addFlag(
"Digitization.EnableTruth",
True)
65 flags.addFlag(
"Digitization.AddCaloDigi",
False)
67 flags.addFlag(
"Digitization.AddCaloDigiThinned",
False)
69 flags.addFlag(
"Digitization.RandomSeedOffset", 0)
71 flags.addFlag(
"Digitization.ExtraInputs", [(
"xAOD::EventInfo",
"EventInfo")])
73 flags.addFlag(
"Digitization.InputBeamSigmaZ", -1)
76 flags.addFlag(
"Digitization.PixelPlanarRadiationDamageSimulationType",
77 PixelRadiationDamageSimulationType.NoRadiationDamage, type=PixelRadiationDamageSimulationType)
79 flags.addFlag(
"Digitization.Pixel3DRadiationDamageSimulationType",
80 PixelRadiationDamageSimulationType.NoRadiationDamage, type=PixelRadiationDamageSimulationType)
84 flags.addFlag(
"Digitization.DigitizeITk3Das3D",
False)
88 flags.addFlag(
"Digitization.PU.BunchStructureConfig",
"")
90 flags.addFlag(
"Digitization.PU.ProfileConfig",
"")
92 flags.addFlag(
"Digitization.PU.CustomProfile",
"")
94 flags.addFlag(
"Digitization.PU.ForceSequentialEventNumbers",
95 lambda prevFlags: prevFlags.Common.ProductionStep == ProductionStep.PileUpPresampling)
97 flags.addFlag(
"Digitization.PU.BeamHaloInputCols", [])
99 flags.addFlag(
"Digitization.PU.BeamIntensityPattern",
102 flags.addFlag(
"Digitization.PU.BeamGasInputCols", [])
105 flags.addFlag(
"Digitization.PU.BunchSpacing",
106 lambda prevFlags: prevFlags.Beam.BunchSpacing)
108 flags.addFlag(
"Digitization.PU.InitialBunchCrossing", -32)
109 flags.addFlag(
"Digitization.PU.FinalBunchCrossing", 6)
111 flags.addFlag(
"Digitization.PU.CavernIgnoresBeamInt",
False)
113 flags.addFlag(
"Digitization.PU.CavernInputCols", [])
115 flags.addFlag(
"Digitization.PU.FixedT0BunchCrossing", 0)
118 flags.addFlag(
"Digitization.PU.HighPtMinBiasInputCols", [])
120 flags.addFlag(
"Digitization.PU.HighPtMinBiasInputColOffset", 0)
123 flags.addFlag(
"Digitization.PU.LowPtMinBiasInputCols", [])
125 flags.addFlag(
"Digitization.PU.NumberOfLowPtMinBias", 0.0)
127 flags.addFlag(
"Digitization.PU.NumberOfHighPtMinBias", 0.0)
129 flags.addFlag(
"Digitization.PU.NumberOfBeamGas", 0.0)
131 flags.addFlag(
"Digitization.PU.NumberOfBeamHalo", 0.0)
133 flags.addFlag(
"Digitization.PU.NumberOfCollisions", 0.0)
135 flags.addFlag(
"Digitization.PU.NumberOfCavern", 0.0)
137 flags.addFlag(
"Digitization.PU.SignalPatternForSteppingCache", [])
139 flags.addFlag(
"Digitization.DoFastDigi", [])
141 flags.addFlag(
"Digitization.ReadParametersFromDB",
lambda prevFlags : prevFlags.Common.ProductionStep
in [ProductionStep.Digitization, ProductionStep.PileUpPresampling, ProductionStep.Overlay, ProductionStep.FastChain])
143 flags.addFlag(
"Digitization.TRT.HeavyIonHT",
False)
148 """Fill digitization configuration flags from run arguments."""
150 if hasattr(runArgs,
"DataRunNumber"):
151 flags.Input.ConditionsRunNumber = runArgs.DataRunNumber
154 if hasattr(runArgs,
"jobNumber"):
155 flags.Input.JobNumber = runArgs.jobNumber
157 if hasattr(runArgs,
"PileUpPresampling"):
158 flags.Common.ProductionStep = ProductionStep.PileUpPresampling
159 elif flags.Common.ProductionStep == ProductionStep.Default:
160 flags.Common.ProductionStep = ProductionStep.Digitization
162 if hasattr(runArgs,
"doAllNoise"):
163 flags.Digitization.DoInnerDetectorNoise = runArgs.doAllNoise
164 flags.Digitization.DoCaloNoise = runArgs.doAllNoise
166 if hasattr(runArgs,
"AddCaloDigi"):
167 flags.Digitization.AddCaloDigi = runArgs.AddCaloDigi
169 if hasattr(runArgs,
"digiSeedOffset1")
or hasattr(runArgs,
"digiSeedOffset2"):
170 flags.Digitization.RandomSeedOffset = 0
171 if hasattr(runArgs,
"digiSeedOffset1"):
172 flags.Digitization.RandomSeedOffset +=
int(runArgs.digiSeedOffset1)
173 if hasattr(runArgs,
"digiSeedOffset2"):
174 flags.Digitization.RandomSeedOffset +=
int(runArgs.digiSeedOffset2)
176 flags.Digitization.RandomSeedOffset = 3
178 if hasattr(runArgs,
"digiSteeringConf"):
179 flags.Digitization.DigiSteeringConf = runArgs.digiSteeringConf +
"PileUpToolsAlg"
187 """Fill pile-up digitization configuration flags from run arguments."""
188 if hasattr(runArgs,
"numberOfLowPtMinBias"):
189 flags.Digitization.PU.NumberOfLowPtMinBias = runArgs.numberOfLowPtMinBias
191 if hasattr(runArgs,
"numberOfHighPtMinBias"):
192 flags.Digitization.PU.NumberOfHighPtMinBias = runArgs.numberOfHighPtMinBias
194 if hasattr(runArgs,
"numberOfBeamHalo"):
195 flags.Digitization.PU.NumberOfBeamHalo = runArgs.numberOfBeamHalo
197 if hasattr(runArgs,
"numberOfBeamGas"):
198 flags.Digitization.PU.NumberOfBeamGas = runArgs.numberOfBeamGas
200 if hasattr(runArgs,
"numberOfCavernBkg"):
201 flags.Digitization.PU.NumberOfCavern = runArgs.numberOfCavernBkg
203 if hasattr(runArgs,
"bunchSpacing"):
204 flags.Digitization.PU.BunchSpacing = runArgs.bunchSpacing
206 if hasattr(runArgs,
"pileupInitialBunch"):
207 flags.Digitization.PU.InitialBunchCrossing = runArgs.pileupInitialBunch
209 if hasattr(runArgs,
"pileupFinalBunch"):
210 flags.Digitization.PU.FinalBunchCrossing = runArgs.pileupFinalBunch
213 if flags.Digitization.PU.InitialBunchCrossing > flags.Digitization.PU.FinalBunchCrossing:
214 raise ValueError(
"Initial bunch crossing should not be larger than the final one")
216 if hasattr(runArgs,
"inputLowPtMinbiasHitsFile"):
217 from RunDependentSimComps.PileUpUtils
import generateBackgroundInputCollections
218 flags.Digitization.PU.LowPtMinBiasInputCols = \
220 flags.Digitization.PU.NumberOfLowPtMinBias,
True)
222 if hasattr(runArgs,
"inputHighPtMinbiasHitsFile"):
223 from RunDependentSimComps.PileUpUtils
import getInputCollectionOffset, generateBackgroundInputCollections
224 if flags.Digitization.PU.HighPtMinBiasInputColOffset < 0:
226 flags.Digitization.PU.HighPtMinBiasInputColOffset =
getInputCollectionOffset(flags, runArgs.inputHighPtMinbiasHitsFile)
228 flags.Digitization.PU.HighPtMinBiasInputCols = \
230 flags.Digitization.PU.NumberOfHighPtMinBias,
True)
232 if hasattr(runArgs,
"inputCavernHitsFile"):
233 from RunDependentSimComps.PileUpUtils
import generateBackgroundInputCollections
234 flags.Digitization.PU.CavernInputCols = \
236 flags.Digitization.PU.NumberOfCavern,
True)
238 if hasattr(runArgs,
"inputBeamHaloHitsFile"):
239 from RunDependentSimComps.PileUpUtils
import generateBackgroundInputCollections
240 flags.Digitization.PU.BeamHaloInputCols = \
242 flags.Digitization.PU.NumberOfBeamHalo,
True)
244 if hasattr(runArgs,
"inputBeamGasHitsFile"):
245 from RunDependentSimComps.PileUpUtils
import generateBackgroundInputCollections
246 flags.Digitization.PU.BeamGasInputCols = \
248 flags.Digitization.PU.NumberOfBeamGas,
True)
255 """Setup common digitization flags."""
257 if (hasattr(runArgs,
"inputLowPtMinbiasHitsFile")
258 or hasattr(runArgs,
"inputHighPtMinbiasHitsFile")
259 or hasattr(runArgs,
"inputCavernHitsFile")
260 or hasattr(runArgs,
"inputBeamHaloHitsFile")
261 or hasattr(runArgs,
"inputBeamGasHitsFile")):
262 flags.Digitization.PileUp =
True
264 if flags.Digitization.PileUp:
265 flags.Input.OverrideRunNumber =
True
267 if flags.Concurrency.NumThreads > 0:
268 flags.Digitization.DoXingByXingPileUp =
False
270 flags.Digitization.DoXingByXingPileUp =
True
272 flags.Input.OverrideRunNumber = flags.Input.ConditionsRunNumber > 0