ATLAS Offline Software
Classes | Functions
InfileMetaDataConfig Namespace Reference

Classes

class  MetaDataHelperLists
 

Functions

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

Function Documentation

◆ createByteStreamMetaData()

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

Definition at line 63 of file InfileMetaDataConfig.py.

63 def createByteStreamMetaData(tools, result, flags, **kwargs):
64  tools.mdItems += ["ByteStreamMetadataContainer#*"]
65  if flags.Input.Format == Format.BS and not flags.Common.isOnline:
66  from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
67 
68  result.merge(ByteStreamReadCfg(flags))
69 
70 
71 @metadata_creator

◆ createCutFlowMetaData()

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

Definition at line 52 of file InfileMetaDataConfig.py.

52 def createCutFlowMetaData(tools, result, flags, **kwargs):
53  from EventBookkeeperTools.EventBookkeeperToolsConfig import (
54  CutFlowOutputList,
55  CutFlowSvcCfg,
56  )
57 
58  result.merge(CutFlowSvcCfg(flags))
59  tools.mdItems += CutFlowOutputList(flags)
60 
61 
62 @metadata_creator

◆ createEventStreamInfo()

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

Definition at line 115 of file InfileMetaDataConfig.py.

115 def createEventStreamInfo(tools, result, flags, **kwargs):
116  esiTool = CompFactory.MakeEventStreamInfo(
117  f"{outputStreamName(kwargs.get('streamName', ''))}_MakeEventStreamInfo",
118  Key=outputStreamName(kwargs.get('streamName', '')),
119  DataHeaderKey=outputStreamName(kwargs.get('streamName', '')),
120  EventInfoKey=f"{flags.Overlay.BkgPrefix}EventInfo"
121  if flags.Common.ProductionStep
122  in [ProductionStep.PileUpPresampling, ProductionStep.PileUpPretracking, ProductionStep.MinbiasPreprocessing]
123  else "EventInfo",
124  )
125  tools.mdItems += [
126  f"EventStreamInfo#{outputStreamName(kwargs.get('streamName', ''))}",
127  ]
128  tools.helperTools.append(esiTool)
129 

◆ createIOVMetaData()

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

Definition at line 108 of file InfileMetaDataConfig.py.

108 def createIOVMetaData(tools, result, flags, **kwargs):
109  tools.mdItems += ["IOVMetaDataContainer#*"]
110  from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg
111  result.merge(IOVDbSvcCfg(flags))
112 
113 
114 @metadata_creator

◆ createLumiBlockMetaData()

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

Definition at line 72 of file InfileMetaDataConfig.py.

72 def createLumiBlockMetaData(tools, result, flags, **kwargs):
73  if flags.Input.Format == Format.BS and not flags.Common.isOnline:
74  from LumiBlockComps.CreateLumiBlockCollectionFromFileConfig import (
75  CreateLumiBlockCollectionFromFileCfg,
76  )
77 
78  result.merge(CreateLumiBlockCollectionFromFileCfg(flags))
79  tools.mdItems += [
80  "xAOD::LumiBlockRangeContainer#*",
81  "xAOD::LumiBlockRangeAuxContainer#*",
82  ]
83 
84 
85 @metadata_creator

◆ createTriggerMenuMetaData()

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

Definition at line 86 of file InfileMetaDataConfig.py.

86 def createTriggerMenuMetaData(tools, result, flags, **kwargs):
87  tools.mdTools.append(
88  CompFactory.xAODMaker.TriggerMenuMetaDataTool("TriggerMenuMetaDataTool")
89  )
90  tools.mdItems += [
91  "xAOD::TriggerMenuContainer#*",
92  "xAOD::TriggerMenuAuxContainer#*",
93  "xAOD::TriggerMenuJsonContainer#*",
94  "xAOD::TriggerMenuJsonAuxContainer#*",
95  ]
96 
97 
98 @metadata_creator

◆ createTruthMetaData()

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

Definition at line 99 of file InfileMetaDataConfig.py.

99 def createTruthMetaData(tools, result, flags, **kwargs):
100  tools.mdItems += [
101  "xAOD::TruthMetaDataContainer#TruthMetaData",
102  "xAOD::TruthMetaDataAuxContainer#TruthMetaDataAux.",
103  ]
104  tools.mdTools.append(CompFactory.xAODMaker.TruthMetaDataTool("TruthMetaDataTool"))
105 
106 
107 @metadata_creator

◆ metadata_creator()

def 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 33 of file InfileMetaDataConfig.py.

33 def metadata_creator(func):
34  """
35  Decorator function which:
36  - creates default MetaDataHelperLists() and ComponentAccumulator() instances
37  - passes them to wrapped create*MetaData functions responsible for configuration of helper lists and CA, specific to metadata category
38  - returns configured instances of MetaDataHelperLists() (used by MetaDataSvc and AthenaOutputStream) and CA
39  """
40 
41  @wraps(func)
42  def wrapper(*args, **kwargs):
43  tools = MetaDataHelperLists()
44  result = ComponentAccumulator()
45  func(tools, result, *args, **kwargs)
46  return tools, result
47 
48  return wrapper
49 
50 
51 @metadata_creator

◆ propagateMetaData()

def 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 130 of file InfileMetaDataConfig.py.

130 def propagateMetaData(flags, streamName="", category=None):
131  """
132  Returns the tuple of MetaDataHelperLists and ComponentAccumulator.
133  The former combines the lists needed to setup given metadata category
134  for the output stream configuration and metadata service.
135  The latter contains the CA needed for a given metadata category.
136  """
137  tools = MetaDataHelperLists()
138  result = ComponentAccumulator()
139  log = logging.getLogger("SetupMetaDataForStreamCfg")
140 
141  if category == MetadataCategory.FileMetaData:
142  tools.mdToolNames.append("xAODMaker::FileMetaDataTool")
143  tools.mdItems += [
144  "xAOD::FileMetaData#FileMetaData",
145  "xAOD::FileMetaDataAuxInfo#FileMetaDataAux.",
146  ]
147  tools.helperTools.append(
148  CompFactory.xAODMaker.FileMetaDataCreatorTool(
149  f"{outputStreamName(streamName)}_FileMetaDataCreatorTool",
150  OutputKey="FileMetaData",
151  StreamName=outputStreamName(streamName),
152  EventInfoKey=f"{flags.Overlay.BkgPrefix}EventInfo"
153  if flags.Common.ProductionStep in [ProductionStep.PileUpPresampling, ProductionStep.PileUpPretracking, ProductionStep.MinbiasPreprocessing]
154  else "EventInfo",
155  )
156  )
157  elif category == MetadataCategory.EventStreamInfo:
158  tools.mdTools += [
159  CompFactory.CopyEventStreamInfo(
160  f"{outputStreamName(streamName)}_CopyEventStreamInfo",
161  Keys=[outputStreamName(streamName)],
162  ),
163  ]
164 
165  elif category == MetadataCategory.EventFormat:
166  efTool = CompFactory.xAODMaker.EventFormatStreamHelperTool(
167  f"{outputStreamName(streamName)}_EventFormatStreamHelperTool",
168  Key=f"EventFormat{outputStreamName(streamName)}",
169  DataHeaderKey=outputStreamName(streamName),
170  )
171  tools.mdItems += [
172  f"xAOD::EventFormat#EventFormat{outputStreamName(streamName)}",
173  ]
174  tools.helperTools.append(efTool)
175  tools.mdToolNames.append("xAODMaker::EventFormatMetaDataTool")
176  elif category == MetadataCategory.CutFlowMetaData:
177  if "CutBookkeepers" in flags.Input.MetadataItems:
178  from EventBookkeeperTools.EventBookkeeperToolsConfig import (
179  CutFlowOutputList,
180  )
181 
182  tools.mdToolNames.append("BookkeeperTool")
183  tools.mdItems += CutFlowOutputList(flags)
184 
185  elif category == MetadataCategory.TriggerMenuMetaData:
186  if any("TriggerMenu" in item for item in flags.Input.MetadataItems):
187  _tools, _ = createTriggerMenuMetaData(flags)
188  tools.mdTools = _tools.mdTools
189  tools.mdItems = _tools.mdItems
190 
191  elif category == MetadataCategory.TruthMetaData:
192  if "TruthMetaData" in flags.Input.MetadataItems:
193  tools.mdItems += [
194  "xAOD::TruthMetaDataContainer#TruthMetaData",
195  "xAOD::TruthMetaDataAuxContainer#TruthMetaDataAux.",
196  ]
197  tools.mdTools.append(
198  CompFactory.xAODMaker.TruthMetaDataTool("TruthMetaDataTool")
199  )
200  elif category == MetadataCategory.ByteStreamMetaData:
201  if "ByteStreamMetadata" in flags.Input.MetadataItems:
202  tools.mdItems += ["ByteStreamMetadataContainer#*"]
203  elif category == MetadataCategory.LumiBlockMetaData:
204  if any(
205  lb in flags.Input.MetadataItems
206  for lb in ["SuspectLumiBlocks", "IncompleteLumiBlocks", "LumiBlocks"]
207  ):
208  tools.mdToolNames.append("LumiBlockMetaDataTool")
209  tools.mdItems += [
210  "xAOD::LumiBlockRangeContainer#*",
211  "xAOD::LumiBlockRangeAuxContainer#*",
212  ]
213  elif category == MetadataCategory.IOVMetaData:
214  if "IOVMetaDataContainer" in flags.Input.MetadataItems.values():
215  tools.mdItems += ["IOVMetaDataContainer#*"]
216 
217  else:
218  log.warning(f"Requested metadata category: {category} could not be configured")
219  return tools, result
220 
221 

◆ SetupMetaDataForStreamCfg()

def 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 222 of file InfileMetaDataConfig.py.

223  flags,
224  streamName="",
225  AcceptAlgs=None,
226  createMetadata=None,
227  propagateMetadataFromInput=True,
228  *args,
229  **kwargs,
230 ):
231  """
232  Set up metadata for the stream named streamName
233 
234  It takes optional arguments: createMetadata to specify a list of metadata
235  categories to create (empty by default) and propagateMetadataFromInput (bool)
236  to propagate metadata existing in the input (True by default).
237 
238  The additional argument, AcceptAlgs, is needed for workflows with custom kernels.
239 
240  Returns CA to be merged
241  """
242  log = logging.getLogger("SetupMetaDataForStreamCfg")
243  result = ComponentAccumulator()
244  if not isinstance(streamName, str) or not streamName:
245  return result
246  if AcceptAlgs is None:
247  AcceptAlgs = []
248  if createMetadata is None:
249  createMetadata = []
250  createMetadata += [MetadataCategory.EventStreamInfo]
251 
252  helperLists = MetaDataHelperLists()
253 
254  if propagateMetadataFromInput:
255  for mdCategory in MetadataCategory:
256  lists, caConfig = propagateMetaData(
257  flags,
258  streamName,
259  mdCategory,
260  )
261  helperLists += lists
262  result.merge(caConfig)
263 
264  for md in createMetadata:
265  try:
266  lists, caConfig = globals()[f"create{md.name}"](
267  flags,
268  streamName=streamName,
269  )
270  except KeyError:
271  log.warning(
272  f"Requested metadata category: {md.name} could not be configured"
273  )
274  continue
275  helperLists += lists
276  result.merge(caConfig)
277 
278  # Configure the relevant output stream
279  result.merge(
281  flags,
282  streamName=streamName,
283  itemOrList=helperLists.mdItems,
284  AcceptAlgs=AcceptAlgs,
285  HelperTools=helperLists.helperTools,
286  **kwargs,
287  )
288  )
289  # Configure the MetaDataSvc and pass the relevant tools
290  from AthenaServices.MetaDataSvcConfig import MetaDataSvcCfg
291 
292  result.merge(
294  flags, tools=helperLists.mdTools, toolNames=helperLists.mdToolNames
295  )
296  )
297  return result
python.CreateLumiBlockCollectionFromFileConfig.CreateLumiBlockCollectionFromFileCfg
def CreateLumiBlockCollectionFromFileCfg(configFlags)
Definition: CreateLumiBlockCollectionFromFileConfig.py:6
AthenaPoolExample_WriteCond.outputStreamName
string outputStreamName
Definition: AthenaPoolExample_WriteCond.py:21
python.OutputStreamConfig.addToMetaData
def addToMetaData(flags, streamName, itemOrList, AcceptAlgs=[], HelperTools=[], **kwargs)
Definition: OutputStreamConfig.py:153
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
InfileMetaDataConfig.propagateMetaData
def propagateMetaData(flags, streamName="", category=None)
Definition: InfileMetaDataConfig.py:130
InfileMetaDataConfig.createIOVMetaData
def createIOVMetaData(tools, result, flags, **kwargs)
Definition: InfileMetaDataConfig.py:108
python.EventBookkeeperToolsConfig.CutFlowOutputList
def CutFlowOutputList(flags, output_name='CutBookkeepers')
Definition: EventBookkeeperToolsConfig.py:44
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
InfileMetaDataConfig.createByteStreamMetaData
def createByteStreamMetaData(tools, result, flags, **kwargs)
Definition: InfileMetaDataConfig.py:63
InfileMetaDataConfig.createLumiBlockMetaData
def createLumiBlockMetaData(tools, result, flags, **kwargs)
Definition: InfileMetaDataConfig.py:72
InfileMetaDataConfig.createEventStreamInfo
def createEventStreamInfo(tools, result, flags, **kwargs)
Definition: InfileMetaDataConfig.py:115
InfileMetaDataConfig.createTruthMetaData
def createTruthMetaData(tools, result, flags, **kwargs)
Definition: InfileMetaDataConfig.py:99
python.IOVDbSvcConfig.IOVDbSvcCfg
def IOVDbSvcCfg(flags, **kwargs)
Definition: IOVDbSvcConfig.py:19
python.MetaDataSvcConfig.MetaDataSvcCfg
def MetaDataSvcCfg(flags, toolNames=[], tools=[])
Definition: MetaDataSvcConfig.py:6
InfileMetaDataConfig.metadata_creator
def metadata_creator(func)
Definition: InfileMetaDataConfig.py:33
InfileMetaDataConfig.createTriggerMenuMetaData
def createTriggerMenuMetaData(tools, result, flags, **kwargs)
Definition: InfileMetaDataConfig.py:86
InfileMetaDataConfig.createCutFlowMetaData
def createCutFlowMetaData(tools, result, flags, **kwargs)
Definition: InfileMetaDataConfig.py:52
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:222
python.EventBookkeeperToolsConfig.CutFlowSvcCfg
def CutFlowSvcCfg(flags, **kwargs)
Definition: EventBookkeeperToolsConfig.py:24