9from AthenaConfiguration.Enums
import Format, MetadataCategory, ProductionStep
10from OutputStreamAthenaPool.OutputStreamConfig
import addToMetaData, outputStreamName
53 from EventBookkeeperTools.EventBookkeeperToolsConfig
import (
58 result.merge(CutFlowSvcCfg(flags))
59 tools.mdItems += CutFlowOutputList(flags)
64 tools.mdItems += [
"ByteStreamMetadataContainer#*"]
65 if flags.Input.Format == Format.BS
and not flags.Common.isOnline:
66 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
68 result.merge(ByteStreamReadCfg(flags))
73 if flags.Input.Format == Format.BS
and not flags.Common.isOnline:
74 from LumiBlockComps.CreateLumiBlockCollectionFromFileConfig
import (
75 CreateLumiBlockCollectionFromFileCfg,
78 result.merge(CreateLumiBlockCollectionFromFileCfg(flags))
80 "xAOD::LumiBlockRangeContainer#*",
81 "xAOD::LumiBlockRangeAuxContainer#*",
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]
126 f
"EventStreamInfo#{outputStreamName(kwargs.get('streamName', ''))}",
128 tools.helperTools.append(esiTool)
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.
138 result = ComponentAccumulator()
139 log = logging.getLogger(
"SetupMetaDataForStreamCfg")
141 if category == MetadataCategory.FileMetaData:
142 tools.mdToolNames.append(
"xAODMaker::FileMetaDataTool")
144 "xAOD::FileMetaData#FileMetaData",
145 "xAOD::FileMetaDataAuxInfo#FileMetaDataAux.",
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]
157 elif category == MetadataCategory.EventStreamInfo:
159 CompFactory.CopyEventStreamInfo(
160 f
"{outputStreamName(streamName)}_CopyEventStreamInfo",
161 Keys=[outputStreamName(streamName)],
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),
172 f
"xAOD::EventFormat#EventFormat{outputStreamName(streamName)}",
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 (
182 tools.mdToolNames.append(
"BookkeeperTool")
183 tools.mdItems += CutFlowOutputList(flags)
185 elif category == MetadataCategory.TriggerMenuMetaData:
186 if any(
"TriggerMenu" in item
for item
in flags.Input.MetadataItems):
188 tools.mdTools = _tools.mdTools
189 tools.mdItems = _tools.mdItems
191 elif category == MetadataCategory.TruthMetaData:
192 if "TruthMetaData" in flags.Input.MetadataItems:
194 "xAOD::TruthMetaDataContainer#TruthMetaData",
195 "xAOD::TruthMetaDataAuxContainer#TruthMetaDataAux.",
197 tools.mdTools.append(
198 CompFactory.xAODMaker.TruthMetaDataTool(
"TruthMetaDataTool")
200 elif category == MetadataCategory.ByteStreamMetaData:
201 if "ByteStreamMetadata" in flags.Input.MetadataItems:
202 tools.mdItems += [
"ByteStreamMetadataContainer#*"]
203 elif category == MetadataCategory.LumiBlockMetaData:
205 lb
in flags.Input.MetadataItems
206 for lb
in [
"SuspectLumiBlocks",
"IncompleteLumiBlocks",
"LumiBlocks"]
208 tools.mdToolNames.append(
"LumiBlockMetaDataTool")
210 "xAOD::LumiBlockRangeContainer#*",
211 "xAOD::LumiBlockRangeAuxContainer#*",
213 elif category == MetadataCategory.IOVMetaData:
214 if "IOVMetaDataContainer" in flags.Input.MetadataItems.values():
215 tools.mdItems += [
"IOVMetaDataContainer#*"]
218 log.warning(f
"Requested metadata category: {category} could not be configured")
227 propagateMetadataFromInput=True,
232 Set up metadata for the stream named streamName
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).
238 The additional argument, AcceptAlgs, is needed for workflows with custom kernels.
240 Returns CA to be merged
242 log = logging.getLogger(
"SetupMetaDataForStreamCfg")
243 result = ComponentAccumulator()
244 if not isinstance(streamName, str)
or not streamName:
246 if AcceptAlgs
is None:
248 if createMetadata
is None:
250 createMetadata += [MetadataCategory.EventStreamInfo]
254 if propagateMetadataFromInput:
255 for mdCategory
in MetadataCategory:
262 result.merge(caConfig)
264 for md
in createMetadata:
266 lists, caConfig = globals()[f
"create{md.name}"](
268 streamName=streamName,
272 f
"Requested metadata category: {md.name} could not be configured"
276 result.merge(caConfig)
282 streamName=streamName,
283 itemOrList=helperLists.mdItems,
284 AcceptAlgs=AcceptAlgs,
285 HelperTools=helperLists.helperTools,
290 from AthenaServices.MetaDataSvcConfig
import MetaDataSvcCfg
294 flags, tools=helperLists.mdTools, toolNames=helperLists.mdToolNames