ATLAS Offline Software
Loading...
Searching...
No Matches
ByteStreamConfig Namespace Reference

Functions

 ByteStreamReadCfg (flags, type_names=None)
 ByteStreamWriteCfg (flags, type_names=None)
 MCEventInfoByteStreamToolCfg (flags, name="MCEventInfoByteStreamTool", writeBS=False)
 TransientByteStreamCfg (flags, item_list=None, type_names=None, extra_inputs=None)
 ByteStreamCfg (flags, **kwargs)

Variables

 log = logging.getLogger('ByteStreamConfig')
 flags = initConfigFlags()
 Files
 doWriteBS
 read = ByteStreamReadCfg(flags)
 write = ByteStreamWriteCfg(flags)
 acc = MainServicesCfg(flags)

Detailed Description

Set up to read and/or write bytestream files.

This module configures the Athena components required to read from
RAW/bytestream input. Use either byteStreamReadCfg to set up for reading
and byteStreamWriteCfg to set up for writing. Merge the component accumulator
the functions return into your job configuration as needed.

Executing this module will run a short test over 10 events. The events are read
from the default bytestream input on CVMFS and written to a local bytestream
file.

    Typical usage examples:

        component_accumulator.merge(byteStreamReadCfg(flags))

Function Documentation

◆ ByteStreamCfg()

ByteStreamConfig.ByteStreamCfg ( flags,
** kwargs )

Definition at line 5 of file graphics/EventDisplaysOnline/python/ByteStreamConfig.py.

5def ByteStreamCfg(flags, **kwargs):
6
7 acc = ComponentAccumulator()
8
9 from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
10 acc.merge(EmonByteStreamCfg(flags))
11
12 bytestreamInput = acc.getService("ByteStreamInputSvc")
13 bytestreamInput.Partition = flags.OnlineEventDisplays.PartitionName
14 bytestreamInput.GroupName = "EventDisplaysOnline"
15 bytestreamInput.PublishName = "EventDisplays"
16 bytestreamInput.Key = "dcm"
17 bytestreamInput.KeyCount = 1
18 bytestreamInput.Timeout = 600000
19 bytestreamInput.UpdatePeriod = 200
20 bytestreamInput.BufferSize = 10
21 bytestreamInput.ISServer = '' # Disable histogramming
22 bytestreamInput.StreamNames = flags.OnlineEventDisplays.TriggerStreams
23 bytestreamInput.ProcessCorruptedEvents = True
24 #bytestreamInput.StreamType = "physics" #comment out for all streams, e.g. if you also want claibration streams
25 bytestreamInput.StreamLogic = "Or"
26
27 if flags.OnlineEventDisplays.BeamSplashMode:
28 bytestreamInput.KeyCount = 64 # equal or greater than the number of DCMs for beam splashes
29 bytestreamInput.BufferSize = 192 # at least three times of keycount for beam splashes
30 bytestreamInput.Timeout = 144000000 #(40 hrs)
31 bytestreamInput.StreamType = "physics" #if trigger fails it will go to debug_HltError
32
33 if flags.OnlineEventDisplays.PartitionName != 'ATLAS':
34 bytestreamInput.KeyValue = [ 'Test_emon_push' ]
35 bytestreamInput.KeyCount = 1
36
37 return acc

◆ ByteStreamReadCfg()

ByteStreamConfig.ByteStreamReadCfg ( flags,
type_names = None )
Set up to read from a bytestream file

The function adds the components required to read events and metadata from
bytestream input. May be used to read events from a secondary input as well
primary input file.

Args:
    flags:      Job configuration flags
    type_names: (optional) specific type names for address provider to find

Returns:
    A component accumulator fragment containing the components required to
    read from bytestream. Should be merged into main job configuration.

Definition at line 26 of file Event/ByteStreamCnvSvc/python/ByteStreamConfig.py.

26def ByteStreamReadCfg(flags, type_names=None):
27 """Set up to read from a bytestream file
28
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
31 primary input file.
32
33 Args:
34 flags: Job configuration flags
35 type_names: (optional) specific type names for address provider to find
36
37 Returns:
38 A component accumulator fragment containing the components required to
39 read from bytestream. Should be merged into main job configuration.
40 """
41 result = ComponentAccumulator()
42
43 bytestream_conversion = CompFactory.ByteStreamCnvSvc(
44 IsSimulation=flags.Input.isMC,
45 )
46 result.addService(bytestream_conversion)
47
48 # For MC ByteStream, add the MCEventInfoByteStreamTool to decode MC EventInfo
49 if flags.Input.isMC:
50 mcEventInfoTool = CompFactory.MCEventInfoByteStreamTool(
51 name="MCEventInfoByteStreamTool",
52 ROBIDs=[0x00ff0001], # SubDetector=OTHER=0xFF, ModuleId=0x01
53 EventInfoReadKey="", # Empty for decoding mode
54 )
55 result.addPublicTool(mcEventInfoTool)
56
57 result.merge(SGInputLoaderCfg(flags, [('ByteStreamMetadataContainer', 'InputMetaDataStore+ByteStreamMetadata')]))
58
59 eiName = "EventInfo"
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")
62 else:
63 eiName = "{}EventInfo".format(flags.Overlay.BkgPrefix if flags.Common.ProductionStep is ProductionStep.MinbiasPreprocessing else "")
64 bytestream_input = CompFactory.ByteStreamEventStorageInputSvc(
65 name="ByteStreamInputSvc",
66 EventInfoKey=eiName)
67 result.addService(bytestream_input)
68
69 if flags.Input.SecondaryFiles:
70 event_selector = CompFactory.EventSelectorByteStream(
71 name="SecondaryEventSelector",
72 IsSecondary=True,
73 Input=flags.Input.SecondaryFiles,
74 SkipEvents=flags.Exec.SkipEvents if flags.Overlay.SkipSecondaryEvents >= 0 else flags.Exec.SkipEvents,
75 ByteStreamInputSvc=bytestream_input.name,
76 )
77 result.addService(event_selector)
78 else:
79 event_selector = CompFactory.EventSelectorByteStream(
80 name="EventSelector",
81 Input=flags.Input.Files,
82 SkipEvents=flags.Exec.SkipEvents,
83 ByteStreamInputSvc=bytestream_input.name,
84 )
85 result.addService(event_selector)
86 result.setAppProperty("EvtSel", event_selector.name)
87
88 event_persistency = CompFactory.EvtPersistencySvc(
89 name="EventPersistencySvc", CnvServices=[bytestream_conversion.name]
90 )
91 result.addService(event_persistency)
92
93 result.addService(CompFactory.ROBDataProviderSvc())
94
95 address_provider = CompFactory.ByteStreamAddressProviderSvc(
96 TypeNames=type_names if type_names else list(),
97 )
98 result.addService(address_provider)
99
100 result.merge(
101 MetaDataSvcCfg(flags, ["IOVDbMetaDataTool", "ByteStreamMetadataTool"])
102 )
103
104 proxy = CompFactory.ProxyProviderSvc(ProviderNames = [address_provider.name])
105 result.addService(proxy)
106
107 result.merge(SGInputLoaderCfg(flags, address_provider.TypeNames,
108 ExtraOutputs=[("xAOD::EventInfo",f"StoreGateSvc+{eiName}"),
109 ("xAOD::EventAuxInfo",f"StoreGateSvc+{eiName}Aux.")]))
110
111 return result
112
113

◆ ByteStreamWriteCfg()

ByteStreamConfig.ByteStreamWriteCfg ( flags,
type_names = None )
Set up output stream in RAW/bytestream format

Configure components responsible for writing bytestream format. Write job
results to bytestream file. ATLAS file naming conventions are enforced as
determined from the given configuration flags.

Args:
    flags:      Job configuration flags
    type_names: (optional) Specify item list for output stream to write

Returns:
    A component accumulator fragment containing the components required to
    write to bytestream. Should be merged into main job configuration.

Definition at line 114 of file Event/ByteStreamCnvSvc/python/ByteStreamConfig.py.

114def ByteStreamWriteCfg(flags, type_names=None):
115 """Set up output stream in RAW/bytestream format
116
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.
120
121 Args:
122 flags: Job configuration flags
123 type_names: (optional) Specify item list for output stream to write
124
125 Returns:
126 A component accumulator fragment containing the components required to
127 write to bytestream. Should be merged into main job configuration.
128 """
129 all_runs = set(flags.Input.RunNumbers)
130 assert (
131 len(all_runs) == 1
132 ), "Input is from multiple runs, do not know which one to use {}".format(
133 all_runs
134 )
135 result = ComponentAccumulator(CompFactory.AthSequencer('AthOutSeq', StopOverride=True))
136
137 event_storage_output = CompFactory.ByteStreamEventStorageOutputSvc(
138 MaxFileMB=15000,
139 MaxFileNE=15000000, # event (beyond which it creates a new file)
140 OutputDirectory="./",
141 SimpleFileName=flags.Output.BSFileName,
142 AppName="Athena",
143 RunNumber=all_runs.pop(),
144 )
145 result.addService(event_storage_output)
146 # release variable depends the way the env is configured
147 # FileTag = release
148
149 bytestream_conversion = CompFactory.ByteStreamCnvSvc(
150 name="ByteStreamCnvSvc",
151 ByteStreamOutputSvcList=[event_storage_output.getName()],
152 IsSimulation=flags.Input.isMC,
153 )
154 result.addService(bytestream_conversion)
155
156 # ByteStreamCnvSvc::connectOutput() requires xAOD::EventInfo
157 event_info_input = ('xAOD::EventInfo','StoreGateSvc+EventInfo')
158
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]
165 )
166 result.addEventAlgo(output_stream, primary=True)
167
168 result.merge(IOVDbSvcCfg(flags))
169
170 result.merge(
171 MetaDataSvcCfg(flags, ["IOVDbMetaDataTool", "ByteStreamMetadataTool"])
172 )
173
174 return result
175
STL class.

◆ MCEventInfoByteStreamToolCfg()

ByteStreamConfig.MCEventInfoByteStreamToolCfg ( flags,
name = "MCEventInfoByteStreamTool",
writeBS = False )
Configure the MCEventInfoByteStreamTool for encoding/decoding MC EventInfo

This tool serializes MC-specific EventInfo fields (mcChannelNumber, mcEventNumber,
mcEventWeights, pileup information, etc.) into a dedicated ROB fragment for MC
ByteStream files (RDO->BS workflow).

Args:
    flags:    Job configuration flags
    name:     Tool name
    writeBS:  If True, configure for encoding, else for decoding

Returns:
    A component accumulator fragment containing the configured tool

Definition at line 176 of file Event/ByteStreamCnvSvc/python/ByteStreamConfig.py.

176def MCEventInfoByteStreamToolCfg(flags, name="MCEventInfoByteStreamTool", writeBS=False):
177 """Configure the MCEventInfoByteStreamTool for encoding/decoding MC EventInfo
178
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).
182
183 Args:
184 flags: Job configuration flags
185 name: Tool name
186 writeBS: If True, configure for encoding, else for decoding
187
188 Returns:
189 A component accumulator fragment containing the configured tool
190 """
191 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
192 from AthenaConfiguration.ComponentFactory import CompFactory
193
194 acc = ComponentAccumulator()
195 tool = CompFactory.MCEventInfoByteStreamTool(name)
196
197 # ROB ID for MC EventInfo (SubDetector=OTHER=0xFF, ModuleId=0x01)
198 mc_eventinfo_robid = 0x00ff0001
199 tool.ROBIDs = [mc_eventinfo_robid]
200
201 if writeBS:
202 # write BS == read xAOD (encoding mode)
203 tool.EventInfoReadKey = "EventInfo"
204 else:
205 # read BS == write xAOD (decoding mode)
206 tool.EventInfoReadKey = ""
207
208 acc.setPrivateTools(tool)
209 return acc
210
211

◆ TransientByteStreamCfg()

ByteStreamConfig.TransientByteStreamCfg ( flags,
item_list = None,
type_names = None,
extra_inputs = None )
Set up transient ByteStream output stream

Configure components responsible for writing bytestream format. Write the
specified objects to ByteStream into the cache of the ROBDataProviderSvc.
The data can then be read downstream as if they were coming from a BS file.

Args:
    flags:        Job configuration flags
    item_list:    (optional) List of objects to be written to transient ByteStream
    type_names:   (optional) List of types/names to register in BS conversion service
                  as available to be read from (transient) ByteStream
    extra_inputs: (optional) List of objects which need to be produced before transient
                  ByteStream streaming is scheduled - ensures correct scheduling

Returns:
    A component accumulator fragment containing the components required to
    write transient bytestream. Should be merged into main job configuration.

Definition at line 212 of file Event/ByteStreamCnvSvc/python/ByteStreamConfig.py.

212def TransientByteStreamCfg(flags, item_list=None, type_names=None, extra_inputs=None):
213 """Set up transient ByteStream output stream
214
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.
218
219 Args:
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
226
227 Returns:
228 A component accumulator fragment containing the components required to
229 write transient bytestream. Should be merged into main job configuration.
230 """
231
232 result = ComponentAccumulator()
233
234 result.addService(CompFactory.ROBDataProviderSvc())
235
236 rdp_output = CompFactory.ByteStreamRDP_OutputSvc()
237 result.addService(rdp_output)
238
239 bytestream_conversion = CompFactory.ByteStreamCnvSvc(
240 name="ByteStreamCnvSvc",
241 FillTriggerBits=False, # ATR-25971, transient BS is produced before trigger bits in RDOtoRDOTrigger
242 ByteStreamOutputSvcList=[rdp_output.getName()],
243 IsSimulation=flags.Input.isMC,
244 )
245 result.addService(bytestream_conversion)
246
247 # Special fictitious extra output which can be used to ensure correct
248 # scheduling of transient ByteStream clients
249 extra_outputs = [("TransientBSOutType","StoreGateSvc+TransientBSOutKey")]
250
251 # ByteStreamCnvSvc::connectOutput() requires xAOD::EventInfo
252 event_info_input = ('xAOD::EventInfo','StoreGateSvc+EventInfo')
253 if not extra_inputs:
254 extra_inputs = [event_info_input]
255 elif event_info_input not in extra_inputs:
256 extra_inputs.append(event_info_input)
257
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
265 )
266 result.addEventAlgo(output_stream,
267 primary=True)
268
269 address_provider = CompFactory.ByteStreamAddressProviderSvc(
270 TypeNames=type_names if type_names else list(),
271 )
272 result.addService(address_provider)
273
274 result.addService(CompFactory.ProxyProviderSvc(
275 ProviderNames = [address_provider.name]))
276
277 result.merge(SGInputLoaderCfg(flags, Load=address_provider.TypeNames))
278
279 return result
280
281

Variable Documentation

◆ acc

ByteStreamConfig.acc = MainServicesCfg(flags)

◆ doWriteBS

ByteStreamConfig.doWriteBS

◆ Files

ByteStreamConfig.Files

◆ flags

ByteStreamConfig.flags = initConfigFlags()

◆ log

ByteStreamConfig.log = logging.getLogger('ByteStreamConfig')

◆ read

ByteStreamConfig.read = ByteStreamReadCfg(flags)

◆ write

ByteStreamConfig.write = ByteStreamWriteCfg(flags)