3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaCommon.Utils.unixtools
import find_datafile
5 from AthenaPython.PyAthenaComps
import Alg, StatusCode
6 from TileConfiguration.TileConfigFlags
import TileRunType
14 refPaths = [os.environ.get(
'ATLAS_REFERENCE_DATA',
None),
15 '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art',
16 '/afs/cern.ch/atlas/maxidisk/d33/referencefiles']
17 for refPath
in refPaths:
19 absPath = os.path.join(refPath, path)
20 if os.path.exists(absPath):
23 from AthenaCommon.Logging
import logging
24 msg = logging.getLogger(
'findAbsPath')
25 msg.error(f
'Cannot find abs path: {path}')
31 """ Find reference directory."""
32 referenceTag = os.environ.get(
'ATLAS_REFERENCE_TAG',
'TileByteStream-02-00-00')
33 directoryPath =
find_datafile(os.path.join(
'TileByteStream', referenceTag))
36 refDirectory = os.path.join(directoryPath, directory)
37 if not refDirectory
or not os.path.exists(refDirectory):
38 refDirectory =
findAbsPath(os.path.join(
'TileByteStream', referenceTag, directory))
44 dumpDirectory = f
'{directory}-{flags.Concurrency.NumThreads}'
45 return refDirectory, dumpDirectory
49 """ Find input file. """
50 filePath = os.environ.get(
'ATLAS_REFERENCE_DATA',
51 '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests')
52 inputFile = os.path.join(filePath, fileName)
53 if not os.path.exists(inputFile):
62 super(Finalizer, self).
__init__(name, **kw)
65 self.msg.
info(f
'Reference directory: {self.refDirectory}')
66 self.msg.
info(f
'Dump directory: {self.dumpDirectory}')
67 dumps = glob.glob(os.path.join(self.
refDirectory,
'*.dump'))
69 localDump = os.path.join(self.
dumpDirectory, os.path.basename(refDump))
70 os.system(f
'diff -u {refDump} {localDump}')
71 self.msg.
info(f
'Finalize: compared {len(dumps)} dumps')
73 return StatusCode.Success
77 """ Configure test of reading the Tile digits container from BS """
79 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
80 cfg =
TileRawDataReadingCfg(flags, readDigits=
True, readRawChannel=
False, readMuRcv=
False, readMuRcvDigits=
True)
82 TileDigitsDumper = CompFactory.TileDigitsDumper
84 TileDigitsContainer=
'TileDigitsCnt',
85 Prefix=f
'{dumpDirectory}/'))
88 TileDigitsContainer=
'MuRcvDigitsCnt',
89 Prefix=f
'{dumpDirectory}/'))
91 cfg.addEventAlgo(
Finalizer(
'TileDigitsCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
96 """ Configure test of reading the Tile raw channel container from BS """
98 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
99 cfg =
TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
True, readMuRcv=
False, readMuRcvRawCh=
True)
101 TileRawChannelDumper = CompFactory.TileRawChannelDumper
103 TileRawChannelContainer=
'TileRawChannelCnt',
104 Prefix=f
'{dumpDirectory}/'))
107 TileRawChannelContainer=
'MuRcvRawChCnt',
108 Prefix=f
'{dumpDirectory}/'))
110 cfg.addEventAlgo(
Finalizer(
'TileRawChannelCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
115 """ Configure test of reading the Tile laser object from BS """
117 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
118 cfg =
TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
False, readMuRcv=
False, readLaserObj=
True)
120 TileLaserObjectDumper = CompFactory.TileLaserObjectDumper
122 TileLaserObject=
'TileLaserObj',
123 Prefix=f
'{dumpDirectory}/'))
125 cfg.addEventAlgo(
Finalizer(
'TileLaserObjCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
130 """ Configure test of reading the Tile L2 container from BS """
132 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
133 cfg =
TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
False, readMuRcv=
False, readL2=
True)
135 TileL2Dumper = CompFactory.TileL2Dumper
137 TileL2Container=
'TileL2Cnt',
138 Prefix=f
'{dumpDirectory}/'))
140 cfg.addEventAlgo(
Finalizer(
'TileL2CompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
145 """ Configure test of reading the Tile beam elements container from BS """
147 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
148 cfg =
TileRawDataReadingCfg(flags, readDigits=
False, readRawChannel=
False, readMuRcv=
False, readBeamElem=
True)
150 TileBeamElemDumper = CompFactory.TileBeamElemDumper
152 TileBeamElemContainer=
'TileBeamElemCnt',
153 Prefix=f
'{dumpDirectory}/'))
155 cfg.addEventAlgo(
Finalizer(
'TileBeamElemCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
160 """ Configure test of reading the Tile muon receiver container from BS """
162 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
165 TileMuonReceiverDumper = CompFactory.TileMuonReceiverDumper
167 TileMuonReceiverContainer=
'TileMuRcvCnt',
168 Prefix=f
'{dumpDirectory}/'))
170 cfg.addEventAlgo(
Finalizer(
'TileMuRcvCompareAlg', refDirectory=refDirectory, dumpDirectory=dumpDirectory))
174 if __name__ ==
"__main__":
176 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
177 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
178 from AthenaCommon.Logging
import log
185 parser = flags.getArgumentParser()
186 tests_group = parser.add_argument_group(
'Test of reading Tile raw data from BS')
187 tests = tests_group.add_mutually_exclusive_group()
188 tests.add_argument(
'--digits', action=
'store_true', help=
'Test of reading Tile digits container from BS')
189 tests.add_argument(
'--murcv', action=
'store_true', help=
'Test of reading Tile muon receiver container from BS')
190 tests.add_argument(
'--level2', action=
'store_true', help=
'Test of reading Tile L2 container from BS')
191 tests.add_argument(
'--raw-channels', dest=
'rawChannels', action=
'store_true', help=
'Test of reading Tile raw channel container from BS')
192 tests.add_argument(
'--laser-object', dest=
'laserObject', action=
'store_true', help=
'Test of reading Tile laser object from BS')
193 tests.add_argument(
'--beam-elements', dest=
'beamElements', action=
'store_true', help=
'Test of reading Tile beam elements container from BS')
194 args, _ = parser.parse_known_args()
196 if not any([args.digits, args.rawChannels, args.murcv, args.laserObject, args.beamElements, args.level2]):
197 log.info(
'No tests are requested. Exiting ...')
200 if any([args.murcv, args.laserObject]):
201 flags.Input.Files = [
getInputFile(
'data18_tilecomm.00363899.calibration_tile.daq.RAW._lb0000._TileREB-ROS._0005-200ev.data')]
202 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
204 flags.Input.Files = [
getInputFile(
'data12_8TeV.00204073.physics_JetTauEtmiss.merge.RAW._lb0144._SFO-5._0001.1')]
205 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN1_2012
207 flags.Exec.MaxEvents = 100
208 flags.Tile.RunType = TileRunType.PHY
209 flags.IOVDb.DatabaseInstance =
'CONDBR2'
210 flags.fillFromArgs(parser=parser)
214 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
221 elif args.rawChannels:
224 elif args.laserObject:
230 elif args.beamElements:
237 cfg.printConfig(withDetails=
True)
240 os.system(f
'rm -rf {dumpDirectory}')
241 os.system(f
'mkdir -p {dumpDirectory}')
247 sys.exit(
not sc.isSuccess())