27 """Set up to read from a bytestream file
29 The function adds the components required to read events and metadata from
30 bytestream input. May be used to read events from a secondary input as well
34 flags: Job configuration flags
35 type_names: (optional) specific type names for address provider to find
38 A component accumulator fragment containing the components required to
39 read from bytestream. Should be merged into main job configuration.
41 result = ComponentAccumulator()
43 bytestream_conversion = CompFactory.ByteStreamCnvSvc(
44 IsSimulation=flags.Input.isMC,
46 result.addService(bytestream_conversion)
50 mcEventInfoTool = CompFactory.MCEventInfoByteStreamTool(
51 name=
"MCEventInfoByteStreamTool",
55 result.addPublicTool(mcEventInfoTool)
57 result.merge(SGInputLoaderCfg(flags, [(
'ByteStreamMetadataContainer',
'InputMetaDataStore+ByteStreamMetadata')]))
60 if flags.Common.isOnline
and not any(flags.Input.Files)
and not (flags.Trigger.doHLT
or flags.Trigger.doLVL1):
61 bytestream_input = CompFactory.ByteStreamEmonInputSvc(
"ByteStreamInputSvc")
63 eiName =
"{}EventInfo".format(flags.Overlay.BkgPrefix
if flags.Common.ProductionStep
is ProductionStep.MinbiasPreprocessing
else "")
64 bytestream_input = CompFactory.ByteStreamEventStorageInputSvc(
65 name=
"ByteStreamInputSvc",
67 result.addService(bytestream_input)
69 if flags.Input.SecondaryFiles:
70 event_selector = CompFactory.EventSelectorByteStream(
71 name=
"SecondaryEventSelector",
73 Input=flags.Input.SecondaryFiles,
74 SkipEvents=flags.Exec.SkipEvents
if flags.Overlay.SkipSecondaryEvents >= 0
else flags.Exec.SkipEvents,
75 ByteStreamInputSvc=bytestream_input.name,
77 result.addService(event_selector)
79 event_selector = CompFactory.EventSelectorByteStream(
81 Input=flags.Input.Files,
82 SkipEvents=flags.Exec.SkipEvents,
83 ByteStreamInputSvc=bytestream_input.name,
85 result.addService(event_selector)
86 result.setAppProperty(
"EvtSel", event_selector.name)
88 event_persistency = CompFactory.EvtPersistencySvc(
89 name=
"EventPersistencySvc", CnvServices=[bytestream_conversion.name]
91 result.addService(event_persistency)
93 result.addService(CompFactory.ROBDataProviderSvc())
95 address_provider = CompFactory.ByteStreamAddressProviderSvc(
96 TypeNames=type_names
if type_names
else list(),
98 result.addService(address_provider)
101 MetaDataSvcCfg(flags, [
"IOVDbMetaDataTool",
"ByteStreamMetadataTool"])
104 proxy = CompFactory.ProxyProviderSvc(ProviderNames = [address_provider.name])
105 result.addService(proxy)
107 result.merge(SGInputLoaderCfg(flags, address_provider.TypeNames,
108 ExtraOutputs=[(
"xAOD::EventInfo",f
"StoreGateSvc+{eiName}"),
109 (
"xAOD::EventAuxInfo",f
"StoreGateSvc+{eiName}Aux.")]))
115 """Set up output stream in RAW/bytestream format
117 Configure components responsible for writing bytestream format. Write job
118 results to bytestream file. ATLAS file naming conventions are enforced as
119 determined from the given configuration flags.
122 flags: Job configuration flags
123 type_names: (optional) Specify item list for output stream to write
126 A component accumulator fragment containing the components required to
127 write to bytestream. Should be merged into main job configuration.
129 all_runs =
set(flags.Input.RunNumbers)
132 ),
"Input is from multiple runs, do not know which one to use {}".format(
135 result = ComponentAccumulator(CompFactory.AthSequencer(
'AthOutSeq', StopOverride=
True))
137 event_storage_output = CompFactory.ByteStreamEventStorageOutputSvc(
140 OutputDirectory=
"./",
141 SimpleFileName=flags.Output.BSFileName,
143 RunNumber=all_runs.pop(),
145 result.addService(event_storage_output)
149 bytestream_conversion = CompFactory.ByteStreamCnvSvc(
150 name=
"ByteStreamCnvSvc",
151 ByteStreamOutputSvcList=[event_storage_output.getName()],
152 IsSimulation=flags.Input.isMC,
154 result.addService(bytestream_conversion)
157 event_info_input = (
'xAOD::EventInfo',
'StoreGateSvc+EventInfo')
159 output_stream = CompFactory.AthenaOutputStream(
160 name=
"BSOutputStreamAlg",
161 EvtConversionSvc=bytestream_conversion.name,
162 OutputFile=
"ByteStreamEventStorageOutputSvc",
163 ItemList=type_names
if type_names
else list(),
164 ExtraInputs=[event_info_input]
166 result.addEventAlgo(output_stream, primary=
True)
168 result.merge(IOVDbSvcCfg(flags))
171 MetaDataSvcCfg(flags, [
"IOVDbMetaDataTool",
"ByteStreamMetadataTool"])
177 """Configure the MCEventInfoByteStreamTool for encoding/decoding MC EventInfo
179 This tool serializes MC-specific EventInfo fields (mcChannelNumber, mcEventNumber,
180 mcEventWeights, pileup information, etc.) into a dedicated ROB fragment for MC
181 ByteStream files (RDO->BS workflow).
184 flags: Job configuration flags
186 writeBS: If True, configure for encoding, else for decoding
189 A component accumulator fragment containing the configured tool
191 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
192 from AthenaConfiguration.ComponentFactory
import CompFactory
194 acc = ComponentAccumulator()
195 tool = CompFactory.MCEventInfoByteStreamTool(name)
198 mc_eventinfo_robid = 0x00ff0001
199 tool.ROBIDs = [mc_eventinfo_robid]
203 tool.EventInfoReadKey =
"EventInfo"
206 tool.EventInfoReadKey =
""
208 acc.setPrivateTools(tool)
213 """Set up transient ByteStream output stream
215 Configure components responsible for writing bytestream format. Write the
216 specified objects to ByteStream into the cache of the ROBDataProviderSvc.
217 The data can then be read downstream as if they were coming from a BS file.
220 flags: Job configuration flags
221 item_list: (optional) List of objects to be written to transient ByteStream
222 type_names: (optional) List of types/names to register in BS conversion service
223 as available to be read from (transient) ByteStream
224 extra_inputs: (optional) List of objects which need to be produced before transient
225 ByteStream streaming is scheduled - ensures correct scheduling
228 A component accumulator fragment containing the components required to
229 write transient bytestream. Should be merged into main job configuration.
232 result = ComponentAccumulator()
234 result.addService(CompFactory.ROBDataProviderSvc())
236 rdp_output = CompFactory.ByteStreamRDP_OutputSvc()
237 result.addService(rdp_output)
239 bytestream_conversion = CompFactory.ByteStreamCnvSvc(
240 name=
"ByteStreamCnvSvc",
241 FillTriggerBits=
False,
242 ByteStreamOutputSvcList=[rdp_output.getName()],
243 IsSimulation=flags.Input.isMC,
245 result.addService(bytestream_conversion)
249 extra_outputs = [(
"TransientBSOutType",
"StoreGateSvc+TransientBSOutKey")]
252 event_info_input = (
'xAOD::EventInfo',
'StoreGateSvc+EventInfo')
254 extra_inputs = [event_info_input]
255 elif event_info_input
not in extra_inputs:
256 extra_inputs.append(event_info_input)
258 output_stream = CompFactory.AthenaOutputStream(
259 name=
"TransBSStreamAlg",
260 EvtConversionSvc=bytestream_conversion.name,
261 OutputFile=
"ByteStreamRDP_OutputSvc",
262 ItemList=item_list
if item_list
else list(),
263 ExtraInputs=extra_inputs,
264 ExtraOutputs=extra_outputs
266 result.addEventAlgo(output_stream,
269 address_provider = CompFactory.ByteStreamAddressProviderSvc(
270 TypeNames=type_names
if type_names
else list(),
272 result.addService(address_provider)
274 result.addService(CompFactory.ProxyProviderSvc(
275 ProviderNames = [address_provider.name]))
277 result.merge(SGInputLoaderCfg(flags, Load=address_provider.TypeNames))