16 MetadataItemList=None,
17 disableEventTag=False,
18 trigNavThinningSvc=None,
19 takeItemsFromInput=False,
20 extendProvenanceRecord=True,
21 keepProvenanceTagsRegEx=None,
24 CompressionListHigh=None,
25 CompressionListLow=None,
27 """Configure an output stream for writing data to POOL files.
30 flags: Configuration flags object
31 streamName: Name of the output stream (e.g., 'ESD', 'AOD', 'DAOD_PHYS')
32 ItemList: List of data objects to write to the stream
33 MetadataItemList: List of metadata objects to write
34 disableEventTag: If True, disable event tagging
35 trigNavThinningSvc: Trigger navigation thinning service
36 takeItemsFromInput: If True, take items from input file
37 extendProvenanceRecord: If True, extend provenance record with processing tags
38 keepProvenanceTagsRegEx: RegEx string to match processing tags in the Event provenance.
39 Only matching tags will be copied to the new DataHeader.
40 Empty string rejects all tags. Direct provenance is not affected
41 (see extendProvenanceRecord).
42 AcceptAlgs: List of algorithms that must accept the event for it to be written
43 HelperTools: List of helper tools to attach to the stream
44 CompressionListHigh: Aux container entries whose floats are stored with a truncated
45 mantissa, keeping CompressionBitsHigh bits (7 by default).
46 CompressionListLow: Aux container entries whose floats are stored with a truncated
47 mantissa, keeping CompressionBitsLow bits (15 by default).
51 ComponentAccumulator: Configured output stream and associated services
56 if MetadataItemList
is None:
58 if AcceptAlgs
is None:
60 if HelperTools
is None:
62 if CompressionListHigh
is None:
63 CompressionListHigh = []
64 if CompressionListLow
is None:
65 CompressionListLow = []
67 eventInfoKey =
"EventInfo"
68 if flags.Common.ProductionStep
in [ProductionStep.PileUpPresampling, ProductionStep.PileUpPretracking, ProductionStep.MinbiasPreprocessing]:
69 eventInfoKey = f
"{flags.Overlay.BkgPrefix}EventInfo"
71 msg = logging.getLogger(
"OutputStreamCfg")
72 flagName = f
"Output.{streamName}FileName"
73 if flags.hasFlag(flagName):
74 fileName = flags._get(flagName)
76 fileName = f
"my{streamName}.pool.root"
77 msg.info(
"No file name predefined for stream %s. Using %s", streamName, fileName)
79 if fileName
in flags.Input.Files:
80 raise ConfigurationError(
"Same name for input and output file %s" % fileName)
82 result = ComponentAccumulator(sequence = CompFactory.AthSequencer(
"AthOutSeq", StopOverride=
True))
85 from AthenaPoolCnvSvc.PoolWriteConfig
import PoolWriteCfg
86 result.merge(PoolWriteCfg(flags))
89 writingTool = CompFactory.AthenaOutputStreamTool(
90 f
"{outputStreamName(streamName)}Tool",
92 TopLevelContainerName=
"",
93 SubLevelBranchName=
"<type>/<key>",
94 ConversionService=
"AthenaPoolSharedIOCnvSvc" if flags.MP.UseSharedReader
or flags.MP.UseSharedWriter
else "AthenaPoolCnvSvc",
98 parentStream = f
"Output.{streamName}ParentStream"
99 childStream = f
"Output.{streamName}ChildStream"
100 if flags.hasFlag(childStream):
101 writingTool.SaveDecisions =
True
102 elif flags.hasFlag(parentStream):
103 disableEventTag =
True
104 writingTool.OutputCollection = f
"POOLContainer_{streamName}"
105 writingTool.PoolContainerPrefix = f
"CollectionTree_{streamName}"
106 writingTool.MetaDataOutputCollection = f
"MetaDataHdr_{streamName}"
107 writingTool.MetaDataPoolContainerPrefix = f
"MetaData_{streamName}"
108 msg.info(
"Stream %s running in augmentation mode with %s as parent", streamName, flags._get(parentStream))
113 if any(name
in streamName
for name
in {
"DAOD_",
"D2AOD_"}):
114 finalItemList = ItemList
116 finalItemList = [f
"xAOD::EventInfo#{eventInfoKey}", f
"xAOD::EventAuxInfo#{eventInfoKey}Aux."] + ItemList
118 outputStream = CompFactory.AthenaOutputStream(
121 WritingTool=writingTool,
122 ItemList=finalItemList,
123 MetadataItemList=MetadataItemList,
125 HelperTools=HelperTools,
127 if takeItemsFromInput:
131 outputStream.TakeItemsFromInput =
True
132 if not extendProvenanceRecord:
135 outputStream.ExtendProvenanceRecord =
False
136 if keepProvenanceTagsRegEx
is not None:
138 outputStream.KeepProvenanceTagsRegEx = keepProvenanceTagsRegEx
139 outputStream.AcceptAlgs += AcceptAlgs
140 if CompressionListHigh:
141 outputStream.CompressionListHigh += CompressionListHigh
142 if CompressionListLow:
143 outputStream.CompressionListLow += CompressionListLow
144 outputStream.ExtraOutputs.add((
"DataHeader", f
"StoreGateSvc+{outputStreamName(streamName)}"))
145 if flags.Scheduler.CheckOutputUsage
and flags.Concurrency.NumThreads > 0:
146 outputStream.ExtraInputs = {tuple(l.split(
'#'))
for l
in finalItemList
if '*' not in l
and 'Aux' not in l}
148 from AthenaConfiguration.MainServicesConfig
import OutputUsageIgnoreCfg
149 result.merge(OutputUsageIgnoreCfg(flags, outputStream.name))
151 result.addService(CompFactory.StoreGateSvc(
"MetaDataStore"))
152 outputStream.MetadataStore = result.getService(
"MetaDataStore")
155 thinningCacheTool = CompFactory.Athena.ThinningCacheTool(f
"ThinningCacheTool_Stream{streamName}",
157 if trigNavThinningSvc
is not None:
158 thinningCacheTool.TrigNavigationThinningSvc = trigNavThinningSvc
159 outputStream.HelperTools.append(thinningCacheTool)
162 if not disableEventTag:
164 outputStream.WritingTool.AttributeListKey=key
166 propagateInputAttributeList =
False
167 if "AthenaAttributeList#Input" in flags.Input.TypedCollections:
168 from SGComps.SGInputLoaderConfig
import SGInputLoaderCfg
169 result.merge(SGInputLoaderCfg(flags, [
"AthenaAttributeList#Input"]))
170 propagateInputAttributeList =
True
173 tagBuilder = CompFactory.EventInfoTagBuilder(AttributeList=key,
174 Tool=CompFactory.EventInfoAttListTool(),
175 EventInfoKey=eventInfoKey,
176 PropagateInput=propagateInputAttributeList)
177 result.addEventAlgo(tagBuilder)
180 if "AOD" in streamName:
181 outputStream.WritingTool.SubLevelBranchName =
"<key>"
183 result.addEventAlgo(outputStream, domain=
'IO')
213def addToMetaData(flags, streamName, itemOrList, AcceptAlgs=[], HelperTools=[], **kwargs):
215 Adds Metadata items to the stream named streamName
217 Similar to addToESD/AOD, itemOrList can be either a list of items or just one time
218 The additional arguments, AcceptAlgs and HelperTools, are passed to the underlying stream
219 The former is needed when there are special kernels, e.g., simulation/derivation
220 The latter is needed primarily for the propagation of the FileMetaData tool
222 Returns CA to be merged
224 flagName = f
"Output.doWrite{streamName}"
225 if not flags.hasFlag(flagName):
226 return ComponentAccumulator()
227 items = [itemOrList]
if isinstance(itemOrList, str)
else itemOrList
229 AcceptAlgs=AcceptAlgs, HelperTools=HelperTools, **kwargs)
OutputStreamCfg(flags, streamName, ItemList=None, MetadataItemList=None, disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, keepProvenanceTagsRegEx=None, AcceptAlgs=None, HelperTools=None, CompressionListHigh=None, CompressionListLow=None)