1 """ComponentAccumulator confguration for pileup digitization
3 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
8 from RngComps.RngCompsConfig
import dSFMT, AthRNGSvcCfg
9 from DigitizationConfig
import PileUpEventType
10 from DigitizationConfig.RunDependentConfig
import (
12 LumiProfileSvcCfg, NoProfileSvcCfg,
14 from BeamEffects.BeamEffectsAlgConfig
import BeamSpotFixerAlgCfg
18 """Local wrapper for dSFMT RNG service"""
19 seedOffset =
" OFFSET 340 123 345"
20 if name==
"PileUpCollXingStream":
21 seedOffset =
" OFFSET 340 123 345"
23 seedOffset =
" OFFSET 340 678 91011"
24 return dSFMT(name + seedOffset)
29 kwargs.setdefault(
"IntensityPattern", flags.Digitization.PU.BeamIntensityPattern)
30 kwargs.setdefault(
"SignalPattern", flags.Digitization.PU.SignalPatternForSteppingCache)
31 acc.addService(CompFactory.StepArrayBM(name, **kwargs), primary=
True)
37 kwargs.setdefault(
"IntensityPattern", flags.Digitization.PU.BeamIntensityPattern)
38 kwargs.setdefault(
"T0Offset", flags.Digitization.PU.FixedT0BunchCrossing)
39 acc.addService(CompFactory.FixedArrayBM(name, **kwargs), primary=
True)
45 kwargs.setdefault(
"IntensityPattern", flags.Digitization.PU.BeamIntensityPattern)
46 kwargs.setdefault(
"RandomSvc", acc.getPrimaryAndMerge(
AthRNGSvcCfg(flags)).name)
47 acc.addService(CompFactory.ArrayBM(name, **kwargs), primary=
True)
53 kwargs.setdefault(
"KeepInputFilesOpen",
True)
54 kwargs.setdefault(
"ProcessMetadata",
False)
55 acc.addService(CompFactory.EventSelectorAthenaPool(name, **kwargs), primary=
True)
60 kwargs.setdefault(
"InputCollections", flags.Digitization.PU.LowPtMinBiasInputCols)
65 kwargs.setdefault(
"InputCollections", flags.Digitization.PU.HighPtMinBiasInputCols)
66 kwargs.setdefault(
'SkipEvents', flags.Digitization.PU.HighPtMinBiasInputColOffset)
71 kwargs.setdefault(
"InputCollections", flags.Digitization.PU.CavernInputCols)
76 kwargs.setdefault(
"InputCollections", flags.Digitization.PU.BeamGasInputCols)
81 kwargs.setdefault(
"InputCollections", flags.Digitization.PU.BeamHaloInputCols)
87 kwargs.setdefault(
"CollPerXing", flags.Digitization.PU.NumberOfLowPtMinBias + flags.Digitization.PU.NumberOfHighPtMinBias)
88 kwargs.setdefault(
"FractionOfCache1Collisions", (flags.Digitization.PU.NumberOfLowPtMinBias/
89 (flags.Digitization.PU.NumberOfLowPtMinBias + flags.Digitization.PU.NumberOfHighPtMinBias)))
91 kwargs.setdefault(
"PileUpEventType", PileUpEventType.MinimumBias)
92 if flags.Digitization.DoXingByXingPileUp
or flags.Digitization.PU.SignalPatternForSteppingCache:
93 kwargs.setdefault(
"Cache1ReadDownscaleFactor", 1)
95 kwargs.setdefault(
"Cache2ReadDownscaleFactor", 1)
98 kwargs.setdefault(
"OccupationFraction", (
float(flags.Digitization.PU.BunchSpacing)/
99 float(flags.Beam.BunchSpacing)))
101 RndmStreamName =
"PileUpCollXingStream"
103 kwargs.setdefault(
"RndmGenSvc", acc.getService(
"AtDSFMTGenSvc"))
104 kwargs.setdefault(
"RndmStreamName", RndmStreamName)
107 acc.setPrivateTools(CompFactory.SplitBkgStreamsCache(name, **kwargs))
113 kwargs.setdefault(
"CollPerXing", flags.Digitization.PU.NumberOfLowPtMinBias)
115 kwargs.setdefault(
"PileUpEventType", PileUpEventType.MinimumBias)
116 if flags.Digitization.DoXingByXingPileUp
or flags.Digitization.PU.SignalPatternForSteppingCache:
117 kwargs.setdefault(
"ReadDownscaleFactor", 1)
119 kwargs.setdefault(
"OccupationFraction", (
float(flags.Digitization.PU.BunchSpacing)/
120 float(flags.Beam.BunchSpacing)))
122 RndmStreamName =
"PileUpCollXingStream"
124 kwargs.setdefault(
"RndmGenSvc", acc.getService(
"AtDSFMTGenSvc"))
125 kwargs.setdefault(
"RndmStreamName", RndmStreamName)
128 if flags.Digitization.PU.SignalPatternForSteppingCache:
130 tool = CompFactory.BkgStreamsStepCache(name, **kwargs)
132 tool = CompFactory.BkgStreamsCache(name, **kwargs)
134 acc.setPrivateTools(tool)
140 kwargs.setdefault(
"CollPerXing", flags.Digitization.PU.NumberOfHighPtMinBias)
142 kwargs.setdefault(
"PileUpEventType", PileUpEventType.HighPtMinimumBias)
143 kwargs.setdefault(
"ReadDownscaleFactor", 1)
145 kwargs.setdefault(
"OccupationFraction", (
float(flags.Digitization.PU.BunchSpacing)/
146 float(flags.Beam.BunchSpacing)))
148 RndmStreamName =
"PileUpCollXingStream"
150 kwargs.setdefault(
"RndmGenSvc", acc.getService(
"AtDSFMTGenSvc"))
151 kwargs.setdefault(
"RndmStreamName", RndmStreamName)
154 if flags.Digitization.PU.SignalPatternForSteppingCache:
156 tool = CompFactory.BkgStreamsStepCache(name, **kwargs)
158 tool = CompFactory.BkgStreamsCache(name, **kwargs)
160 acc.setPrivateTools(tool)
166 kwargs.setdefault(
"CollPerXing", flags.Digitization.PU.NumberOfCavern)
167 kwargs.setdefault(
"CollDistribution",
"Fixed")
168 kwargs.setdefault(
"PileUpEventType", PileUpEventType.Cavern)
169 if flags.Digitization.DoXingByXingPileUp
or flags.Digitization.PU.SignalPatternForSteppingCache:
170 kwargs.setdefault(
"ReadDownscaleFactor", 1)
172 OccupationFraction = (
float(flags.Digitization.PU.BunchSpacing)/
173 float(flags.Beam.BunchSpacing))
174 if flags.Digitization.PU.BeamIntensityPattern:
175 kwargs.setdefault(
"IgnoreBeamInt", flags.Digitization.PU.CavernIgnoresBeamInt)
176 if flags.Digitization.PU.CavernIgnoresBeamInt:
177 OccupationFraction = 1.0
178 kwargs.setdefault(
"OccupationFraction", OccupationFraction)
181 RndmStreamName =
"PileUpCollXingStream"
183 kwargs.setdefault(
"RndmGenSvc", acc.getService(
"AtDSFMTGenSvc"))
184 kwargs.setdefault(
"RndmStreamName", RndmStreamName)
187 if flags.Digitization.PU.SignalPatternForSteppingCache:
189 tool = CompFactory.BkgStreamsStepCache(name, **kwargs)
191 tool = CompFactory.BkgStreamsCache(name, **kwargs)
192 acc.setPrivateTools(tool)
198 kwargs.setdefault(
"IgnoreBeamLumi",
True)
199 kwargs.setdefault(
"CollPerXing", flags.Digitization.PU.NumberOfBeamGas)
200 kwargs.setdefault(
"PileUpEventType", PileUpEventType.HaloGas)
201 kwargs.setdefault(
"CollDistribution",
"Poisson")
202 kwargs.setdefault(
"ReadDownscaleFactor", 1)
206 RndmStreamName =
"PileUpCollXingStream"
208 kwargs.setdefault(
"RndmGenSvc", acc.getService(
"AtDSFMTGenSvc"))
209 kwargs.setdefault(
"RndmStreamName", RndmStreamName)
212 if flags.Digitization.PU.SignalPatternForSteppingCache:
214 tool = CompFactory.BkgStreamsStepCache(name, **kwargs)
216 tool = CompFactory.BkgStreamsCache(name, **kwargs)
218 acc.setPrivateTools(tool)
224 kwargs.setdefault(
"IgnoreBeamLumi",
True)
225 kwargs.setdefault(
"CollPerXing", flags.Digitization.PU.NumberOfBeamHalo)
226 kwargs.setdefault(
"PileUpEventType", PileUpEventType.HaloGas)
227 kwargs.setdefault(
"CollDistribution",
"Poisson")
228 kwargs.setdefault(
"ReadDownscaleFactor", 1)
232 RndmStreamName =
"PileUpCollXingStream"
234 kwargs.setdefault(
"RndmGenSvc", acc.getService(
"AtDSFMTGenSvc"))
235 kwargs.setdefault(
"RndmStreamName", RndmStreamName)
238 if flags.Digitization.PU.SignalPatternForSteppingCache:
240 tool = CompFactory.BkgStreamsStepCache(name, **kwargs)
242 tool = CompFactory.BkgStreamsCache(name, **kwargs)
244 acc.setPrivateTools(tool)
252 kwargs.setdefault(
"XingByXing", flags.Digitization.DoXingByXingPileUp)
254 if flags.Digitization.PU.BeamIntensityPattern:
255 if flags.Digitization.PU.SignalPatternForSteppingCache:
257 kwargs.setdefault(
"BeamInt", acc.getPrimaryAndMerge(
StepArrayBMCfg(flags)).name)
258 elif flags.Digitization.PU.FixedT0BunchCrossing:
260 kwargs.setdefault(
"BeamInt", acc.getPrimaryAndMerge(
FixedArrayBMCfg(flags)).name)
263 kwargs.setdefault(
"BeamInt", acc.getPrimaryAndMerge(
ArrayBMCfg(flags)).name)
266 assert not flags.Input.SecondaryFiles, (
"Found ConfigFlags.Input.SecondaryFiles = %r; "
267 "double event selection is not supported "
268 "by PileUpEventLoopMgr" % (
not flags.Input.SecondaryFiles))
270 kwargs.setdefault(
"OrigSelector", acc.getService(
"EventSelector"))
271 BackgroundCaches = []
273 if flags.Digitization.PU.LowPtMinBiasInputCols:
275 if flags.Digitization.PU.HighPtMinBiasInputCols:
277 if flags.Digitization.PU.CavernInputCols:
279 if flags.Digitization.PU.BeamGasInputCols:
281 if flags.Digitization.PU.BeamHaloInputCols:
283 kwargs.setdefault(
"bkgCaches", BackgroundCaches)
285 kwargs.setdefault(
"XingFrequency", flags.Digitization.PU.BunchSpacing)
287 kwargs.setdefault(
"firstXing", flags.Digitization.PU.InitialBunchCrossing)
288 kwargs.setdefault(
"lastXing", flags.Digitization.PU.FinalBunchCrossing)
290 if flags.Input.RunAndLumiOverrideList:
292 kwargs.setdefault(
"BeamLuminosity", acc.getPrimaryAndMerge(
LumiProfileSvcCfg(flags)).name)
294 kwargs.setdefault(
"MaxMinBiasCollPerXing", flags.Digitization.PU.NumberOfCollisions)
295 kwargs.setdefault(
"BeamLuminosity", acc.getPrimaryAndMerge(
NoProfileSvcCfg(flags)).name)
297 from AthenaKernel.EventIdOverrideConfig
import EvtIdModifierSvcCfg
299 kwargs.setdefault(
"EventInfoName",
"Input_EventInfo")
304 if flags.Input.MCChannelNumber > 0:
305 kwargs.setdefault(
"MCChannelNumber", flags.Input.MCChannelNumber)
308 if flags.Output.doWriteRDO:
309 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
311 "xAOD::EventInfoContainer#PileUpEventInfo",
312 "xAOD::EventInfoAuxContainer#PileUpEventInfo*",
315 acc.addService(CompFactory.PileUpEventLoopMgr(name, **kwargs))
320 """NoPileUpMuWriter configuration."""
322 acc.addEventAlgo(CompFactory.NoPileUpMuWriter(name, **kwargs))