6 @author Salah-Eddine Dahbi, Song-Ming Wang
7 @brief Global Monitoring job option to run online DQ with new-style configuration.
8 -- Offline on lxplus for ART test :
9 --- python GlobalMonitoring.py IOVDb.GlobalTag="conditions_Tag" --offline --filesInput [path_to_RAW_data_file] --evtMax [Max_number_events]
10 --- note: if the filesInput is not provided a defaultTestFile will be used.
11 --- note: if the evtMax is not provided, the default is 100.
13 -- Online is the default: python GlobalMonitoring.py"
16 if __name__==
'__main__':
19 from AthenaConfiguration.Enums
import BeamType
20 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
21 from AthenaConfiguration.ComponentFactory
import CompFactory
22 from AthenaConfiguration.Enums
import Format
24 parser = flags.getArgumentParser()
25 parser.add_argument(
'--offline', action=
'store_true', help=
"Run in offline mode (default is online)")
27 parser.set_defaults(threads=1)
28 args, _ = parser.parse_known_args()
29 is_online =
not args.offline
30 flags.fillFromArgs(parser=parser)
33 from AthenaCommon.Logging
import log
34 from AthenaCommon
import Constants
36 log.setLevel(getattr(Constants, args.loglevel))
39 print(
"Running in online mode")
40 partitionName = os.environ.get(
"TDAQ_PARTITION",
"ATLAS")
42 from AthenaConfiguration.AutoConfigOnlineRecoFlags
import autoConfigOnlineRecoFlags
45 flags.Concurrency.NumThreads = 1
46 flags.Exec.MaxEvents = -1
50 from ispy
import IPCPartition, ISObject
51 p = IPCPartition(partitionName)
53 print(
"Partition:", p.name(),
"is not valid")
57 flags.DQ.useTrigger =
True
58 flags.DQ.triggerDataAvailable =
True
59 flags.DQ.enableLumiAccess =
False
60 print(
"Online mode setup complete.")
64 print(
"Running in offline mode")
65 partitionName =
'GMTestPartition'
68 flags.DQ.useTrigger =
False
69 flags.Reco.EnableTrigger =
False
70 flags.DQ.triggerDataAvailable =
False
71 flags.LAr.doHVCorr =
False
72 flags.DQ.enableLumiAccess =
True
73 isOnlineStateless =
True
76 print(
"Offline mode setup complete.")
85 detDescrVersion =
'ATLAS-R3S-2021-03-02-00'
86 flags.IOVDb.DatabaseInstance =
"CONDBR2"
87 flags.GeoModel.Layout=
"atlas"
88 flags.GeoModel.AtlasVersion = detDescrVersion
90 flags.Trigger.triggerConfig=
'DB'
92 if partitionName ==
"ATLAS" or partitionName ==
'ATLAS_MP1':
94 y = ISObject(p,
'RunParams.RunParams',
'RunParams')
96 print(
"Could not find Run Parameters in IS - Set default beam type to 'cosmics'")
97 beamType=BeamType.Cosmics
100 beamtype = y.beam_type
101 beamenergy = y.beam_energy
102 runnumber = y.run_number
103 project = y.T0_project_tag
104 print(
"RUN CONFIGURATION: beam type %i, beam energy %i, run number %i, project tag %s"%(beamtype,beamenergy,runnumber,project))
106 if project[7:10]==
"cos":
107 beamType=BeamType.Cosmics
109 beamType=BeamType.Collisions
112 beamType=BeamType.Collisions
114 flags.Beam.Type = beamType
115 flags.Beam.BunchSpacing = 25
116 print(
"RUN CONFIGURATION: Beamtype =",flags.Beam.Type)
118 if partitionName
not in [
'ATLAS',
'ATLAS_MP1']:
119 from AthenaConfiguration.TestDefaults
import defaultTestFiles
121 if not args.filesInput
and args.offline:
122 flags.Input.Files = defaultTestFiles.RAW_RUN3_DATA24
125 flags.Exec.MaxEvents = 100
127 if flags.Input.Format
is Format.BS :
128 if flags.DQ.Environment
not in (
'tier0',
'tier0Raw',
'online'):
129 log.warning(
'Reading RAW file, but DQ.Environment set to %s',
130 flags.DQ.Environment)
131 log.warning(
'Will proceed but best guess is this is an error')
132 log.info(
'Will schedule reconstruction, as best we know')
134 if flags.DQ.Environment
in (
'tier0',
'tier0Raw',
'online'):
135 log.warning(
'Reading POOL file, but DQ.Environment set to %s',
136 flags.DQ.Environment)
137 log.warning(
'Will proceed but best guess is this is an error')
139 flags.Common.isOnline =
True
142 print(f
"Partition: {partitionName}")
143 print(f
"Max events: {flags.Exec.MaxEvents}")
144 print(f
"Run numbers: {flags.Input.RunNumbers}")
145 print(f
"Lumi block numbers: {flags.Input.LumiBlockNumbers}")
146 print(f
"Is online: {flags.Common.isOnline}")
148 flags.Input.isMC =
False
150 flags.InDet.useSctDCS =
False
151 flags.InDet.useDCS =
False
153 flags.DQ.doMonitoring =
True
154 flags.DQ.doPostProcessing =
True
156 flags.DQ.FileKey =
''
157 flags.DQ.Environment =
'online'
158 flags.Output.HISTFileName =
'monitoring.root'
159 flags.LAr.doHVCorr =
False
160 flags.Detector.EnableCalo =
True
166 flags.DQ.Steering.doGlobalMon =
False
168 flags.DQ.Steering.doHLTMon =
False
170 flags.DQ.Steering.doZDCMon =
False
172 flags.DQ.Steering.doLVL1CaloMon =
False
173 flags.DQ.Steering.doLVL1InterfacesMon =
False
175 flags.DQ.Steering.doDataFlowMon =
False
177 flags.DQ.Steering.doCTPMon =
False
178 if partitionName
not in [
'ATLAS',
'ATLAS_MP1'] :
179 flags.DQ.useTrigger =
False
180 flags.DQ.triggerDataAvailable =
False
181 flags.Reco.EnableTrigger =
False
183 log.info(
'FINAL CONFIG FLAGS SETTINGS FOLLOW')
184 if args.loglevel
is None or getattr(Constants, args.loglevel) <= Constants.INFO:
188 from AthenaConfiguration.ComponentFactory
import CompFactory
189 from SGComps.SGInputLoaderConfig
import SGInputLoaderCfg
192 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
194 acc.addService(CompFactory.ByteStreamCnvSvc(), primary=
True)
199 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
202 if not args.offline
and not args.filesInput:
203 from ByteStreamEmonSvc.EmonByteStreamConfig
import EmonByteStreamCfg
205 bytestreamInput = acc.getService(
"ByteStreamInputSvc")
210 bytestreamInput.Partition = partitionName
212 bytestreamInput.Key =
"dcm"
213 bytestreamInput.KeyCount = 40
214 bytestreamInput.BufferSize = 120
220 bytestreamInput.Timeout = 600000
222 bytestreamInput.UpdatePeriod = 200
224 bytestreamInput.StreamNames = [
'express']
225 bytestreamInput.StreamType =
"physics"
226 bytestreamInput.StreamLogic =
"Or"
228 bytestreamInput.PublishName = os.environ.get(
"TDAQ_APPLICATION_NAME",
"GlobalMonitoring")
229 bytestreamInput.ISServer =
'Histogramming-Global-iss'
230 if partitionName !=
'ATLAS' and partitionName !=
'ATLAS_MP1':
231 bytestreamInput.ISServer =
'Histogramming'
234 if partitionName ==
'ATLAS' or partitionName ==
'ATLAS_MP1':
235 from PyUtils.OnlineISConfig
import GetAtlasReady
236 if beamType == BeamType.Cosmics:
237 bytestreamInput.StreamNames = [
'express',
'IDCosmic',
'HLT_IDCosmic',
'CosmicMuons',
'CosmicCalo']
241 bytestreamInput.StreamNames = [
'express']
243 bytestreamInput.StreamType =
"express"
246 bytestreamInput.StreamNames = [
'express',
'IDCosmic',
'HLT_IDCosmic',
'CosmicMuons',
'MinBias',
'Standby',
'Main',
'CosmicCalo']
249 bytestreamInput.StreamLogic =
'Ignore'
250 bytestreamInput.PublishName =
'GMT9_sdahbi_R55'
252 from xAODEventInfoCnv.xAODEventInfoCnvConfig
import EventInfoBeamSpotDecoratorAlgCfg
256 acc.flagPerfmonDomain(
'Calo')
257 if flags.Detector.EnableCalo:
258 from CaloRec.CaloRecoConfig
import CaloRecoCfg
262 acc.flagPerfmonDomain(
'CaloExtension')
263 if flags.Reco.EnableCaloExtension:
264 from TrackToCalo.CaloExtensionBuilderAlgCfg
import (
265 CaloExtensionBuilderCfg)
268 acc.flagPerfmonDomain(
'CaloRings')
269 if flags.Reco.EnableCaloRinger:
270 from CaloRingerAlgs.CaloRingerAlgsConfig
import CaloRingerSteeringCfg
273 acc.flagPerfmonDomain(
'ID')
274 if flags.Reco.EnableTracking:
275 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
279 acc.flagPerfmonDomain(
'Muon')
280 if flags.Detector.EnableMuon:
281 from MuonConfig.MuonReconstructionConfig
import MuonReconstructionCfg
285 acc.flagPerfmonDomain(
'CombinedMuon')
286 if flags.Reco.EnableCombinedMuon:
287 from MuonCombinedConfig.MuonCombinedReconstructionConfig
import (
288 MuonCombinedReconstructionCfg)
292 acc.flagPerfmonDomain(
'Jets')
293 if flags.Reco.EnableJet:
294 from JetRecConfig.JetRecoSteering
import JetRecoSteeringCfg
299 acc.flagPerfmonDomain(
'TrackCellAssociation')
300 if flags.Reco.EnableTrackCellAssociation:
301 from TrackParticleAssociationAlgs.TrackParticleAssociationAlgsConfig
import (
302 TrackParticleCellAssociationCfg)
305 acc.flagPerfmonDomain(
'Jets')
306 if flags.Reco.EnableGlobalFELinking:
310 from eflowRec.PFCfg
import PFGlobalFlowElementLinkingCfg
313 acc.flagPerfmonDomain(
'PFlow')
314 if flags.Reco.EnablePFlow:
315 from eflowRec.PFRun3Config
import PFCfg
316 acc.merge(
PFCfg(flags))
318 acc.flagPerfmonDomain(
'EGamma')
319 if flags.Reco.EnableEgamma:
320 from egammaConfig.egammaSteeringConfig
import EGammaSteeringCfg
323 acc.flagPerfmonDomain(
'Tau')
324 if flags.Reco.EnableTau:
325 from tauRec.TauConfig
import TauReconstructionCfg
329 acc.flagPerfmonDomain(
'Trigger')
330 if flags.Reco.EnableTrigger:
331 from TriggerJobOpts.TriggerRecoConfig
import TriggerRecoCfg
335 acc.flagPerfmonDomain(
'MET')
336 if flags.Reco.EnableMet:
337 from METReconstruction.METRecCfg
import METCfg
341 acc.flagPerfmonDomain(
'Isolation')
342 if flags.Reco.EnableIsolation:
343 from IsolationAlgs.IsolationSteeringConfig
import IsolationSteeringCfg
347 acc.flagPerfmonDomain(
'Lucid')
348 if flags.Detector.EnableLucid:
349 from ForwardRec.LucidRecConfig
import LucidRecCfg
353 acc.flagPerfmonDomain(
'HI')
354 if flags.Reco.EnableHI:
355 from HIRecConfig.HIRecConfig
import HIRecCfg
359 acc.flagPerfmonDomain(
'FTag')
360 if flags.Reco.EnableBTagging:
361 from BTagging.BTagConfig
import BTagRecoSplitCfg
371 acc.flagPerfmonDomain(
'DQM')
372 if flags.DQ.doMonitoring:
373 from AthenaMonitoring.AthenaMonitoringCfg
import (AthenaMonitoringCfg, AthenaMonitoringPostprocessingCfg)
375 if flags.DQ.doPostProcessing:
379 if flags.DQ.Steering.doPixelMon:
380 from PixelMonitoring.PixelMonitoringConfig
import PixelMonitoringConfig
383 if flags.DQ.Steering.doSCTMon:
385 from SCT_Monitoring.SCTMonitoringConfig
import SCTMonitoringConfig
388 if flags.DQ.Steering.doTRTMon:
390 from TRTMonitoringRun3.TRTMonitoringRun3Config
import TRTMonitoringRun3Cfg
393 if flags.DQ.Steering.doInDetMon:
394 if flags.DQ.Steering.InDet.doGlobalMon:
396 from InDetGlobalMonitoringRun3Test.InDetGlobalMonitoringRun3TestConfig
import InDetGlobalMonitoringRun3TestConfig
398 if flags.DQ.Steering.InDet.doAlignMon:
400 from InDetAlignmentMonitoringRun3.InDetAlignmentMonitoringRun3Config
import InDetAlignmentMonitoringRun3Config
403 if flags.DQ.Steering.doLArMon:
405 from LArConfiguration.LArMonitoringConfig
import LArMonitoringConfig
408 if flags.DQ.Steering.doTileMon:
410 from TileMonitoring.TileMonitoringConfig
import TileMonitoringCfg
413 if flags.DQ.Steering.doCaloGlobalMon:
415 from CaloMonitoring.CaloMonitoringConfig
import CaloMonitoringCfg
418 if flags.DQ.Steering.doMuonMon:
420 from MuonDQAMonitoring.MuonDQAMonitoringConfig
import MuonDQAMonitoringConfig
423 if flags.DQ.Steering.doHLTMon:
425 from TrigHLTMonitoring.TrigHLTMonitorAlgorithm
import TrigHLTMonTopConfig
428 if flags.DQ.Steering.doJetTagMon:
430 from JetTagMonitoring.JetTagMonitorAlgorithm
import JetTagMonitorConfig
433 if flags.DQ.Steering.doEgammaMon:
435 from egammaPerformance.egammaMonitoringConfig
import egammaMonitoringConfig
438 if flags.DQ.Steering.doJetMon:
440 from JetMonitoring.JetMonitoringStandard
import standardJetMonitoring
444 if flags.DQ.Environment !=
'tier0ESD':
446 if not flags.Reco.EnableHI
or (flags.Reco.EnableHI
and flags.Tracking.doUPC) :
447 from eflowRec.PFCfg
import PFGlobalFlowElementLinkingCfg
450 from IOVDbSvc.IOVDbSvcConfig
import addOverride
451 acc.merge(
addOverride(flags,
"/TRT/Onl/Calib/PID_NN",
"TRTCalibPID_NN_v2", db=
""))
456 acc.getEventAlgo(
"AlgTRTMonitoringRun3RAW").doExpert =
True
464 acc.getService(
"PoolSvc").ReadCatalog += [
"xmlcatalog_file:/det/dqm/GlobalMonitoring/PoolFileCatalog_M7/PoolFileCatalog.xml"]
470 sys.exit(0
if sc.isSuccess()
else 1)