3from AthenaConfiguration.ComponentFactory
import CompFactory
4from AthenaCommon.Utils.unixtools
import find_datafile
5from AthenaPython.PyAthenaComps
import Alg, StatusCode
6from TileConfiguration.TileConfigFlags
import TileRunType
14 refPaths = [os.environ.get(
'ATLAS_REFERENCE_DATA',
None),
15 '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art']
16 for refPath
in refPaths:
18 absPath = os.path.join(refPath, path)
19 if os.path.exists(absPath):
22 from AthenaCommon.Logging
import logging
23 msg = logging.getLogger(
'findAbsPath')
24 msg.error(f
'Cannot find abs path: {path}')
30 """ Find reference directory."""
31 referenceTag = os.environ.get(
'ATLAS_REFERENCE_TAG',
'TileByteStream-02-00-00')
32 directoryPath = find_datafile(os.path.join(
'TileByteStream', referenceTag))
35 refDirectory = os.path.join(directoryPath, directory)
36 if not refDirectory
or not os.path.exists(refDirectory):
37 refDirectory =
findAbsPath(os.path.join(
'TileByteStream', referenceTag, directory))
43 dumpDirectory = f
'{directory}-{flags.Concurrency.NumThreads}'
44 return refDirectory, dumpDirectory
48 """ Find input file. """
49 filePath = os.environ.get(
'ATLAS_REFERENCE_DATA',
50 '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests')
51 inputFile = os.path.join(filePath, fileName)
52 if not os.path.exists(inputFile):
61 super(Finalizer, self).
__init__(name, **kw)
64 self.msg.info(f
'Reference directory: {self.refDirectory}')
65 self.msg.info(f
'Dump directory: {self.dumpDirectory}')
66 dumps = glob.glob(os.path.join(self.
refDirectory,
'*.dump'))
68 localDump = os.path.join(self.
dumpDirectory, os.path.basename(refDump))
69 os.system(f
'diff -u {refDump} {localDump}')
70 self.msg.info(f
'Finalize: compared {len(dumps)} dumps')
72 return StatusCode.Success
76 """ Configure test of reading the Tile digits container from BS """
78 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
79 cfg = TileRawDataReadingCfg(flags, readDigits=
True, readRawChannel=
False, readMuRcv=
False, readMuRcvDigits=
True)
81 TileDigitsDumper = CompFactory.TileDigitsDumper
83 TileDigitsContainer=
'TileDigitsCnt',
84 Prefix=f
'{dumpDirectory}/'))
87 TileDigitsContainer=
'MuRcvDigitsCnt',
88 Prefix=f
'{dumpDirectory}/'))
90 cfg.addEventAlgo(
Finalizer(
'TileDigitsCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
95 """ Configure test of reading the Tile raw channel container from BS """
97 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
98 cfg = TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
True, readMuRcv=
False, readMuRcvRawCh=
True)
100 TileRawChannelDumper = CompFactory.TileRawChannelDumper
102 TileRawChannelContainer=
'TileRawChannelCnt',
103 Prefix=f
'{dumpDirectory}/'))
106 TileRawChannelContainer=
'MuRcvRawChCnt',
107 Prefix=f
'{dumpDirectory}/'))
109 cfg.addEventAlgo(
Finalizer(
'TileRawChannelCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
114 """ Configure test of reading the Tile laser object from BS """
116 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
117 cfg = TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
False, readMuRcv=
False, readLaserObj=
True)
119 TileLaserObjectDumper = CompFactory.TileLaserObjectDumper
121 TileLaserObject=
'TileLaserObj',
122 Prefix=f
'{dumpDirectory}/'))
124 cfg.addEventAlgo(
Finalizer(
'TileLaserObjCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
129 """ Configure test of reading the Tile L2 container from BS """
131 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
132 cfg = TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
False, readMuRcv=
False, readL2=
True)
134 TileL2Dumper = CompFactory.TileL2Dumper
136 TileL2Container=
'TileL2Cnt',
137 Prefix=f
'{dumpDirectory}/'))
139 cfg.addEventAlgo(
Finalizer(
'TileL2CompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
144 """ Configure test of reading the Tile beam elements container from BS """
146 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
147 cfg = TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
False, readMuRcv=
False, readBeamElem=
True)
149 TileBeamElemDumper = CompFactory.TileBeamElemDumper
151 TileBeamElemContainer=
'TileBeamElemCnt',
152 Prefix=f
'{dumpDirectory}/'))
154 cfg.addEventAlgo(
Finalizer(
'TileBeamElemCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
159 """ Configure test of reading the Tile muon receiver container from BS """
161 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
162 cfg = TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
False, readMuRcv=
True)
164 TileMuonReceiverDumper = CompFactory.TileMuonReceiverDumper
166 TileMuonReceiverContainer=
'TileMuRcvCnt',
167 Prefix=f
'{dumpDirectory}/'))
169 cfg.addEventAlgo(
Finalizer(
'TileMuRcvCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
173if __name__ ==
"__main__":
175 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
176 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
177 from AthenaCommon.Logging
import log
183 flags = initConfigFlags()
184 parser = flags.getArgumentParser()
185 tests_group = parser.add_argument_group(
'Test of reading Tile raw data from BS')
186 tests = tests_group.add_mutually_exclusive_group()
187 tests.add_argument(
'--digits', action=
'store_true', help=
'Test of reading Tile digits container from BS')
188 tests.add_argument(
'--murcv', action=
'store_true', help=
'Test of reading Tile muon receiver container from BS')
189 tests.add_argument(
'--level2', action=
'store_true', help=
'Test of reading Tile L2 container from BS')
190 tests.add_argument(
'--raw-channels', dest=
'rawChannels', action=
'store_true', help=
'Test of reading Tile raw channel container from BS')
191 tests.add_argument(
'--laser-object', dest=
'laserObject', action=
'store_true', help=
'Test of reading Tile laser object from BS')
192 tests.add_argument(
'--beam-elements', dest=
'beamElements', action=
'store_true', help=
'Test of reading Tile beam elements container from BS')
193 args, _ = parser.parse_known_args()
195 if not any([args.digits, args.rawChannels, args.murcv, args.laserObject, args.beamElements, args.level2]):
196 log.info(
'No tests are requested. Exiting ...')
199 if any([args.murcv, args.laserObject]):
200 flags.Input.Files = [
getInputFile(
'data18_tilecomm.00363899.calibration_tile.daq.RAW._lb0000._TileREB-ROS._0005-200ev.data')]
201 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
203 flags.Input.Files = [
getInputFile(
'data12_8TeV.00204073.physics_JetTauEtmiss.merge.RAW._lb0144._SFO-5._0001.1')]
204 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN1_2012
206 flags.Exec.MaxEvents = 100
207 flags.Tile.RunType = TileRunType.PHY
208 flags.IOVDb.DatabaseInstance =
'CONDBR2'
209 flags.fillFromArgs(parser=parser)
213 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
214 cfg = MainServicesCfg(flags)
220 elif args.rawChannels:
223 elif args.laserObject:
229 elif args.beamElements:
236 cfg.printConfig(withDetails=
True)
239 os.system(f
'rm -rf {dumpDirectory}')
240 os.system(f
'mkdir -p {dumpDirectory}')
246 sys.exit(
not sc.isSuccess())
Dump a TileBeamElemContainer to a text file.
Dump a TileDigitsContainer to a text file.
Dump a TileL2Container to a text file.
Dump a TileLaserObject to a text file.
Dump a TileMuonReceiverContainer to a text file.
Dump a TileRawChannelContainer to a text file.
__init__(self, name=None, **kw)
getRefAndDumpDirectories(flags, directory)
TileRawChannelReadTestCfg(flags, refDirectory, dumpDirectory, **kwargs)
TileMuRcvReadTestCfg(flags, refDirectory, dumpDirectory, **kwargs)
TileL2ReadTestCfg(flags, refDirectory, dumpDirectory, **kwargs)
TileDigitsReadTestCfg(flags, refDirectory, dumpDirectory, **kwargs)
TileBeamElemReadTestCfg(flags, refDirectory, dumpDirectory, **kwargs)
TileLaserObjectReadTestCfg(flags, refDirectory, dumpDirectory, **kwargs)