ATLAS Offline Software
Loading...
Searching...
No Matches
xAODEventInfoCnvConfig.py
Go to the documentation of this file.
1"""Define methods to construct configured EventInfo conversion algorithms
2
3Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4"""
5
6from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7from AthenaConfiguration.ComponentFactory import CompFactory
8from AthenaConfiguration.Enums import LHCPeriod, ProductionStep
9
10
11def EventInfoCnvAlgCfg(flags, name="EventInfoCnvAlg",
12 inputKey="McEventInfo",
13 outputKey="EventInfo",
14 disableBeamSpot=False,
15 **kwargs):
16 """Return a ComponentAccumulator for EventInfoCnvAlg algorithm"""
17
18 acc = ComponentAccumulator()
19
20 kwargs.setdefault("AODKey", inputKey)
21 kwargs.setdefault("xAODKey", outputKey)
22
23 if f"PileUpEventInfo#{inputKey}" in flags.Input.TypedCollections:
24 kwargs.setdefault("PileupKey", f"Pileup{outputKey}")
25 else:
26 kwargs.setdefault("PileupKey", "")
27
28 # TODO: luminosity
29
30 if not disableBeamSpot:
31 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
32 acc.merge(BeamSpotCondAlgCfg(flags))
33
34 acc.addEventAlgo(CompFactory.xAODMaker.EventInfoCnvAlg(name, **kwargs))
35
36 return acc
37
38
39def EventInfoOverlayAlgCfg(flags, name="EventInfoOverlay", **kwargs):
40 """Return a ComponentAccumulator for EventInfoOverlay algorithm"""
41 acc = ComponentAccumulator()
42
43 # Add beam spot conditions
44 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
45 acc.merge(BeamSpotCondAlgCfg(flags))
46
47 kwargs.setdefault("BkgInputKey", f"{flags.Overlay.BkgPrefix}EventInfo")
48 kwargs.setdefault("SignalInputKey", f"{flags.Overlay.SigPrefix}EventInfo")
49 kwargs.setdefault("OutputKey", "EventInfo")
50
51 kwargs.setdefault("DataOverlay", flags.Overlay.DataOverlay)
52 kwargs.setdefault("ValidateBeamSpot", not (flags.Common.ProductionStep == ProductionStep.FastChain and flags.Common.isOverlay) and not flags.Overlay.DataOverlay and flags.GeoModel.Run is LHCPeriod.Run3)
53
54 if flags.Input.MCChannelNumber > 0:
55 kwargs.setdefault("MCChannelNumber", flags.Input.MCChannelNumber)
56
57 # Do the xAOD::EventInfo overlay
58 acc.addEventAlgo(CompFactory.xAODMaker.EventInfoOverlay(name, **kwargs))
59
60 # Add output
61 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
62 if flags.Output.doWriteRDO:
63 acc.merge(OutputStreamCfg(flags, "RDO"))
64
65 # Add signal output
66 if flags.Output.doWriteRDO_SGNL:
67 acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[
68 f"xAOD::EventInfo#{flags.Overlay.SigPrefix}EventInfo",
69 f"xAOD::EventAuxInfo#{flags.Overlay.SigPrefix}EventInfoAux."
70 ]))
71
72 return acc
73
74
75def EventInfoOverlayCfg(flags, **kwargs):
76 """Return a ComponentAccumulator for the full EventInfoOverlay algorithm accumulator"""
77
78 acc = ComponentAccumulator()
79 inputs = [f"xAOD::EventInfo#{flags.Overlay.BkgPrefix}EventInfo"]
80 # Check if running on legacy HITS
81 if "EventInfo" not in flags.Input.Collections and "EventInfo" not in flags.Input.SecondaryCollections:
82 acc.merge(EventInfoCnvAlgCfg(flags,
83 inputKey=f"{flags.Overlay.SigPrefix}McEventInfo",
84 outputKey=f"{flags.Overlay.SigPrefix}EventInfo",
85 **kwargs))
86 # Re-map signal address
87 from SGComps.AddressRemappingConfig import AddressRemappingCfg
88 acc.merge(AddressRemappingCfg([
89 f"EventInfo#McEventInfo->{flags.Overlay.SigPrefix}McEventInfo",
90 ]))
91
92 inputs.append(f"EventInfo#{flags.Overlay.SigPrefix}McEventInfo")
93 else:
94 # Re-map signal address
95 from SGComps.AddressRemappingConfig import AddressRemappingCfg
96 acc.merge(AddressRemappingCfg([
97 f"xAOD::EventInfo#EventInfo->{flags.Overlay.SigPrefix}EventInfo",
98 f"xAOD::EventAuxInfo#EventInfoAux.->{flags.Overlay.SigPrefix}EventInfoAux.",
99 ]))
100
101 inputs.append(f"xAOD::EventInfo#{flags.Overlay.SigPrefix}EventInfo")
102
103 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
104 acc.merge(SGInputLoaderCfg(flags, inputs))
105
106 acc.merge(EventInfoOverlayAlgCfg(flags, **kwargs))
107 return acc
108
109
110def EventInfoUpdateFromContextAlgCfg(flags, name="EventInfoUpdateFromContextAlg", disableBeamSpot=False, **kwargs):
111 """Return a ComponentAccumulator for EventInfoUpdateFromContext algorithm"""
112 acc = ComponentAccumulator()
113
114 # Add beam spot conditions
115 if not disableBeamSpot:
116 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
117 acc.merge(BeamSpotCondAlgCfg(flags))
118
119 kwargs.setdefault("SignalInputKey", "Input_EventInfo")
120 kwargs.setdefault("OutputKey", f"{flags.Overlay.SigPrefix}EventInfo" if flags.Common.ProductionStep == ProductionStep.FastChain and flags.Common.isOverlay else "EventInfo")
121
122 if flags.Input.MCChannelNumber > 0:
123 kwargs.setdefault("MCChannelNumber", flags.Input.MCChannelNumber)
124
125 if disableBeamSpot:
126 kwargs.setdefault("BeamSpotKey", "")
127
128 # Do the xAOD::EventInfo overlay
129 acc.addEventAlgo(CompFactory.xAODMaker.EventInfoUpdateFromContextAlg(name, **kwargs))
130
131 # Re-map signal address
132 from SGComps.AddressRemappingConfig import AddressRemappingCfg
133 acc.merge(AddressRemappingCfg([
134 "xAOD::EventInfo#EventInfo->" + "Input_EventInfo",
135 "xAOD::EventAuxInfo#EventInfoAux.->" + "Input_EventInfoAux.",
136 ]))
137
138 return acc
139
140
141def EventInfoBeamSpotDecoratorAlgCfg(flags, name="EventInfoBeamSpotDecoratorAlg", eventInfoKey="EventInfo", **kwargs):
142 result = ComponentAccumulator()
143
144 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
145 result.merge(BeamSpotCondAlgCfg(flags))
146
147 kwargs.setdefault("EventInfoKey", eventInfoKey)
148
149 result.addEventAlgo(CompFactory.xAODMaker.EventInfoBeamSpotDecoratorAlg(name, **kwargs))
150
151 return result
EventInfoCnvAlgCfg(flags, name="EventInfoCnvAlg", inputKey="McEventInfo", outputKey="EventInfo", disableBeamSpot=False, **kwargs)
EventInfoOverlayAlgCfg(flags, name="EventInfoOverlay", **kwargs)