ATLAS Offline Software
Loading...
Searching...
No Matches
InfileMetaDataConfig Namespace Reference

Classes

class  MetaDataHelperLists

Functions

 metadata_creator (func)
 createCutFlowMetaData (tools, result, flags, **kwargs)
 createByteStreamMetaData (tools, result, flags, **kwargs)
 createLumiBlockMetaData (tools, result, flags, **kwargs)
 createTriggerMenuMetaData (tools, result, flags, **kwargs)
 createTruthMetaData (tools, result, flags, **kwargs)
 createIOVMetaData (tools, result, flags, **kwargs)
 createEventStreamInfo (tools, result, flags, **kwargs)
 propagateMetaData (flags, streamName="", category=None)
 SetupMetaDataForStreamCfg (flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)

Variables

list defaultIOVFolders
dict excludeStreamToIOVFolders

Function Documentation

◆ createByteStreamMetaData()

InfileMetaDataConfig.createByteStreamMetaData ( tools,
result,
flags,
** kwargs )

Definition at line 87 of file InfileMetaDataConfig.py.

87def createByteStreamMetaData(tools, result, flags, **kwargs):
88 tools.mdItems += ["ByteStreamMetadataContainer#*"]
89 if flags.Input.Format == Format.BS and not flags.Common.isOnline:
90 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
91
92 result.merge(ByteStreamReadCfg(flags))
93
94
95@metadata_creator

◆ createCutFlowMetaData()

InfileMetaDataConfig.createCutFlowMetaData ( tools,
result,
flags,
** kwargs )

Definition at line 76 of file InfileMetaDataConfig.py.

76def createCutFlowMetaData(tools, result, flags, **kwargs):
77 from EventBookkeeperTools.EventBookkeeperToolsConfig import (
78 CutFlowOutputList,
79 CutFlowSvcCfg,
80 )
81
82 result.merge(CutFlowSvcCfg(flags))
83 tools.mdItems += CutFlowOutputList(flags)
84
85
86@metadata_creator

◆ createEventStreamInfo()

InfileMetaDataConfig.createEventStreamInfo ( tools,
result,
flags,
** kwargs )

Definition at line 147 of file InfileMetaDataConfig.py.

147def createEventStreamInfo(tools, result, flags, **kwargs):
148 esiTool = CompFactory.MakeEventStreamInfo(
149 f"{outputStreamName(kwargs.get('streamName', ''))}_MakeEventStreamInfo",
150 Key=outputStreamName(kwargs.get('streamName', '')),
151 DataHeaderKey=outputStreamName(kwargs.get('streamName', '')),
152 EventInfoKey=f"{flags.Overlay.BkgPrefix}EventInfo"
153 if flags.Common.ProductionStep
154 in [ProductionStep.PileUpPresampling, ProductionStep.PileUpPretracking, ProductionStep.MinbiasPreprocessing]
155 else "EventInfo",
156 )
157 tools.mdItems += [
158 f"EventStreamInfo#{outputStreamName(kwargs.get('streamName', ''))}",
159 ]
160 tools.helperTools.append(esiTool)
161

◆ createIOVMetaData()

InfileMetaDataConfig.createIOVMetaData ( tools,
result,
flags,
** kwargs )

Definition at line 132 of file InfileMetaDataConfig.py.

132def createIOVMetaData(tools, result, flags, **kwargs):
133 streamName = kwargs.get("streamName", "")
134 if streamName not in excludeStreamToIOVFolders:
135 tools.mdItems += ["IOVMetaDataContainer#*"]
136 else:
137 tools.mdItems += [
138 f"IOVMetaDataContainer#{folder}"
139 for folder in defaultIOVFolders
140 if folder not in excludeStreamToIOVFolders[streamName]
141 ]
142 from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg
143 result.merge(IOVDbSvcCfg(flags))
144
145
146@metadata_creator

◆ createLumiBlockMetaData()

InfileMetaDataConfig.createLumiBlockMetaData ( tools,
result,
flags,
** kwargs )

Definition at line 96 of file InfileMetaDataConfig.py.

96def createLumiBlockMetaData(tools, result, flags, **kwargs):
97 if flags.Input.Format == Format.BS and not flags.Common.isOnline:
98 from LumiBlockComps.CreateLumiBlockCollectionFromFileConfig import (
99 CreateLumiBlockCollectionFromFileCfg,
100 )
101
102 result.merge(CreateLumiBlockCollectionFromFileCfg(flags))
103 tools.mdItems += [
104 "xAOD::LumiBlockRangeContainer#*",
105 "xAOD::LumiBlockRangeAuxContainer#*",
106 ]
107
108
109@metadata_creator

◆ createTriggerMenuMetaData()

InfileMetaDataConfig.createTriggerMenuMetaData ( tools,
result,
flags,
** kwargs )

Definition at line 110 of file InfileMetaDataConfig.py.

110def createTriggerMenuMetaData(tools, result, flags, **kwargs):
111 tools.mdTools.append(
112 CompFactory.xAODMaker.TriggerMenuMetaDataTool("TriggerMenuMetaDataTool")
113 )
114 tools.mdItems += [
115 "xAOD::TriggerMenuContainer#*",
116 "xAOD::TriggerMenuAuxContainer#*",
117 "xAOD::TriggerMenuJsonContainer#*",
118 "xAOD::TriggerMenuJsonAuxContainer#*",
119 ]
120
121
122@metadata_creator

◆ createTruthMetaData()

InfileMetaDataConfig.createTruthMetaData ( tools,
result,
flags,
** kwargs )

Definition at line 123 of file InfileMetaDataConfig.py.

123def createTruthMetaData(tools, result, flags, **kwargs):
124 tools.mdItems += [
125 "xAOD::TruthMetaDataContainer#TruthMetaData",
126 "xAOD::TruthMetaDataAuxContainer#TruthMetaDataAux.",
127 ]
128 tools.mdTools.append(CompFactory.xAODMaker.TruthMetaDataTool("TruthMetaDataTool"))
129
130
131@metadata_creator

◆ metadata_creator()

InfileMetaDataConfig.metadata_creator ( func)
Decorator function which:
- creates default MetaDataHelperLists() and ComponentAccumulator() instances
- passes them to wrapped create*MetaData functions responsible for configuration of helper lists and CA, specific to metadata category
- returns configured instances of MetaDataHelperLists() (used by MetaDataSvc and AthenaOutputStream) and CA

Definition at line 57 of file InfileMetaDataConfig.py.

57def metadata_creator(func):
58 """
59 Decorator function which:
60 - creates default MetaDataHelperLists() and ComponentAccumulator() instances
61 - passes them to wrapped create*MetaData functions responsible for configuration of helper lists and CA, specific to metadata category
62 - returns configured instances of MetaDataHelperLists() (used by MetaDataSvc and AthenaOutputStream) and CA
63 """
64
65 @wraps(func)
66 def wrapper(*args, **kwargs):
67 tools = MetaDataHelperLists()
68 result = ComponentAccumulator()
69 func(tools, result, *args, **kwargs)
70 return tools, result
71
72 return wrapper
73
74
75@metadata_creator

◆ propagateMetaData()

InfileMetaDataConfig.propagateMetaData ( flags,
streamName = "",
category = None )
Returns the tuple of MetaDataHelperLists and ComponentAccumulator.
The former combines the lists needed to setup given metadata category
for the output stream configuration and metadata service.
The latter contains the CA needed for a given metadata category.

Definition at line 162 of file InfileMetaDataConfig.py.

162def propagateMetaData(flags, streamName="", category=None):
163 """
164 Returns the tuple of MetaDataHelperLists and ComponentAccumulator.
165 The former combines the lists needed to setup given metadata category
166 for the output stream configuration and metadata service.
167 The latter contains the CA needed for a given metadata category.
168 """
169 tools = MetaDataHelperLists()
170 result = ComponentAccumulator()
171 log = logging.getLogger("SetupMetaDataForStreamCfg")
172
173 if category == MetadataCategory.FileMetaData:
174 tools.mdToolNames.append("xAODMaker::FileMetaDataTool")
175 tools.mdItems += [
176 "xAOD::FileMetaData#FileMetaData",
177 "xAOD::FileMetaDataAuxInfo#FileMetaDataAux.",
178 ]
179 tools.helperTools.append(
180 CompFactory.xAODMaker.FileMetaDataCreatorTool(
181 f"{outputStreamName(streamName)}_FileMetaDataCreatorTool",
182 OutputKey="FileMetaData",
183 StreamName=outputStreamName(streamName),
184 EventInfoKey=f"{flags.Overlay.BkgPrefix}EventInfo"
185 if flags.Common.ProductionStep in [ProductionStep.PileUpPresampling, ProductionStep.PileUpPretracking, ProductionStep.MinbiasPreprocessing]
186 else "EventInfo",
187 )
188 )
189 elif category == MetadataCategory.EventStreamInfo:
190 tools.mdTools += [
191 CompFactory.CopyEventStreamInfo(
192 f"{outputStreamName(streamName)}_CopyEventStreamInfo",
193 Keys=[outputStreamName(streamName)],
194 ),
195 ]
196
197 elif category == MetadataCategory.EventFormat:
198 efTool = CompFactory.xAODMaker.EventFormatStreamHelperTool(
199 f"{outputStreamName(streamName)}_EventFormatStreamHelperTool",
200 Key=f"EventFormat{outputStreamName(streamName)}",
201 DataHeaderKey=outputStreamName(streamName),
202 )
203 tools.mdItems += [
204 f"xAOD::EventFormat#EventFormat{outputStreamName(streamName)}",
205 ]
206 tools.helperTools.append(efTool)
207 tools.mdToolNames.append("xAODMaker::EventFormatMetaDataTool")
208 elif category == MetadataCategory.CutFlowMetaData:
209 if "CutBookkeepers" in flags.Input.MetadataItems:
210 from EventBookkeeperTools.EventBookkeeperToolsConfig import (
211 CutFlowOutputList,
212 )
213
214 tools.mdToolNames.append("BookkeeperTool")
215 tools.mdItems += CutFlowOutputList(flags)
216
217 elif category == MetadataCategory.TriggerMenuMetaData:
218 if any("TriggerMenu" in item for item in flags.Input.MetadataItems):
219 _tools, _ = createTriggerMenuMetaData(flags)
220 tools.mdTools = _tools.mdTools
221 tools.mdItems = _tools.mdItems
222
223 elif category == MetadataCategory.TruthMetaData:
224 if "TruthMetaData" in flags.Input.MetadataItems:
225 tools.mdItems += [
226 "xAOD::TruthMetaDataContainer#TruthMetaData",
227 "xAOD::TruthMetaDataAuxContainer#TruthMetaDataAux.",
228 ]
229 tools.mdTools.append(
230 CompFactory.xAODMaker.TruthMetaDataTool("TruthMetaDataTool")
231 )
232 elif category == MetadataCategory.ByteStreamMetaData:
233 if "ByteStreamMetadata" in flags.Input.MetadataItems:
234 tools.mdItems += ["ByteStreamMetadataContainer#*"]
235 elif category == MetadataCategory.LumiBlockMetaData:
236 if any(
237 lb in flags.Input.MetadataItems
238 for lb in ["SuspectLumiBlocks", "IncompleteLumiBlocks", "LumiBlocks"]
239 ):
240 tools.mdToolNames.append("LumiBlockMetaDataTool")
241 tools.mdItems += [
242 "xAOD::LumiBlockRangeContainer#*",
243 "xAOD::LumiBlockRangeAuxContainer#*",
244 ]
245 elif category == MetadataCategory.IOVMetaData:
246 if "IOVMetaDataContainer" in flags.Input.MetadataItems.values():
247 if streamName not in excludeStreamToIOVFolders:
248 tools.mdItems += ["IOVMetaDataContainer#*"]
249 else:
250 tools.mdItems += [
251 f"IOVMetaDataContainer#{folder}"
252 for folder, container in flags.Input.MetadataItems.items()
253 if container == "IOVMetaDataContainer" and folder not in excludeStreamToIOVFolders[streamName]
254 ]
255
256 else:
257 log.warning(f"Requested metadata category: {category} could not be configured")
258 return tools, result
259
260

◆ SetupMetaDataForStreamCfg()

InfileMetaDataConfig.SetupMetaDataForStreamCfg ( flags,
streamName = "",
AcceptAlgs = None,
createMetadata = None,
propagateMetadataFromInput = True,
* args,
** kwargs )
Set up metadata for the stream named streamName

It takes optional arguments: createMetadata to specify a list of metadata
categories to create (empty by default) and propagateMetadataFromInput (bool)
to propagate metadata existing in the input (True by default).

The additional argument, AcceptAlgs, is needed for workflows with custom kernels.

Returns CA to be merged

Definition at line 261 of file InfileMetaDataConfig.py.

269):
270 """
271 Set up metadata for the stream named streamName
272
273 It takes optional arguments: createMetadata to specify a list of metadata
274 categories to create (empty by default) and propagateMetadataFromInput (bool)
275 to propagate metadata existing in the input (True by default).
276
277 The additional argument, AcceptAlgs, is needed for workflows with custom kernels.
278
279 Returns CA to be merged
280 """
281 log = logging.getLogger("SetupMetaDataForStreamCfg")
282 result = ComponentAccumulator()
283 if not isinstance(streamName, str) or not streamName:
284 return result
285 if AcceptAlgs is None:
286 AcceptAlgs = []
287 if createMetadata is None:
288 createMetadata = []
289 createMetadata += [MetadataCategory.EventStreamInfo]
290
291 helperLists = MetaDataHelperLists()
292
293 if propagateMetadataFromInput:
294 for mdCategory in MetadataCategory:
295 lists, caConfig = propagateMetaData(
296 flags,
297 streamName,
298 mdCategory,
299 )
300 helperLists += lists
301 result.merge(caConfig)
302
303 for md in createMetadata:
304 try:
305 lists, caConfig = globals()[f"create{md.name}"](
306 flags,
307 streamName=streamName,
308 )
309 except KeyError:
310 log.warning(
311 f"Requested metadata category: {md.name} could not be configured"
312 )
313 continue
314 helperLists += lists
315 result.merge(caConfig)
316
317 # Configure the relevant output stream
318 result.merge(
319 addToMetaData(
320 flags,
321 streamName=streamName,
322 itemOrList=helperLists.mdItems,
323 AcceptAlgs=AcceptAlgs,
324 HelperTools=helperLists.helperTools,
325 **kwargs,
326 )
327 )
328 # Configure the MetaDataSvc and pass the relevant tools
329 from AthenaServices.MetaDataSvcConfig import MetaDataSvcCfg
330
331 result.merge(
332 MetaDataSvcCfg(
333 flags, tools=helperLists.mdTools, toolNames=helperLists.mdToolNames
334 )
335 )
336 return result

Variable Documentation

◆ defaultIOVFolders

list InfileMetaDataConfig.defaultIOVFolders
Initial value:
1= [
2 "/Generation/Parameters",
3 "/GLOBAL/BField/Maps",
4 "/Simulation/Parameters",
5 "/Digitization/Parameters",
6 "/TagInfo",
7 "/TRIGGER/HLT/HltConfigKeys",
8 "/TRIGGER/HLT/Menu",
9 "/TRIGGER/HLT/PrescaleKey",
10 "/TRIGGER/HLT/Prescales",
11 "/TRIGGER/LVL1/ItemDef",
12 "/TRIGGER/LVL1/Lvl1ConfigKey",
13 "/TRIGGER/LVL1/Menu",
14 "/TRIGGER/LVL1/Prescales",
15 "/TRIGGER/LVL1/Thresholds",
16]

Definition at line 13 of file InfileMetaDataConfig.py.

◆ excludeStreamToIOVFolders

dict InfileMetaDataConfig.excludeStreamToIOVFolders
Initial value:
1= {
2 "HITS": [
3 "/Digitization/Parameters",
4 ],
5}

Definition at line 30 of file InfileMetaDataConfig.py.