ATLAS Offline Software
Loading...
Searching...
No Matches
TriggerByteStreamConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2'''
3Functions creating ComponentAccumulator for ByteStream access
4'''
5
6from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7
8def ByteStreamReadCfg(flags, type_names=[]):
9 '''
10 Returns ComponentAccumulator with all components required to read objects from ByteStream input
11
12 Params:
13 flags (AthConfigFlags): The configuration flags container
14 type_names (list): Types to register converters for reading from BS, format ["typeA/key1", "typeB/key2"]
15
16 This wrapper function registers the type_names with either the online (HLT), the offline or the EMon BS services
17 depending on the configuration flags.
18 '''
19
20 if flags.Common.isOnline and not any(flags.Input.Files) and not (flags.Trigger.doHLT or flags.Trigger.doLVL1):
21 # Running online reconstruction at P1 (EMon)
22 from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
23 servicesCfgFunction = EmonByteStreamCfg
24 elif flags.Trigger.Online.isPartition:
25 # Running HLT at P1 or with athenaHLT.py
26 from TrigByteStreamCnvSvc.TrigByteStreamConfig import TrigByteStreamCfg
27 servicesCfgFunction = TrigByteStreamCfg
28 else:
29 # Running offline athena
30 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
31 servicesCfgFunction = ByteStreamReadCfg
32
33 acc = ComponentAccumulator()
34 acc.merge(servicesCfgFunction(flags, type_names=type_names))
35 return acc
36
37
38def ByteStreamWriteCfg(flags, type_names=[], extra_inputs=[]):
39 '''
40 Returns ComponentAccumulator with all components required to write objects to ByteStream output
41
42 Params:
43 flags (AthConfigFlags): The configuration flags container
44 type_names (list): Objects to register converters for reading from BS, format ["typeA/key1", "typeB/key2"]
45 extra_inputs (list): Objects which need to be produced before the output stream algorithm runs
46 (scheduler dependencies), format [('typeC', 'key3'), ('typeD', 'key4')]
47 '''
48
49 # Allow calling this only in offline athena (i.e. not in athenaHLT)
50 if flags.Trigger.Online.isPartition:
51 raise RuntimeError('Cannot write arbitrary objects to ByteStream in online HLT configuration')
52
53 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamWriteCfg
54 acc = ByteStreamWriteCfg(flags, type_names=type_names)
55 acc.getPrimary().ExtraInputs = extra_inputs
56 acc.getService('ByteStreamEventStorageOutputSvc').StreamType = 'unknown'
57 acc.getService('ByteStreamEventStorageOutputSvc').StreamName = 'SingleStream'
58 return acc
ByteStreamWriteCfg(flags, type_names=[], extra_inputs=[])