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
8
9def _createTileContByteStreamToolCfg (flags, name, InitializeForWriting=False, **kwargs):
10
11 acc = ComponentAccumulator()
12 TileContByteStreamTool = CompFactory.getComp(name)
13 tool = TileContByteStreamTool(name, **kwargs)
14 tool.InitializeForWriting = InitializeForWriting
15 acc.addPublicTool(tool)
16
17 extraOutputs = []
18 if InitializeForWriting:
19 from TileByteStream.TileHid2RESrcIDConfig import TileHid2RESrcIDCondAlgCfg
20 acc.merge( TileHid2RESrcIDCondAlgCfg(flags, ForHLT=True) )
21
22 extraOutputs = [('TileHid2RESrcID', 'ConditionStore+TileHid2RESrcIDHLT')]
23
24 return acc, extraOutputs
25
26
28 name="TileDigitsContByteStreamTool",
29 InitializeForWriting=False,
30 **kwargs):
31 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
32
34 name="TileRawChannelContByteStreamTool",
35 InitializeForWriting=False,
36 **kwargs):
37 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
38
40 name="TileMuRcvContByteStreamTool",
41 InitializeForWriting=False,
42 **kwargs):
43 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
44
46 name="TileL2ContByteStreamTool",
47 InitializeForWriting=False,
48 **kwargs):
49 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
50
52 name="TileLaserObjByteStreamTool",
53 InitializeForWriting=False,
54 **kwargs):
55 return _createTileContByteStreamToolCfg(flags, name, InitializeForWriting, **kwargs)
56
57def addTileReadAlg(cfg, name, **kwargs):
58 decoder = CompFactory.TileROD_Decoder(TileBadChanTool="", TileCondToolEmscale="")
59 TileRawDataReadingAlg = CompFactory.TileRawDataReadingAlg
60 cfg.addEventAlgo(TileRawDataReadingAlg(name, TileROD_Decoder=decoder, **kwargs))
61
62def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True,
63 readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False,
64 readBeamElem=None, readLaserObj=None, readDigitsFlx=False,
65 readL2=False, stateless=False, **kwargs):
66 """
67 Configure reading the Tile BS files
68
69 Arguments:
70 read[...] -- flag to read the corresponding Tile data from BS.
71 Possible values: None (default), True, False.
72 In the case of None it will be autoconfigured.
73 stateless -- read online Tile data using emon BS service.
74 """
75
76 isPhysicsRun = flags.Tile.RunType is TileRunType.PHY
77 isLaserRun = flags.Tile.RunType in [TileRunType.LAS, TileRunType.BILAS]
78 isCalibRun = not isPhysicsRun
79
80 # Set up default data
81 readMuRcv = isPhysicsRun if readMuRcv is None else readMuRcv
82 readBeamElem = isCalibRun if readBeamElem is None else readBeamElem
83 readLaserObj = isLaserRun if readLaserObj is None else readLaserObj
84
85 typeNames = kwargs.pop('type_names', [])
86
87 prefix = flags.Overlay.BkgPrefix if flags.Common.ProductionStep is ProductionStep.MinbiasPreprocessing else ''
88
89 cfg = ComponentAccumulator()
90 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
91 cfg.merge(TileCablingSvcCfg(flags))
92
93 if stateless:
94 from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
95 cfg.merge( EmonByteStreamCfg(flags, type_names=typeNames) )
96 else:
97 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
98 cfg.merge( ByteStreamReadCfg(flags, type_names=typeNames) )
99
100 from TileByteStream.TileHid2RESrcIDConfig import TileHid2RESrcIDCondAlgCfg
101 cfg.merge( TileHid2RESrcIDCondAlgCfg(flags, ROD2ROBmap=['-1']) )
102
103 if readDigits:
104 addTileReadAlg(cfg, 'TileDigitsReadAlg', TileDigitsContainer=f'{prefix}TileDigitsCnt')
105 if readRawChannel:
106 addTileReadAlg(cfg, 'TileRawChannelReadAlg', TileRawChannelContainer=f'{prefix}TileRawChannelCnt')
107 if readMuRcv:
108 addTileReadAlg(cfg, 'TileMuRcvReadAlg', TileMuonReceiverContainer='TileMuRcvCnt')
109 if readMuRcvDigits:
110 addTileReadAlg(cfg, 'MuRcvDigitsReadAlg', MuRcvDigitsContainer=f'{prefix}MuRcvDigitsCnt')
111 if readMuRcvRawCh:
112 addTileReadAlg(cfg, 'TileMuRcvRawChReadAlg', MuRcvRawChannelContainer='MuRcvRawChCnt')
113 if readLaserObj:
114 addTileReadAlg(cfg, 'TileLaserObjReadAlg', TileLaserObject='TileLaserObj')
115 if readBeamElem:
116 addTileReadAlg(cfg, 'TileBeamElemReadAlg', TileBeamElemContainer='TileBeamElemCnt')
117 if readDigitsFlx:
118 addTileReadAlg(cfg, 'TileDigitsFlxReadAlg', TileDigitsFlxContainer='TileDigitsFlxCnt')
119 if readL2:
120 addTileReadAlg(cfg, 'TileL2ReadAlg', TileL2Container='TileL2Cnt')
121
122 return cfg
123
124
125if __name__ == "__main__":
126
127 from AthenaConfiguration.AllConfigFlags import initConfigFlags
128 from AthenaConfiguration.TestDefaults import defaultGeometryTags, defaultTestFiles
129 from AthenaCommon.Logging import log
130 from AthenaCommon.Constants import INFO
131
132 # Test setup
133 log.setLevel(INFO)
134
135 flags = initConfigFlags()
136 flags.Input.Files = defaultTestFiles.RAW_RUN2
137 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
138 flags.Exec.MaxEvents = 3
139 flags.fillFromArgs()
140 flags.lock()
141
142 # Initialize configuration object, add accumulator, merge, and run.
143 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
144 cfg = MainServicesCfg(flags)
145
146 cfg.merge( TileRawDataReadingCfg(flags) )
147
148 cfg.printConfig(withDetails = True, summariseProps = True)
149 cfg.store( open('TileRawChannelReadAlg.pkl','wb') )
150
151 sc = cfg.run()
152
153 import sys
154 # Success should be 0
155 sys.exit(not sc.isSuccess())
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)
TileDigitsContByteStreamToolCfg(flags, name="TileDigitsContByteStreamTool", InitializeForWriting=False, **kwargs)
TileMuRcvContByteStreamToolCfg(flags, name="TileMuRcvContByteStreamTool", InitializeForWriting=False, **kwargs)
TileRawChannelContByteStreamToolCfg(flags, name="TileRawChannelContByteStreamTool", InitializeForWriting=False, **kwargs)