9from AthenaConfiguration.Enums
import Format, MetadataCategory, ProductionStep
97 if flags.Input.Format == Format.BS
and not flags.Common.isOnline:
98 from LumiBlockComps.CreateLumiBlockCollectionFromFileConfig
import (
99 CreateLumiBlockCollectionFromFileCfg,
102 result.merge(CreateLumiBlockCollectionFromFileCfg(flags))
104 "xAOD::LumiBlockRangeContainer#*",
105 "xAOD::LumiBlockRangeAuxContainer#*",
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]
158 f
"EventStreamInfo#{outputStreamName(kwargs.get('streamName', ''))}",
160 tools.helperTools.append(esiTool)
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.
170 result = ComponentAccumulator()
171 log = logging.getLogger(
"SetupMetaDataForStreamCfg")
173 if category == MetadataCategory.FileMetaData:
174 tools.mdToolNames.append(
"xAODMaker::FileMetaDataTool")
176 "xAOD::FileMetaData#FileMetaData",
177 "xAOD::FileMetaDataAuxInfo#FileMetaDataAux.",
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]
189 elif category == MetadataCategory.EventStreamInfo:
191 CompFactory.CopyEventStreamInfo(
192 f
"{outputStreamName(streamName)}_CopyEventStreamInfo",
193 Keys=[outputStreamName(streamName)],
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),
204 f
"xAOD::EventFormat#EventFormat{outputStreamName(streamName)}",
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 (
214 tools.mdToolNames.append(
"BookkeeperTool")
215 tools.mdItems += CutFlowOutputList(flags)
217 elif category == MetadataCategory.TriggerMenuMetaData:
218 if any(
"TriggerMenu" in item
for item
in flags.Input.MetadataItems):
220 tools.mdTools = _tools.mdTools
221 tools.mdItems = _tools.mdItems
223 elif category == MetadataCategory.TruthMetaData:
224 if "TruthMetaData" in flags.Input.MetadataItems:
226 "xAOD::TruthMetaDataContainer#TruthMetaData",
227 "xAOD::TruthMetaDataAuxContainer#TruthMetaDataAux.",
229 tools.mdTools.append(
230 CompFactory.xAODMaker.TruthMetaDataTool(
"TruthMetaDataTool")
232 elif category == MetadataCategory.ByteStreamMetaData:
233 if "ByteStreamMetadata" in flags.Input.MetadataItems:
234 tools.mdItems += [
"ByteStreamMetadataContainer#*"]
235 elif category == MetadataCategory.LumiBlockMetaData:
237 lb
in flags.Input.MetadataItems
238 for lb
in [
"SuspectLumiBlocks",
"IncompleteLumiBlocks",
"LumiBlocks"]
240 tools.mdToolNames.append(
"LumiBlockMetaDataTool")
242 "xAOD::LumiBlockRangeContainer#*",
243 "xAOD::LumiBlockRangeAuxContainer#*",
245 elif category == MetadataCategory.IOVMetaData:
246 if "IOVMetaDataContainer" in flags.Input.MetadataItems.values():
247 if streamName
not in excludeStreamToIOVFolders:
248 tools.mdItems += [
"IOVMetaDataContainer#*"]
251 f
"IOVMetaDataContainer#{folder}"
252 for folder, container
in flags.Input.MetadataItems.items()
253 if container ==
"IOVMetaDataContainer" and folder
not in excludeStreamToIOVFolders[streamName]
257 log.warning(f
"Requested metadata category: {category} could not be configured")
266 propagateMetadataFromInput=True,
271 Set up metadata for the stream named streamName
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).
277 The additional argument, AcceptAlgs, is needed for workflows with custom kernels.
279 Returns CA to be merged
281 log = logging.getLogger(
"SetupMetaDataForStreamCfg")
282 result = ComponentAccumulator()
283 if not isinstance(streamName, str)
or not streamName:
285 if AcceptAlgs
is None:
287 if createMetadata
is None:
289 createMetadata += [MetadataCategory.EventStreamInfo]
293 if propagateMetadataFromInput:
294 for mdCategory
in MetadataCategory:
301 result.merge(caConfig)
303 for md
in createMetadata:
305 lists, caConfig = globals()[f
"create{md.name}"](
307 streamName=streamName,
311 f
"Requested metadata category: {md.name} could not be configured"
315 result.merge(caConfig)
321 streamName=streamName,
322 itemOrList=helperLists.mdItems,
323 AcceptAlgs=AcceptAlgs,
324 HelperTools=helperLists.helperTools,
329 from AthenaServices.MetaDataSvcConfig
import MetaDataSvcCfg
333 flags, tools=helperLists.mdTools, toolNames=helperLists.mdToolNames