ATLAS Offline Software
Loading...
Searching...
No Matches
TileByteStreamConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentFactory import CompFactory
4from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5from AthenaConfiguration.Enums import ProductionStep
6from TileConfiguration.TileConfigFlags import TileRunType
7
8def _createTileContByteStreamToolsConfig (name, TileContByteStreamTool, InitializeForWriting=False, stream=None, **kwargs):
9
10 kwargs['name'] = name
11 kwargs['InitializeForWriting'] = InitializeForWriting
12 tool = TileContByteStreamTool(**kwargs)
13
14 if InitializeForWriting:
15 from TileByteStream.TileHid2RESrcIDConfig import TileHid2RESrcIDCondAlg
16 TileHid2RESrcIDCondAlg(ForHLT=True)
17
18 if stream:
19 stream.ExtraInputs |= {('TileHid2RESrcID', 'ConditionStore+TileHid2RESrcIDHLT')}
20
21 return tool
22
23def TileRawChannelContByteStreamToolConfig(name='TileRawChannelContByteStreamTool', InitializeForWriting=False, stream=None, **kwargs):
24 from TileByteStream.TileByteStreamConf import TileRawChannelContByteStreamTool
25 return _createTileContByteStreamToolsConfig(name, TileRawChannelContByteStreamTool, InitializeForWriting, stream, **kwargs)
26
27def TileL2ContByteStreamToolConfig(name='TileL2ContByteStreamTool', InitializeForWriting=False, stream=None, **kwargs):
28 from TileByteStream.TileByteStreamConf import TileL2ContByteStreamTool
29 return _createTileContByteStreamToolsConfig(name, TileL2ContByteStreamTool, InitializeForWriting, stream, **kwargs)
30
31
32
33# ComponentAccumulator version
34
35def _createTileContByteStreamToolCfg (flags, name, InitializeForWriting=False, **kwargs):
36
37 acc = ComponentAccumulator()
38 TileContByteStreamTool = CompFactory.getComp(name)
39 tool = TileContByteStreamTool(name, **kwargs)
40 tool.InitializeForWriting = InitializeForWriting
41 acc.addPublicTool(tool)
42
43 extraOutputs = []
44 if InitializeForWriting:
45 from TileByteStream.TileHid2RESrcIDConfig import TileHid2RESrcIDCondAlgCfg
46 acc.merge( TileHid2RESrcIDCondAlgCfg(flags, ForHLT=True) )
47
48 extraOutputs = [('TileHid2RESrcID', 'ConditionStore+TileHid2RESrcIDHLT')]
49
50 return acc, extraOutputs
51
52
54 name="TileDigitsContByteStreamTool",
55 InitializeForWriting=False,
56 **kwargs):
57 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
58
60 name="TileRawChannelContByteStreamTool",
61 InitializeForWriting=False,
62 **kwargs):
63 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
64
66 name="TileMuRcvContByteStreamTool",
67 InitializeForWriting=False,
68 **kwargs):
69 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
70
72 name="TileL2ContByteStreamTool",
73 InitializeForWriting=False,
74 **kwargs):
75 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
76
78 name="TileLaserObjByteStreamTool",
79 InitializeForWriting=False,
80 **kwargs):
81 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
82
83def addTileReadAlg(cfg, name, **kwargs):
84 decoder = CompFactory.TileROD_Decoder(TileBadChanTool="", TileCondToolEmscale="")
85 TileRawDataReadingAlg = CompFactory.TileRawDataReadingAlg
86 cfg.addEventAlgo(TileRawDataReadingAlg(name, TileROD_Decoder=decoder, **kwargs))
87
88def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True,
89 readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False,
90 readBeamElem=None, readLaserObj=None, readDigitsFlx=False,
91 readL2=False, stateless=False, **kwargs):
92 """
93 Configure reading the Tile BS files
94
95 Arguments:
96 read[...] -- flag to read the corresponding Tile data from BS.
97 Possible values: None (default), True, False.
98 In the case of None it will be autoconfigured.
99 stateless -- read online Tile data using emon BS service.
100 """
101
102 isPhysicsRun = flags.Tile.RunType is TileRunType.PHY
103 isLaserRun = flags.Tile.RunType in [TileRunType.LAS, TileRunType.BILAS]
104 isCalibRun = not isPhysicsRun
105
106 # Set up default data
107 readMuRcv = isPhysicsRun if readMuRcv is None else readMuRcv
108 readBeamElem = isCalibRun if readBeamElem is None else readBeamElem
109 readLaserObj = isLaserRun if readLaserObj is None else readLaserObj
110
111 typeNames = kwargs.pop('type_names', [])
112
113 prefix = flags.Overlay.BkgPrefix if flags.Common.ProductionStep is ProductionStep.MinbiasPreprocessing else ''
114
115 cfg = ComponentAccumulator()
116 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
117 cfg.merge(TileCablingSvcCfg(flags))
118
119 if stateless:
120 from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
121 cfg.merge( EmonByteStreamCfg(flags, type_names=typeNames) )
122 else:
123 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
124 cfg.merge( ByteStreamReadCfg(flags, type_names=typeNames) )
125
126 from TileByteStream.TileHid2RESrcIDConfig import TileHid2RESrcIDCondAlgCfg
127 cfg.merge( TileHid2RESrcIDCondAlgCfg(flags, ROD2ROBmap=['-1']) )
128
129 if readDigits:
130 addTileReadAlg(cfg, 'TileDigitsReadAlg', TileDigitsContainer=f'{prefix}TileDigitsCnt')
131 if readRawChannel:
132 addTileReadAlg(cfg, 'TileRawChannelReadAlg', TileRawChannelContainer=f'{prefix}TileRawChannelCnt')
133 if readMuRcv:
134 addTileReadAlg(cfg, 'TileMuRcvReadAlg', TileMuonReceiverContainer='TileMuRcvCnt')
135 if readMuRcvDigits:
136 addTileReadAlg(cfg, 'MuRcvDigitsReadAlg', MuRcvDigitsContainer=f'{prefix}MuRcvDigitsCnt')
137 if readMuRcvRawCh:
138 addTileReadAlg(cfg, 'TileMuRcvRawChReadAlg', MuRcvRawChannelContainer='MuRcvRawChCnt')
139 if readLaserObj:
140 addTileReadAlg(cfg, 'TileLaserObjReadAlg', TileLaserObject='TileLaserObj')
141 if readBeamElem:
142 addTileReadAlg(cfg, 'TileBeamElemReadAlg', TileBeamElemContainer='TileBeamElemCnt')
143 if readDigitsFlx:
144 addTileReadAlg(cfg, 'TileDigitsFlxReadAlg', TileDigitsFlxContainer='TileDigitsFlxCnt')
145 if readL2:
146 addTileReadAlg(cfg, 'TileL2ReadAlg', TileL2Container='TileL2Cnt')
147
148 return cfg
149
150
151if __name__ == "__main__":
152
153 from AthenaConfiguration.AllConfigFlags import initConfigFlags
154 from AthenaConfiguration.TestDefaults import defaultGeometryTags, defaultTestFiles
155 from AthenaCommon.Logging import log
156 from AthenaCommon.Constants import INFO
157
158 # Test setup
159 log.setLevel(INFO)
160
161 flags = initConfigFlags()
162 flags.Input.Files = defaultTestFiles.RAW_RUN2
163 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
164 flags.Exec.MaxEvents = 3
165 flags.fillFromArgs()
166 flags.lock()
167
168 # Initialize configuration object, add accumulator, merge, and run.
169 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
170 cfg = MainServicesCfg(flags)
171
172 cfg.merge( TileRawDataReadingCfg(flags) )
173
174 cfg.printConfig(withDetails = True, summariseProps = True)
175 cfg.store( open('TileRawChannelReadAlg.pkl','wb') )
176
177 sc = cfg.run()
178
179 import sys
180 # Success should be 0
181 sys.exit(not sc.isSuccess())
Condition algorithm to prepare TileHid2RESrcID conditions object and put it into conditions store.
Class for Tile raw data reading from BS.
_createTileContByteStreamToolCfg(flags, name, InitializeForWriting=False, **kwargs)
TileLaserObjByteStreamToolCfg(flags, name="TileLaserObjByteStreamTool", InitializeForWriting=False, **kwargs)
addTileReadAlg(cfg, name, **kwargs)
TileL2ContByteStreamToolCfg(flags, name="TileL2ContByteStreamTool", InitializeForWriting=False, **kwargs)
TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True, readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False, readBeamElem=None, readLaserObj=None, readDigitsFlx=False, readL2=False, stateless=False, **kwargs)
TileRawChannelContByteStreamToolConfig(name='TileRawChannelContByteStreamTool', InitializeForWriting=False, stream=None, **kwargs)
TileDigitsContByteStreamToolCfg(flags, name="TileDigitsContByteStreamTool", InitializeForWriting=False, **kwargs)
TileL2ContByteStreamToolConfig(name='TileL2ContByteStreamTool', InitializeForWriting=False, stream=None, **kwargs)
TileMuRcvContByteStreamToolCfg(flags, name="TileMuRcvContByteStreamTool", InitializeForWriting=False, **kwargs)
_createTileContByteStreamToolsConfig(name, TileContByteStreamTool, InitializeForWriting=False, stream=None, **kwargs)
TileRawChannelContByteStreamToolCfg(flags, name="TileRawChannelContByteStreamTool", InitializeForWriting=False, **kwargs)