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 acc.setPrivateTools(CompFactory.Simulation.MatchingBkgVertexPositioner(name, **kwargs))
104def CrabKissingVertexPositionerCfg(flags, name="CrabKissingVertexPositioner", **kwargs):
105 """Return a Crab-Kissing vertex positioner tool"""
106 # todo needs BunchLength, RandomSvc, BunchShape
107 acc = ComponentAccumulator()
108 acc.setPrivateTools(CompFactory.Simulation.CrabKissingVertexPositioner(name, **kwargs))
112def LongBeamspotVertexPositionerCfg(flags, name="LongBeamspotVertexPositioner", **kwargs):
113 """Return a long beamspot vertex positioner tool"""
114 # todo needs LParameter and RandomSvc
115 acc = ComponentAccumulator()
116 kwargs.setdefault("SimpleTimeSmearing", flags.Sim.VertexTimeSmearing)
117 acc.setPrivateTools(CompFactory.Simulation.LongBeamspotVertexPositioner(name, **kwargs))
121def BeamEffectsAlgCfg(flags, name="BeamEffectsAlg", **kwargs):
122 """Return an accumulator and algorithm for beam effects, wihout output"""
123 acc = ComponentAccumulator()
125 from SimulationConfig.SimEnums import LArParameterization
126 if flags.Sim.LArParameterization is LArParameterization.FastCaloSim:
127 kwargs.setdefault("ISFRun", True)
129 kwargs.setdefault("ISFRun", flags.Sim.ISFRun)
131 # Set default properties
132 if flags.Sim.DoFullChain and flags.Digitization.PileUp:
133 kwargs.setdefault("InputMcEventCollection", "OriginalEvent_SG+GEN_EVENT")
135 kwargs.setdefault("InputMcEventCollection", "GEN_EVENT")
137 if flags.Sim.DoFullChain and flags.Common.isOverlay and not flags.Overlay.DataOverlay:
138 kwargs.setdefault('OutputMcEventCollection', f"{flags.Overlay.SigPrefix}TruthEvent")
140 kwargs.setdefault('OutputMcEventCollection', 'BeamTruthEvent')
142 # Set (todo) the appropriate manipulator tools
144 manipulators.append(acc.popToolsAndMerge(ValidityCheckerCfg(flags)))
145 from SimulationConfig.SimEnums import VertexSource
146 if not flags.Sim.VertexSource == VertexSource.AsGenerated:
147 # Vertex manipulation required
148 from SimulationConfig.SimEnums import CavernBackground
149 if flags.Beam.Type not in [BeamType.Cosmics, BeamType.TestBeam] and flags.Sim.CavernBackground is not CavernBackground.Read:
150 manipulators.append(acc.popToolsAndMerge(GenEventVertexPositionerCfg(flags)))
151 # manipulators.append(acc.popToolsAndMerge(GenEventBeamEffectBoosterCfg(flags))) # todo segmentation violation
152 # manipulators.append(acc.popToolsAndMerge(CrabKissingVertexPositionerCfg(flags))) # todo Callback registration failed
153 kwargs.setdefault("GenEventManipulators", manipulators)
155 acc.addEventAlgo(CompFactory.Simulation.BeamEffectsAlg(name, **kwargs), primary=True)
159def BeamEffectsAlgOutputCfg(flags, **kwargs):
160 """Return an accumulator and algorithm for beam effects, with output"""
161 acc = BeamEffectsAlgCfg(flags, **kwargs)
162 # Set to write HITS pool file
163 alg = acc.getPrimary()
164 ItemList = ["McEventCollection#" + alg.OutputMcEventCollection]
165 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
166 acc.merge(OutputStreamCfg(flags, "HITS", ItemList=ItemList, disableEventTag=True))
170def BeamSpotFixerAlgCfg(flags, name="BeamSpotFixerAlg", **kwargs):
171 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
172 acc = BeamSpotCondAlgCfg(flags)
174 kwargs.setdefault("InputKey", "Input_EventInfo")
175 if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
176 kwargs.setdefault("OutputKey", flags.Overlay.BkgPrefix + "EventInfo")
178 kwargs.setdefault("OutputKey", "EventInfo")
180 acc.addEventAlgo(CompFactory.Simulation.BeamSpotFixerAlg(name, **kwargs))
184def ZeroLifetimePositionerCfg(flags, name="ZeroLifetimePositioner", **kwargs):
185 result = ComponentAccumulator()
186 kwargs.setdefault('ApplyPatch', True)
187 kwargs.setdefault('RemovePatch', True)
188 result.addService(CompFactory.Simulation.ZeroLifetimePositioner(name, **kwargs), primary = True)
192def BeamSpotReweightingAlgCfg(flags, name="BeamSpotReweightingAlg", **kwargs):
193 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
194 acc = BeamSpotCondAlgCfg(flags)
196 kwargs.setdefault("Input_beam_sigma_z", flags.Digitization.InputBeamSigmaZ)
198 acc.addEventAlgo(CompFactory.Simulation.BeamSpotReweightingAlg(name, **kwargs))
200 # Ignore dependencies
201 from AthenaConfiguration.MainServicesConfig import OutputUsageIgnoreCfg
202 acc.merge(OutputUsageIgnoreCfg(flags, name))