24def GenEventRotatorCfg(flags, name="GenEventRotator", **kwargs):
25 """Return a event rotator tool"""
26 acc = ComponentAccumulator()
27 acc.setPrivateTools(CompFactory.Simulation.GenEventRotator(name, **kwargs))
31def GenEventBeamEffectBoosterCfg(flags, name="GenEventBeamEffectBooster", **kwargs):
32 """Return a lorentz booster tool"""
33 # todo needs random seed, more?
34 acc = ComponentAccumulator()
35 acc.setPrivateTools(CompFactory.Simulation.GenEventBeamEffectBooster(name, **kwargs))
39def GenEventVertexPositionerCfg(flags, name="GenEventVertexPositioner", **kwargs):
40 """Return a vertex positioner tool"""
41 # todo needs input file(s?)
43 acc = ComponentAccumulator()
45 from SimulationConfig.SimEnums import VertexSource
46 if flags.Sim.VertexSource is VertexSource.MatchingBkg:
47 kwargs.setdefault("VertexShifters", [acc.popToolsAndMerge(MatchingBkgVertexPositionerCfg(flags))])
48 elif flags.Sim.VertexSource is VertexSource.CondDB:
49 kwargs.setdefault("VertexShifters", [acc.popToolsAndMerge(VertexBeamCondPositionerCfg(flags))])
50 elif flags.Sim.VertexSource is VertexSource.LongBeamspotVertexPositioner:
51 kwargs.setdefault("VertexShifters", [acc.popToolsAndMerge(LongBeamspotVertexPositionerCfg(flags))])
52 elif flags.Sim.VertexSource is VertexSource.LRAPositioner:
53 kwargs.setdefault("VertexShifters", [acc.popToolsAndMerge(LRAVertexPositionerCfg(flags))])
55 acc.setPrivateTools(CompFactory.Simulation.GenEventVertexPositioner(name, **kwargs))
59# LorentzVectorGenerators
60def VertexBeamCondPositionerCfg(flags, name="VertexBeamCondPositioner", **kwargs):
61 """Return a conditional (? todo) vertex positioner tool"""
62 from RngComps.RngCompsConfig import AthRNGSvcCfg
64 acc = ComponentAccumulator()
66 kwargs.setdefault("RandomSvc", acc.getPrimaryAndMerge(AthRNGSvcCfg(flags)))
67 kwargs.setdefault("SimpleTimeSmearing", flags.Sim.VertexTimeSmearing)
68 kwargs.setdefault("TimeWidth", flags.Sim.VertexTimeWidth)
70 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
71 acc.merge(BeamSpotCondAlgCfg(flags))
73 acc.setPrivateTools(CompFactory.Simulation.VertexBeamCondPositioner(name, **kwargs))
77def LRAVertexPositionerCfg(flags, name="LRAVertexPositionerCfg", **kwargs):
78 from RngComps.RngCompsConfig import AthRNGSvcCfg
80 acc = ComponentAccumulator()
82 kwargs.setdefault("FileName", flags.Beam.vdMScan.ConfigFile)
83 kwargs.setdefault("HistName", flags.Beam.vdMScan.PV.PDF)
85 kwargs.setdefault("RNGService", acc.getPrimaryAndMerge(AthRNGSvcCfg(flags)).name)
87 acc.setPrivateTools(CompFactory.Simulation.LRAVertexPositioner(name, **kwargs))
90def MatchingBkgVertexPositionerCfg(flags, name="MatchingBkgVertexPositioner", **kwargs):
91 """Return a vertex positioner tool that reads a matching vertex from the background input file."""
92 acc = ComponentAccumulator()
94 if flags.Overlay.DataOverlay:
95 kwargs.setdefault("PrimaryVertexContainerName", f"{flags.Overlay.BkgPrefix}PrimaryVertices")
97 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
98 acc.merge(SGInputLoaderCfg(flags, [f'xAOD::VertexContainer#{kwargs["PrimaryVertexContainerName"]}']))
100 kwargs.setdefault("McEventCollectionName", f"{flags.Overlay.BkgPrefix}TruthEvent")
102 acc.setPrivateTools(CompFactory.Simulation.MatchingBkgVertexPositioner(name, **kwargs))
106def CrabKissingVertexPositionerCfg(flags, name="CrabKissingVertexPositioner", **kwargs):
107 """Return a Crab-Kissing vertex positioner tool"""
108 # todo needs BunchLength, RandomSvc, BunchShape
109 acc = ComponentAccumulator()
110 acc.setPrivateTools(CompFactory.Simulation.CrabKissingVertexPositioner(name, **kwargs))
114def LongBeamspotVertexPositionerCfg(flags, name="LongBeamspotVertexPositioner", **kwargs):
115 """Return a long beamspot vertex positioner tool"""
116 # todo needs LParameter and RandomSvc
117 acc = ComponentAccumulator()
118 kwargs.setdefault("SimpleTimeSmearing", flags.Sim.VertexTimeSmearing)
119 acc.setPrivateTools(CompFactory.Simulation.LongBeamspotVertexPositioner(name, **kwargs))
123def BeamEffectsAlgCfg(flags, name="BeamEffectsAlg", **kwargs):
124 """Return an accumulator and algorithm for beam effects, wihout output"""
125 acc = ComponentAccumulator()
127 from SimulationConfig.SimEnums import LArParameterization
128 if flags.Sim.LArParameterization is LArParameterization.FastCaloSim:
129 kwargs.setdefault("ISFRun", True)
131 kwargs.setdefault("ISFRun", flags.Sim.ISFRun)
133 # Set default properties
134 if flags.Sim.DoFullChain and flags.Digitization.PileUp:
135 kwargs.setdefault("InputMcEventCollection", "OriginalEvent_SG+GEN_EVENT")
137 kwargs.setdefault("InputMcEventCollection", "GEN_EVENT")
139 if flags.Sim.DoFullChain and flags.Common.isOverlay and not flags.Overlay.DataOverlay:
140 kwargs.setdefault('OutputMcEventCollection', f"{flags.Overlay.SigPrefix}TruthEvent")
142 kwargs.setdefault('OutputMcEventCollection', 'BeamTruthEvent')
144 # Set (todo) the appropriate manipulator tools
146 manipulators.append(acc.popToolsAndMerge(ValidityCheckerCfg(flags)))
147 from SimulationConfig.SimEnums import VertexSource
148 if not flags.Sim.VertexSource == VertexSource.AsGenerated:
149 # Vertex manipulation required
150 from SimulationConfig.SimEnums import CavernBackground
151 if flags.Beam.Type not in [BeamType.Cosmics, BeamType.TestBeam] and flags.Sim.CavernBackground is not CavernBackground.Read:
152 manipulators.append(acc.popToolsAndMerge(GenEventVertexPositionerCfg(flags)))
153 # manipulators.append(acc.popToolsAndMerge(GenEventBeamEffectBoosterCfg(flags))) # todo segmentation violation
154 # manipulators.append(acc.popToolsAndMerge(CrabKissingVertexPositionerCfg(flags))) # todo Callback registration failed
155 kwargs.setdefault("GenEventManipulators", manipulators)
157 acc.addEventAlgo(CompFactory.Simulation.BeamEffectsAlg(name, **kwargs), primary=True)
161def BeamEffectsAlgOutputCfg(flags, **kwargs):
162 """Return an accumulator and algorithm for beam effects, with output"""
163 acc = BeamEffectsAlgCfg(flags, **kwargs)
164 # Set to write HITS pool file
165 alg = acc.getPrimary()
166 ItemList = ["McEventCollection#" + alg.OutputMcEventCollection]
167 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
168 acc.merge(OutputStreamCfg(flags, "HITS", ItemList=ItemList, disableEventTag=True))
172def BeamSpotFixerAlgCfg(flags, name="BeamSpotFixerAlg", **kwargs):
173 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
174 acc = BeamSpotCondAlgCfg(flags)
176 kwargs.setdefault("InputKey", "Input_EventInfo")
177 if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
178 kwargs.setdefault("OutputKey", flags.Overlay.BkgPrefix + "EventInfo")
180 kwargs.setdefault("OutputKey", "EventInfo")
182 acc.addEventAlgo(CompFactory.Simulation.BeamSpotFixerAlg(name, **kwargs))
186def ZeroLifetimePositionerCfg(flags, name="ZeroLifetimePositioner", **kwargs):
187 result = ComponentAccumulator()
188 kwargs.setdefault('ApplyPatch', True)
189 kwargs.setdefault('RemovePatch', True)
190 result.addService(CompFactory.Simulation.ZeroLifetimePositioner(name, **kwargs), primary = True)
194def BeamSpotReweightingAlgCfg(flags, name="BeamSpotReweightingAlg", **kwargs):
195 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
196 acc = BeamSpotCondAlgCfg(flags)
198 kwargs.setdefault("Input_beam_sigma_z", flags.Digitization.InputBeamSigmaZ)
200 acc.addEventAlgo(CompFactory.Simulation.BeamSpotReweightingAlg(name, **kwargs))
202 # Ignore dependencies
203 from AthenaConfiguration.MainServicesConfig import OutputUsageIgnoreCfg
204 acc.merge(OutputUsageIgnoreCfg(flags, name))