5 '''@file RunTileMonitoring.py
6 @brief Script to run Tile Reconstrcution/Monitoring with new-style configuration
9 from AthenaConfiguration.ComponentFactory
import CompFactory
10 from AthenaConfiguration.Enums
import BeamType, Format, LHCPeriod
11 from TileConfiguration.TileConfigFlags
import TileRunType
15 Configure the following flags from partition in online: run number, beam type, and project
18 from ipc
import IPCPartition
19 from ispy
import ISObject
20 ipcPartition = IPCPartition(partition)
21 if not ipcPartition.isValid():
22 log.error(
'Partition: ' + ipcPartition.name() +
' is not valid' )
25 runParams = ISObject(ipcPartition,
'RunParams.SOR_RunParams',
'RunParams')
29 projectName =
'data20_calib'
30 log.warning(
"No Run Parameters in IS => Set defaults: partition: %s, beam type: %i, run number: %i, project tag: %s",
31 partition, beamType, runNumber, projectName)
34 beamType = runParams.beam_type
35 beamEnergy = runParams.beam_energy
36 runNumber = runParams.run_number
37 projectName = runParams.T0_project_tag
38 runType = runParams.run_type
39 log.info(
"RUN CONFIG: partition: %s, run type: %s, beam type: %i, beam energy: %i, run number: %i, project tag: %s",
40 partition, runType, beamType, beamEnergy, runNumber, projectName)
42 if any([projectName.endswith(_)
for _
in (
"cos",
"test",
"calib")]):
44 elif projectName.endswith(
'1beam'):
45 beamType =
'singlebeam'
47 beamType =
'collisions'
51 if partition ==
'Tile':
52 flags.Tile.NoiseFilter = 0
54 flags.Tile.RunType = TileRunType.MONOCIS
if 'mono' in runType
else TileRunType.CIS
55 elif 'Laser' in runType:
56 flags.Tile.RunType = TileRunType.LAS
57 elif 'Pedestals' in runType:
58 flags.Tile.RunType = TileRunType.PED
61 flags.Input.ProjectName = projectName
62 flags.Input.RunNumbers = [runNumber]
65 if __name__==
'__main__':
69 group = parser.add_mutually_exclusive_group()
70 destination = dest
if dest
else argument
71 group.add_argument(
'--' + argument, dest=destination, action=
'store_true', help=
"Switch on " + help)
72 group.add_argument(
'--no-' + argument, dest=destination, action=
'store_false', help=
"Switch off " + help)
74 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
76 parser = flags.getArgumentParser()
77 parser.add_argument(
'--preExec', help=
'Code to execute before locking configs')
78 parser.add_argument(
'--postExec', help=
'Code to execute after setup')
79 parser.add_argument(
'--printDetailedConfig', action=
'store_true', help=
'Print detailed Athena configuration')
80 parser.add_argument(
'--dumpArguments', action=
'store_true', help=
'Print arguments and exit')
86 _addBoolArgument(parser,
'towers', help=
'Tile Calorimeter Towers monitoring')
87 _addBoolArgument(parser,
'clusters', help=
'Tile Calorimeter Clusters monitoring')
89 _addBoolArgument(parser,
'muonfit', help=
'Tile Calorimeter MuonFit monitoring')
92 _addBoolArgument(parser,
'digi-noise',dest=
'digiNoise', help=
'Tile digi noise monitoring')
93 _addBoolArgument(parser,
'raw-chan-noise',dest=
'rawChanNoise', help=
'Tile raw channel noise monitoring')
95 _addBoolArgument(parser,
'tmdb-digits', dest=
'tmdbDigits', help=
'TMDB digits monitoring')
96 _addBoolArgument(parser,
'tmdb-raw-channels', dest=
'tmdbRawChannels', help=
'TMDB raw channels monitoring')
99 parser.add_argument(
'--no-mon', action=
'store_false', dest=
'mon', help=
'Do not run Tile monitoring algorithms')
100 parser.add_argument(
'--cosmics', action=
'store_true', help=
'Use cosmics streams for online Tile monitoring')
101 parser.add_argument(
'--jivexml', action=
'store_true', help=
'Create Jive XML output')
102 parser.add_argument(
'--stateless', action=
"store_true", help=
'Run Online Tile monitoring in partition')
103 parser.add_argument(
'--use-mbts-trigger', action=
"store_true", dest=
'useMbtsTrigger', help=
'Use L1 MBTS triggers')
104 parser.add_argument(
'--partition', default=
"", help=
'EMON, Partition name, default taken from $TDAQ_PARTITION if not set')
105 parser.add_argument(
'--key', type=str, default=
"",
106 help=
'EMON, Selection key, e.g.: SFI, default: dcm (ATLAS), CompleteEvent (TileMon), ReadoutApplication (Tile)')
107 parser.add_argument(
'--keyValue', default=[],
108 help=
'EMON, Key values, e.g. [SFI-1, SFI-2]; if empty all SFIs; default: "" (*), TileREB-ROS (Tile)')
109 parser.add_argument(
'--keyCount', type=int, default=50,
110 help=
'EMON, key count, e.g. 5 to get five random SFIs, default: 50 (physics), 1000 (laser:CIS)')
111 parser.add_argument(
'--publishName', default=
'TilePT-stateless-10', help=
'EMON, Name under which to publish histograms')
112 parser.add_argument(
'--include', default=
"", help=
'EMON, Regular expression to select histograms to publish')
113 parser.add_argument(
'--lvl1Items', default=[], help=
'EMON, A list of L1 bit numbers, default []')
114 parser.add_argument(
'--lvl1Names', default=[], help=
'EMON, A list of L1 bit names, default []')
115 parser.add_argument(
'--lvl1Logic', default=
'Ignore', choices=[
'And',
'Or',
'Ignore'], help=
'EMON, default: Ignore')
116 parser.add_argument(
'--lvl1Origin', default=
'TAV', choices=[
'TBP',
'TAP',
'TAV'], help=
'EMON, default: TAV')
117 parser.add_argument(
'--streamType', default=
'physics', help=
'EMON, HLT stream type (e.g. physics or calibration)')
118 parser.add_argument(
'--streamNames', default=[
'express',
'Main',
'Standby',
'L1Calo',
'ZeroBias',
'Background',
'MinBias'], help=
'EMON, List of HLT stream names')
119 parser.add_argument(
'--streamLogic', default=
'Or', choices=[
'And',
'Or',
'Ignore'], help=
'EMON, default: Or')
120 parser.add_argument(
'--triggerType', type=int, default=256, help=
'EMON, LVL1 8 bit trigger type, default: 256')
121 parser.add_argument(
'--groupName', default=
"TilePhysMon", help=
'EMON, Name of the monitoring group')
122 parser.add_argument(
'--postProcessingInterval', type=int, default=10000000,
123 help=
'Number of events between postprocessing steps (<0: disabled, >evtMax: during finalization)')
125 update_group = parser.add_mutually_exclusive_group()
126 update_group.add_argument(
'--frequency', type=int, default=0, help=
'EMON, Frequency (in number of events) of publishing histograms')
127 update_group.add_argument(
'--updatePeriod', type=int, default=60, help=
'EMON, Frequency (in seconds) of publishing histograms')
129 args, _ = parser.parse_known_args()
133 parser.set_defaults(cells=
False, towers=
False, clusters=
False, muid=
False, muonfit=
False, mbts=
False,
134 rod=
False, tmdb=
False, tmdbDigits=
False, tmdbRawChannels=
False)
135 elif not any([args.laser, args.cis, args.noise, args.mbts]):
136 mbts =
not (args.stateless
and args.useMbtsTrigger)
137 parser.set_defaults(cells=
True, towers=
True, clusters=
True, muid=
True, muonfit=
None, mbts=mbts,
138 rod=
True, tmdb=
True, tmdbDigits=
True, tmdbRawChannels=
True)
140 parser.set_defaults(digiNoise=
True, rawChanNoise=
True)
143 parser.set_defaults(online=
True)
144 partition = args.partition
if args.partition
else os.getenv(
'TDAQ_PARTITION',
'ATLAS')
146 keys = {
'ATLAS' :
'dcm',
'TileMon' :
'CompleteEvent',
'Tile' :
'ReadoutApplication'}
147 key = args.key
if args.key
else keys.get(partition,
'dcm')
149 keyValues = {
'Tile': [
'TileREB-ROS']}
150 keyValue = args.keyValue
if args.keyValue
else keyValues.get(partition, [])
153 updatePeriod = 0
if args.frequency > 0
else args.updatePeriod
154 parser.set_defaults(partition=partition, key=key, keyValue=keyValue, updatePeriod=updatePeriod)
156 if any([args.laser, args.cis]):
157 calibGroupName =
'TileLasMon' if args.laser
else 'TileCisMon'
158 parser.set_defaults(streamType=
'calibration', streamNames=[
'Tile'], streamLogic=
'And', keyCount=1000, groupName=calibGroupName)
160 publishInclude =
".*Summary.*|.*DMUErrors.*|.*DigiNoise.*"
161 parser.set_defaults(streamType=
'physics', streamNames=[
'CosmicCalo'], streamLogic=
'And', include=publishInclude,
162 triggerType=0x82, frequency=300, updatePeriod=0, keyCount=100, groupName=
'TileNoiseMon', postProcessingInterval=299)
166 _l1Names = [
'L1_MBTS_1',
'L1_MBTS_1_EMPTY',
'L1_MBTS_1_1_EMPTY']
167 _l1Names += [
'L1_MBTSA' +
str(counter)
for counter
in range(0, 16)]
168 _l1Names += [
'L1_MBTSC' +
str(counter)
for counter
in range(0, 16)]
169 parser.set_defaults(lvl1Logic=
'Or', lvl1Origin=
'TBP', lvl1Items=_l1Items, lvl1Names=_l1Names,
170 keyCount=100, groupName=
'TileMBTSMon', useMbtsTrigger =
True)
172 parser.set_defaults(postProcessingInterval=100, groupName=
'TileCosmicsMon', streamNames=[
'CosmicCalo',
'CosmicMuons',
'IDCosmic'])
174 parser.set_defaults(postProcessingInterval=100)
176 args, _ = parser.parse_known_args()
179 from AthenaCommon.Logging
import log
183 if args.dumpArguments:
184 log.info(
'=====>>> FINAL ARGUMENTS FOLLOW')
185 print(
'{:40} : {}'.
format(
'Argument Name',
'Value'))
186 for a,v
in (vars(args)).
items():
187 print(f
'{a:40} : {v}')
191 flags.DQ.useTrigger =
False
192 flags.DQ.enableLumiAccess =
False
193 flags.Tile.RunType = TileRunType.PHY
194 flags.LAr.doHVCorr =
False
196 if args.mbts
and args.useMbtsTrigger:
197 flags.Trigger.triggerConfig =
'DB'
199 flags.Input.Files = []
202 flags.Input.isMC =
False
203 flags.Input.Format = Format.BS
204 flags.GeoModel.Run = LHCPeriod.Run3
205 if args.mbts
and args.useMbtsTrigger:
206 if args.partition
in [
'TileMon']:
207 flags.Trigger.triggerConfig =
'DB:{:s}:{:d},{:d},{:d},{:d}'.
format(
'TRIGGERDB_RUN3', 3185, 4357, 4219, 2543)
209 beamType = flags.Beam.Type
210 from AthenaConfiguration.AutoConfigOnlineRecoFlags
import autoConfigOnlineRecoFlags
212 flags.Beam.Type = beamType
216 flags.fillFromArgs(parser=parser)
217 if not (args.filesInput
or flags.Input.Files):
219 inputDirectory =
"/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TileByteStream/TileByteStream-02-00-00"
220 inputFile =
"data18_tilecomm.00363899.calibration_tile.daq.RAW._lb0000._TileREB-ROS._0005-200ev.data"
221 flags.Input.Files = [os.path.join(inputDirectory, inputFile)]
222 flags.Input.RunNumbers = [363899]
224 inputDirectory =
"/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TileByteStream/TileByteStream-02-00-00"
225 inputFile =
"data18_tilecomm.00363899.calibration_tile.daq.RAW._lb0000._TileREB-ROS._0005-200ev.data"
226 flags.Input.Files = [os.path.join(inputDirectory, inputFile)]
227 flags.Input.RunNumbers = [363899]
229 inputDirectory =
'root://eosatlas.cern.ch//eos/atlas/atlascerngroupdisk/det-tile/test'
230 inputFile =
'data12_8TeV.00201555.physics_ZeroBiasOverlay.merge.RAW._lb0150._SFO-ALL._0001.1'
231 flags.Input.Files = [os.path.join(inputDirectory, inputFile)]
233 from AthenaConfiguration.TestDefaults
import defaultTestFiles
234 flags.Input.Files = defaultTestFiles.RAW_RUN2
236 if any([args.cis, args.laser]):
237 flags.Input.ProjectName = flags.Input.Files[0].
split(os.path.sep)[-1].
split(
'.')[0]
239 runNumber = flags.Input.RunNumbers[0]
240 if not flags.Input.isMC:
241 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
242 flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
244 if not flags.Output.HISTFileName:
245 flags.Output.HISTFileName =
'tilemon_{}.root'.
format(runNumber)
248 flags.Common.isOnline =
True
249 if flags.Common.isOnline:
250 flags.IOVDb.GlobalTag =
'CONDBR2-HLTP-2025-01' if runNumber > 232498
else 'COMCOND-HLTP-004-02'
251 flags.DQ.Environment =
'online'
252 flags.DQ.FileKey =
''
254 flags.IOVDb.GlobalTag =
'CONDBR2-BLKPA-2025-03' if runNumber > 232498
else 'COMCOND-BLKPA-RUN1-06'
256 if any([args.laser, args.cis]):
258 flags.Tile.RunType = TileRunType.GAPLAS
260 flags.Tile.RunType = TileRunType.GAPCIS
261 flags.Tile.doFit =
True
262 flags.Tile.correctTime =
True
263 flags.Tile.doOverflowFit =
False
264 flags.Tile.BestPhaseFromCOOL =
True
265 flags.Tile.NoiseFilter = 1
268 flags.Output.doJiveXML =
True
271 flags.fillFromArgs(parser=parser)
274 log.info(
'Executing preExec: %s', args.preExec)
277 log.info(
'=====>>> FINAL CONFIG FLAGS SETTINGS FOLLOW')
278 flags.dump(pattern=
'Tile.*|Input.*|Exec.*|IOVDb.[D|G].*', evaluate=
True)
283 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
286 typeNames = [
'CTP_RDO/CTP_RDO']
if args.mbts
and args.useMbtsTrigger
else []
288 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
290 readMuRcvDigits=any([args.tmdbDigits, args.tmdb]),
291 readMuRcvRawCh=any([args.tmdbRawChannels, args.tmdb]),
293 stateless=args.stateless,
294 type_names=typeNames) )
297 jobs = [
'cosmics',
'mbts',
'noise',
'laser',
'cis']
298 bufferSize = 200
if any(job
in args.publishName
for job
in jobs)
else 500
300 bsEmonInputSvc = cfg.getService(
"ByteStreamInputSvc" )
301 bsEmonInputSvc.Partition = args.partition
302 bsEmonInputSvc.Key = args.key
303 bsEmonInputSvc.KeyValue = args.keyValue
304 bsEmonInputSvc.KeyCount = args.keyCount
305 bsEmonInputSvc.PublishName = args.publishName
306 bsEmonInputSvc.ISServer =
'Histogramming'
307 bsEmonInputSvc.Include = args.include
308 bsEmonInputSvc.UpdatePeriod = args.updatePeriod
309 bsEmonInputSvc.Frequency = args.frequency
310 bsEmonInputSvc.LVL1Items = args.lvl1Items
311 bsEmonInputSvc.LVL1Names = args.lvl1Names
312 bsEmonInputSvc.LVL1Logic = args.lvl1Logic
313 bsEmonInputSvc.LVL1Origin = args.lvl1Origin
314 bsEmonInputSvc.StreamType =
'express' if flags.Beam.Type
is BeamType.SingleBeam
else args.streamType
315 bsEmonInputSvc.StreamNames = args.streamNames
316 bsEmonInputSvc.StreamLogic = args.streamLogic
317 bsEmonInputSvc.GroupName = args.groupName
318 bsEmonInputSvc.ProcessCorruptedEvents =
True
319 bsEmonInputSvc.BufferSize = bufferSize
322 cfg.getEventAlgo(
'SGInputLoader').ExtraOutputs=[(
"xAOD::EventInfo",
"StoreGateSvc+EventInfo"),(
"xAOD::EventAuxInfo",
"StoreGateSvc+EventInfoAux.")]
324 cfg.addPublicTool( CompFactory.TileROD_Decoder(fullTileMode = runNumber) )
326 from TileRecUtils.TileRawChannelMakerConfig
import TileRawChannelMakerCfg
329 l1Triggers = [
'bit0_RNDM',
'bit1_ZeroBias',
'bit2_L1Cal',
'bit3_Muon',
330 'bit4_RPC',
'bit5_FTK',
'bit6_CTP',
'bit7_Calib',
'AnyPhysTrig']
332 if any([args.laser, args.cis]):
333 triggerTypes = [0x34]
if args.laser
else [0x32]
334 from TileMonitoring.TileRawChannelTimeMonitorAlgorithm
import TileRawChannelTimeMonitoringConfig
338 from TileMonitoring.TileRODMonitorAlgorithm
import TileRODMonitoringConfig
342 from TileMonitoring.TileTMDBDigitsMonitorAlgorithm
import TileTMDBDigitsMonitoringConfig
345 if args.tmdbRawChannels:
346 from TileMonitoring.TileTMDBRawChannelMonitorAlgorithm
import TileTMDBRawChannelMonitoringConfig
350 from TileMonitoring.TileTMDBMonitorAlgorithm
import TileTMDBMonitoringConfig
353 muonfit = flags.Beam.Type
is not BeamType.Collisions
if args.muonfit
is None else args.muonfit
354 if any([args.cells, args.towers, args.clusters, args.mbts, args.muid, muonfit, flags.Output.doJiveXML]):
355 from TileRecUtils.TileCellMakerConfig
import TileCellMakerCfg
359 from TileMonitoring.TileCellMonitorAlgorithm
import TileCellMonitoringConfig
361 fillGapScintilatorHistograms=
True, fillChannelTimeHistograms=
True))
364 from TileMonitoring.TileTowerMonitorAlgorithm
import TileTowerMonitoringConfig
368 from TileMonitoring.TileClusterMonitorAlgorithm
import TileClusterMonitoringConfig
372 from TileMonitoring.TileMBTSMonitorAlgorithm
import TileMBTSMonitoringConfig
376 from TileMuId.TileMuIdConfig
import TileLookForMuAlgCfg
379 from TileMonitoring.TileMuIdMonitorAlgorithm
import TileMuIdMonitoringConfig
383 from TileCosmicAlgs.TileMuonFitterConfig
import TileMuonFitterCfg
384 cfg.merge(
TileMuonFitterCfg(flags, Cardinality=args.threads
if args.threads
else 0))
386 from TileMonitoring.TileMuonFitMonitorAlgorithm
import TileMuonFitMonitoringConfig
390 from TileMonitoring.TileDigiNoiseMonitorAlgorithm
import TileDigiNoiseMonitoringConfig
393 if args.rawChanNoise:
394 from TileMonitoring.TileRawChannelNoiseMonitorAlgorithm
import TileRawChannelNoiseMonitoringConfig
397 from TileMonitoring.TileDQFragMonitorAlgorithm
import TileDQFragMonitoringConfig
400 if any([args.digiNoise, args.rawChanNoise, args.tmdbDigits, args.tmdb])
and args.postProcessingInterval > 0:
401 from AthenaCommon.Utils.unixtools
import find_datafile
404 if any([args.tmdbDigits, args.tmdb]):
405 configurations += [os.path.join(dataPath,
'TileTMDBPostProc.yaml')]
407 configurations += [os.path.join(dataPath,
'TileDigiNoisePostProc.yaml')]
408 if args.rawChanNoise:
409 configurations += [os.path.join(dataPath,
'TileRawChanNoisePostProc.yaml')]
411 from DataQualityUtils.DQPostProcessingAlg
import DQPostProcessingAlg
414 if hasattr(self,
'OutputLevel'):
416 return super(TileMonPostProcessingAlg, self).
initialize()
419 ppa.OutputLevel = flags.Exec.OutputLevel
420 ppa.ExtraInputs = {(
'xAOD::EventInfo' ,
'StoreGateSvc+EventInfo' )}
421 ppa.Interval = args.postProcessingInterval
422 ppa.ConfigFiles = configurations
423 if not hasattr(ppa,
'_descriptors'):
424 ppa._descriptors = {}
426 if flags.Common.isOnline:
427 fileKey = flags.DQ.FileKey
428 ppa.FileKey = (fileKey +
'/')
if not fileKey.endswith(
'/')
else fileKey
430 ppa.FileKey = f
'/{flags.DQ.FileKey}/run_{runNumber}/'
432 cfg.addEventAlgo(ppa, sequenceName=
'AthEndSeq')
434 if flags.Output.doJiveXML:
435 from TileMonitoring.TileJiveXMLConfig
import TileAlgoJiveXMLCfg
441 log.info(
'Executing postExec: %s', args.postExec)
444 if flags.Common.isOnline:
445 cfg.getService(
"THistSvc").Output=[
"Tile DATAFILE='%s' OPT='RECREATE'" % (flags.Output.HISTFileName)]
446 cfg.getService(
"TileCablingSvc").CablingType=6
448 if args.stateless
and args.cis:
449 cfg.getEventAlgo(
'TileDQstatusAlg').TileBeamElemContainer=
""
451 cfg.printConfig(withDetails=args.printDetailedConfig,
452 summariseProps=args.printDetailedConfig,
453 printDefaults=args.printDetailedConfig)
456 sys.exit(0
if sc.isSuccess()
else 1)