ATLAS Offline Software
GlobalMonitoring_CA.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 #
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 '''
6 @author Tulin Mete
7 @brief Global Monitoring job option to run online DQ with new-style configuration.
8 Include parts from StateLessPT_NewConfig.py and RecoSteering.py
9 '''
10 
11 if __name__=='__main__':
12  import sys
13  from AthenaConfiguration.AllConfigFlags import initConfigFlags
14  from AthenaConfiguration.ComponentFactory import CompFactory
15  from AthenaConfiguration.Enums import Format
16  flags = initConfigFlags()
17 
18  # ############################################################
19  # Get partition name
20  # ############################################################
21  import os
22  partitionName = os.environ.get("TDAQ_PARTITION", "ATLAS")
23 
24  from ispy import IPCPartition, ISObject
25 
26  # ################################
27  # To read run parameters from IS
28  # ################################
29  p = IPCPartition(partitionName)
30  if not p.isValid():
31  print("Partition:",p.name(),"is not valid")
32  sys.exit(1)
33 
34 
35  from AthenaConfiguration.Enums import BeamType
36 
37  if partitionName == "ATLAS" or partitionName == 'ATLAS_MP1':
38  try:
39  y = ISObject(p, 'RunParams.RunParams', 'RunParams')
40  except:
41  print("Could not find Run Parameters in IS - Set default beam type to 'cosmics'")
42  beamType=BeamType.Cosmics
43  else:
44  y.checkout()
45  beamtype = y.beam_type
46  beamenergy = y.beam_energy
47  runnumber = y.run_number
48  project = y.T0_project_tag
49  print("RUN CONFIGURATION: beam type %i, beam energy %i, run number %i, project tag %s"%(beamtype,beamenergy,runnumber,project))
50  # Define beam type based on project tag name
51  if project[7:10]=="cos":
52  beamType=BeamType.Cosmics
53  else:
54  beamType=BeamType.Collisions
55 
56 
57  else:
58  beamType=BeamType.Collisions
59 
60  # ############################################################
61  # COND tag and GEO are needed
62  # for running over a test partition online
63  # ############################################################
64  conditionsTag = 'CONDBR2-HLTP-2022-02'
65  detDescrVersion = 'ATLAS-R3S-2021-03-00-00'
66 
67  # ############################################################
68  # Setting flags
69  # ############################################################
70  from AthenaConfiguration.AutoConfigOnlineRecoFlags import autoConfigOnlineRecoFlags
71  autoConfigOnlineRecoFlags(flags, partitionName)
72 
73  flags.Concurrency.NumThreads = 1
74 
75  flags.Exec.MaxEvents = -1
76 
77  flags.Beam.Type = beamType
78  flags.Beam.BunchSpacing = 25
79  print("RUN CONFIGURATION: Beamtype =",flags.Beam.Type)
80 
81  if partitionName != 'ATLAS' and partitionName != 'ATLAS_MP1':
82  flags.Input.ProjectName = 'data21_900GeV'
83  flags.Exec.MaxEvents = 20
84  flags.Input.RunNumbers = [431894]
85  flags.Input.LumiBlockNumbers = [1]
86 
87  flags.Common.isOnline = True
88 
89  flags.Input.Format = Format.BS
90  flags.Input.isMC = False
91 
92  flags.IOVDb.DatabaseInstance = "CONDBR2"
93  flags.IOVDb.GlobalTag = conditionsTag
94 
95  flags.GeoModel.Layout="atlas"
96  flags.GeoModel.AtlasVersion = detDescrVersion
97 
98  flags.Trigger.triggerConfig='DB'
99 
100  flags.InDet.useSctDCS = False
101 
102  flags.DQ.enableLumiAccess = False
103  flags.DQ.doMonitoring = True
104  flags.DQ.doPostProcessing = True
105  flags.DQ.useTrigger = True
106  flags.DQ.triggerDataAvailable = True
107  flags.DQ.FileKey = ''
108  flags.DQ.Environment = 'online'
109 
110  flags.LAr.doHVCorr = False
111 
112  if (partitionName != 'ATLAS' and partitionName != 'ATLAS_MP1'):
113  flags.DQ.useTrigger = False
114  flags.DQ.triggerDataAvailable = False
115 
116  # ############################################################
117  # Set reco flags
118  # ############################################################
119  flags.Detector.EnableCalo = True
120  flags.Reco.EnableTracking = True
121  flags.Detector.EnableMuon = True
122  flags.Reco.EnableCombinedMuon = True
123  flags.Reco.EnableJet = True
124  flags.Reco.EnablePFlow = True
125  flags.Reco.EnableEgamma = True
126  flags.Reco.EnableTrigger = True
127 
128  if (partitionName != 'ATLAS' and partitionName != 'ATLAS_MP1'):
129  flags.Reco.EnableTrigger = False
130 
131  flags.Reco.EnableMet = True
132  flags.Reco.EnableIsolation = True
133  flags.Detector.EnableLucid = True
134  flags.Reco.EnableHI = False
135  flags.Reco.EnableBTagging = True
136 
137  # ############################################################
138  # Set monitoring flags
139  # ############################################################
140 
141  flags.DQ.Steering.doCaloGlobalMon = True
142 
143  flags.DQ.Steering.doInDetMon = True
144  flags.DQ.Steering.InDet.doGlobalMon = True
145  flags.DQ.Steering.InDet.doAlignMon = True
146 
147  flags.DQ.Steering.doLArMon = True
148 
149  flags.DQ.Steering.doTileMon = True
150 
151  flags.DQ.Steering.doJetMon = True
152 
153  flags.DQ.Steering.doPixelMon = True
154 
155  flags.DQ.Steering.doSCTMon = False # Need to set this to True when ATLASRECTS-7652 is resolved
156 
157  flags.DQ.Steering.doTRTMon = True
158 
159  flags.DQ.Steering.doMuonMon = True
160 
161  flags.DQ.Steering.doMissingEtMon = True
162  flags.DQ.Steering.doEgammaMon = True
163  flags.DQ.Steering.doJetTagMon = True
164  flags.DQ.Steering.doTauMon = True
165  flags.DQ.Steering.doGlobalMon = False
166 
167  flags.DQ.Steering.doJetInputsMon = True
168 
169  flags.DQ.Steering.doHLTMon = True
170 
171  flags.DQ.Steering.doAFPMon = True
172 
173  flags.DQ.Steering.doZDCMon = False
174 
175  flags.DQ.Steering.doLVL1CaloMon = False
176  flags.DQ.Steering.doLVL1InterfacesMon = False
177 
178  flags.DQ.Steering.doDataFlowMon = False
179 
180  flags.DQ.Steering.doCTPMon = False
181 
182  if (partitionName != 'ATLAS' and partitionName != 'ATLAS_MP1'):
183  flags.DQ.Steering.doHLTMon = False
184 
185  # ############################################################
186  # Lock flags
187  # ############################################################
188  flags.lock()
189 
190  flags.dump()
191 
192  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
193  acc = MainServicesCfg(flags)
194 
195  bytestreamConversion = CompFactory.ByteStreamCnvSvc()
196  acc.addService(bytestreamConversion, primary=True)
197 
198  from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
199  acc.merge(EmonByteStreamCfg(flags))
200 
201  bytestreamInput = acc.getService("ByteStreamInputSvc")
202 
203  # ############################################################
204  # The name of the partition you want to connect
205  # ############################################################
206  bytestreamInput.Partition = partitionName
207 
208  bytestreamInput.Key = "dcm"
209  bytestreamInput.KeyCount = 40
210 
211  # #######################################################
212  # TimeOut (in milliseconds) - Prevent job with low rates
213  # to reconnect too often to SFIs
214  # ######################################################
215  bytestreamInput.Timeout = 600000
216 
217  bytestreamInput.UpdatePeriod = 200
218 
219  bytestreamInput.ISServer = 'Histogramming'
220 
221  bytestreamInput.StreamNames = ['express']
222  bytestreamInput.StreamType = "physics"
223  bytestreamInput.StreamLogic = "Or"
224 
225 
226  if partitionName == 'ATLAS' or partitionName == 'ATLAS_MP1':
227  from PyUtils.OnlineISConfig import GetAtlasReady
228  if beamType == BeamType.Cosmics:
229  bytestreamInput.StreamNames = ['express','IDCosmic','HLT_IDCosmic','CosmicMuons','CosmicCalo']
230  else:
231  if GetAtlasReady():
232  print ("ATLAS READY, reading express stream")
233  bytestreamInput.StreamNames = ['express']
234  else:
235  print ("ATLAS NOT READY, reading standby stream")
236  bytestreamInput.StreamNames = ['express','IDCosmic','HLT_IDCosmic','CosmicMuons','MinBias','Standby','Main','CosmicCalo']
237  else:
238  bytestreamInput.StreamLogic = 'Ignore'
239  bytestreamInput.PublishName = 'GMT9_23_0_28_CA_test_1'
240 
241  # #######################################################################
242  # Add BeamSpotDecoratorAlg to solve muon monitoring issue
243  # reported in https://its.cern.ch/jira/browse/ATLASRECTS-7281
244  # This needs to be fixed by muon experts
245  # ######################################################################
246 
247  from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoBeamSpotDecoratorAlgCfg
248  acc.merge(EventInfoBeamSpotDecoratorAlgCfg(flags))
249 
250  # ###########################################################
251  # Load Reco
252  # ###########################################################
253 
254 
255  if flags.Detector.EnableCalo:
256  from CaloRec.CaloRecoConfig import CaloRecoCfg
257  acc.merge(CaloRecoCfg(flags))
258 
259 
260  if flags.Reco.EnableTracking:
261  from InDetConfig.TrackRecoConfig import InDetTrackRecoCfg
262  acc.merge(InDetTrackRecoCfg(flags))
263 
264 
265  if flags.Detector.EnableMuon:
266  from MuonConfig.MuonReconstructionConfig import MuonReconstructionCfg
267  acc.merge(MuonReconstructionCfg(flags))
268 
269 
270  if flags.Reco.EnableCombinedMuon:
271  from MuonCombinedConfig.MuonCombinedReconstructionConfig import (
272  MuonCombinedReconstructionCfg)
273  acc.merge(MuonCombinedReconstructionCfg(flags))
274 
275 
276  if flags.Reco.EnableJet:
277  from JetRecConfig.JetRecoSteering import JetRecoSteeringCfg
278  acc.merge(JetRecoSteeringCfg(flags))
279 
280 
281  if flags.Reco.EnablePFlow:
282  from eflowRec.PFRun3Config import PFCfg
283  acc.merge(PFCfg(flags))
284 
285 
286  if flags.Reco.EnableEgamma:
287  from egammaConfig.egammaSteeringConfig import EGammaSteeringCfg
288  acc.merge(EGammaSteeringCfg(flags))
289 
290 
291  if flags.Reco.EnableTau:
292  from tauRec.TauConfig import TauReconstructionCfg
293  acc.merge(TauReconstructionCfg(flags))
294 
295 
296  if flags.Reco.EnableTrigger:
297  from TriggerJobOpts.TriggerRecoConfig import TriggerRecoCfg
298  acc.merge(TriggerRecoCfg(flags))
299 
300 
301  if flags.Reco.EnableMet:
302  from METReconstruction.METRecCfg import METCfg
303  acc.merge(METCfg(flags))
304 
305 
306  if flags.Reco.EnableIsolation:
307  from IsolationAlgs.IsolationSteeringConfig import IsolationSteeringCfg
308  acc.merge(IsolationSteeringCfg(flags))
309 
310 
311  if flags.Detector.EnableLucid:
312  from ForwardRec.LucidRecConfig import LucidRecCfg
313  acc.merge(LucidRecCfg(flags))
314 
315 
316  if flags.Reco.EnableHI:
317  from HIRecConfig.HIRecConfig import HIRecCfg
318  acc.merge(HIRecCfg(flags))
319 
320 
321  if flags.Reco.EnableBTagging:
322  from BTagging.BTagConfig import BTagRecoSplitCfg
323  acc.merge(BTagRecoSplitCfg(flags))
324 
325  # #####################################################
326  # Load Monitoring
327  # #####################################################
328  if flags.DQ.doMonitoring:
329  from AthenaMonitoring.AthenaMonitoringCfg import (
330  AthenaMonitoringCfg, AthenaMonitoringPostprocessingCfg)
331  acc.merge(AthenaMonitoringCfg(flags))
332  if flags.DQ.doPostProcessing:
333  acc.merge(AthenaMonitoringPostprocessingCfg(flags))
334 
335 
336  from IOVDbSvc.IOVDbSvcConfig import addOverride
337  acc.merge(addOverride(flags, "/TRT/Onl/Calib/PID_NN", "TRTCalibPID_NN_v2", db=""))
338 
339  # #######################################
340  # Set TRT expert flags
341  # #######################################
342  acc.getEventAlgo("AlgTRTMonitoringRun3RAW").doExpert = True
343  acc.getEventAlgo("AlgTRTMonitoringRun3RAW").doEfficiency = True
344 
345  # ###########################################################################################################################
346  # Need to add this line since it was needed as explained in the link below. Otherwise jobs crash
347  # https://gitlab.cern.ch/atlas/athena/-/blob/master/Reconstruction/RecExample/RecExOnline/share/RecExOnline_postconfig.py#L12
348  # ###########################################################################################################################
349  acc.getService("PoolSvc").ReadCatalog += ["xmlcatalog_file:/det/dqm/GlobalMonitoring/PoolFileCatalog_M7/PoolFileCatalog.xml"]
350 
351  # #######################################
352  # Run
353  # #######################################
354  sc = acc.run()
355  sys.exit(0 if sc.isSuccess() else 1)
EmonByteStreamConfig.EmonByteStreamCfg
def EmonByteStreamCfg(flags, type_names=[])
Definition: EmonByteStreamConfig.py:12
python.CaloRecoConfig.CaloRecoCfg
def CaloRecoCfg(flags, clustersname=None)
Definition: CaloRecoConfig.py:9
LucidRecConfig.LucidRecCfg
def LucidRecCfg(flags)
Definition: LucidRecConfig.py:9
python.MuonReconstructionConfig.MuonReconstructionCfg
def MuonReconstructionCfg(flags)
Definition: MuonReconstructionConfig.py:149
python.egammaSteeringConfig.EGammaSteeringCfg
def EGammaSteeringCfg(flags, name="EGammaSteering")
Definition: egammaSteeringConfig.py:15
python.JetRecoSteering.JetRecoSteeringCfg
def JetRecoSteeringCfg(flags)
Definition: JetRecoSteering.py:67
python.AthenaMonitoringCfg.AthenaMonitoringCfg
def AthenaMonitoringCfg(flags)
Definition: AthenaMonitoringCfg.py:7
METRecCfg.METCfg
def METCfg(inputFlags)
Definition: METRecCfg.py:4
TauConfig.TauReconstructionCfg
def TauReconstructionCfg(flags)
Definition: TauConfig.py:261
python.IOVDbSvcConfig.addOverride
def addOverride(flags, folder, tag, db=None)
Definition: IOVDbSvcConfig.py:224
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.AutoConfigOnlineRecoFlags.autoConfigOnlineRecoFlags
def autoConfigOnlineRecoFlags(flags, partition=None)
Definition: AutoConfigOnlineRecoFlags.py:134
IsolationSteeringConfig.IsolationSteeringCfg
def IsolationSteeringCfg(flags, name='IsolationSteering')
Definition: IsolationSteeringConfig.py:10
python.BTagConfig.BTagRecoSplitCfg
def BTagRecoSplitCfg(inputFlags, JetCollection=['AntiKt4EMTopo', 'AntiKt4EMPFlow'])
Definition: BTagConfig.py:131
python.TrackRecoConfig.InDetTrackRecoCfg
def InDetTrackRecoCfg(flags)
Main ID tracking config #####################.
Definition: TrackRecoConfig.py:791
python.xAODEventInfoCnvConfig.EventInfoBeamSpotDecoratorAlgCfg
def EventInfoBeamSpotDecoratorAlgCfg(flags, name="EventInfoBeamSpotDecoratorAlg", eventInfoKey="EventInfo", **kwargs)
Definition: xAODEventInfoCnvConfig.py:139
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.TriggerRecoConfig.TriggerRecoCfg
def TriggerRecoCfg(flags)
Definition: TriggerRecoConfig.py:17
python.OnlineISConfiguration.GetAtlasReady
def GetAtlasReady()
Definition: OnlineISConfiguration.py:6
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.HIRecConfig.HIRecCfg
def HIRecCfg(flags)
Definition: HIRecConfig.py:8
python.MuonCombinedReconstructionConfig.MuonCombinedReconstructionCfg
def MuonCombinedReconstructionCfg(flags)
Definition: MuonCombinedReconstructionConfig.py:674
python.AthenaMonitoringCfg.AthenaMonitoringPostprocessingCfg
def AthenaMonitoringPostprocessingCfg(flags)
Definition: AthenaMonitoringCfg.py:169
PFCfg
Definition: PFCfg.py:1