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.doLVL1CaloMon = False
174  flags.DQ.Steering.doLVL1InterfacesMon = False
175 
176  flags.DQ.Steering.doDataFlowMon = False
177 
178  flags.DQ.Steering.doCTPMon = False
179 
180  if (partitionName != 'ATLAS' and partitionName != 'ATLAS_MP1'):
181  flags.DQ.Steering.doHLTMon = False
182 
183  # ############################################################
184  # Lock flags
185  # ############################################################
186  flags.lock()
187 
188  flags.dump()
189 
190  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
191  acc = MainServicesCfg(flags)
192 
193  bytestreamConversion = CompFactory.ByteStreamCnvSvc()
194  acc.addService(bytestreamConversion, primary=True)
195 
196  from ByteStreamEmonSvc.EmonByteStreamConfig import EmonByteStreamCfg
197  acc.merge(EmonByteStreamCfg(flags))
198 
199  bytestreamInput = acc.getService("ByteStreamInputSvc")
200 
201  # ############################################################
202  # The name of the partition you want to connect
203  # ############################################################
204  bytestreamInput.Partition = partitionName
205 
206  bytestreamInput.Key = "dcm"
207  bytestreamInput.KeyCount = 40
208 
209  # #######################################################
210  # TimeOut (in milliseconds) - Prevent job with low rates
211  # to reconnect too often to SFIs
212  # ######################################################
213  bytestreamInput.Timeout = 600000
214 
215  bytestreamInput.UpdatePeriod = 200
216 
217  bytestreamInput.ISServer = 'Histogramming'
218 
219  bytestreamInput.StreamNames = ['express']
220  bytestreamInput.StreamType = "physics"
221  bytestreamInput.StreamLogic = "Or"
222 
223 
224  if partitionName == 'ATLAS' or partitionName == 'ATLAS_MP1':
225  from PyUtils.OnlineISConfig import GetAtlasReady
226  if beamType == BeamType.Cosmics:
227  bytestreamInput.StreamNames = ['express','IDCosmic','HLT_IDCosmic','CosmicMuons','CosmicCalo']
228  else:
229  if GetAtlasReady():
230  print ("ATLAS READY, reading express stream")
231  bytestreamInput.StreamNames = ['express']
232  else:
233  print ("ATLAS NOT READY, reading standby stream")
234  bytestreamInput.StreamNames = ['express','IDCosmic','HLT_IDCosmic','CosmicMuons','MinBias','Standby','Main','CosmicCalo']
235  else:
236  bytestreamInput.StreamLogic = 'Ignore'
237  bytestreamInput.PublishName = 'GMT9_23_0_28_CA_test_1'
238 
239  # #######################################################################
240  # Add BeamSpotDecoratorAlg to solve muon monitoring issue
241  # reported in https://its.cern.ch/jira/browse/ATLASRECTS-7281
242  # This needs to be fixed by muon experts
243  # ######################################################################
244 
245  from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoBeamSpotDecoratorAlgCfg
246  acc.merge(EventInfoBeamSpotDecoratorAlgCfg(flags))
247 
248  # ###########################################################
249  # Load Reco
250  # ###########################################################
251 
252 
253  if flags.Detector.EnableCalo:
254  from CaloRec.CaloRecoConfig import CaloRecoCfg
255  acc.merge(CaloRecoCfg(flags))
256 
257 
258  if flags.Reco.EnableTracking:
259  from InDetConfig.TrackRecoConfig import InDetTrackRecoCfg
260  acc.merge(InDetTrackRecoCfg(flags))
261 
262 
263  if flags.Detector.EnableMuon:
264  from MuonConfig.MuonReconstructionConfig import MuonReconstructionCfg
265  acc.merge(MuonReconstructionCfg(flags))
266 
267 
268  if flags.Reco.EnableCombinedMuon:
269  from MuonCombinedConfig.MuonCombinedReconstructionConfig import (
270  MuonCombinedReconstructionCfg)
271  acc.merge(MuonCombinedReconstructionCfg(flags))
272 
273 
274  if flags.Reco.EnableJet:
275  from JetRecConfig.JetRecoSteering import JetRecoSteeringCfg
276  acc.merge(JetRecoSteeringCfg(flags))
277 
278 
279  if flags.Reco.EnablePFlow:
280  from eflowRec.PFRun3Config import PFCfg
281  acc.merge(PFCfg(flags))
282 
283 
284  if flags.Reco.EnableEgamma:
285  from egammaConfig.egammaSteeringConfig import EGammaSteeringCfg
286  acc.merge(EGammaSteeringCfg(flags))
287 
288 
289  if flags.Reco.EnableTau:
290  from tauRec.TauConfig import TauReconstructionCfg
291  acc.merge(TauReconstructionCfg(flags))
292 
293 
294  if flags.Reco.EnableTrigger:
295  from TriggerJobOpts.TriggerRecoConfig import TriggerRecoCfg
296  acc.merge(TriggerRecoCfg(flags))
297 
298 
299  if flags.Reco.EnableMet:
300  from METReconstruction.METRecCfg import METCfg
301  acc.merge(METCfg(flags))
302 
303 
304  if flags.Reco.EnableIsolation:
305  from IsolationAlgs.IsolationSteeringConfig import IsolationSteeringCfg
306  acc.merge(IsolationSteeringCfg(flags))
307 
308 
309  if flags.Detector.EnableLucid:
310  from ForwardRec.LucidRecConfig import LucidRecCfg
311  acc.merge(LucidRecCfg(flags))
312 
313 
314  if flags.Reco.EnableHI:
315  from HIRecConfig.HIRecConfig import HIRecCfg
316  acc.merge(HIRecCfg(flags))
317 
318 
319  if flags.Reco.EnableBTagging:
320  from BTagging.BTagConfig import BTagRecoSplitCfg
321  acc.merge(BTagRecoSplitCfg(flags))
322 
323  # #####################################################
324  # Load Monitoring
325  # #####################################################
326  if flags.DQ.doMonitoring:
327  from AthenaMonitoring.AthenaMonitoringCfg import (
328  AthenaMonitoringCfg, AthenaMonitoringPostprocessingCfg)
329  acc.merge(AthenaMonitoringCfg(flags))
330  if flags.DQ.doPostProcessing:
331  acc.merge(AthenaMonitoringPostprocessingCfg(flags))
332 
333 
334  from IOVDbSvc.IOVDbSvcConfig import addOverride
335  acc.merge(addOverride(flags, "/TRT/Onl/Calib/PID_NN", "TRTCalibPID_NN_v2", db=""))
336 
337  # #######################################
338  # Set TRT expert flags
339  # #######################################
340  acc.getEventAlgo("AlgTRTMonitoringRun3RAW").doExpert = True
341  acc.getEventAlgo("AlgTRTMonitoringRun3RAW").doEfficiency = True
342 
343  # ###########################################################################################################################
344  # Need to add this line since it was needed as explained in the link below. Otherwise jobs crash
345  # https://gitlab.cern.ch/atlas/athena/-/blob/master/Reconstruction/RecExample/RecExOnline/share/RecExOnline_postconfig.py#L12
346  # ###########################################################################################################################
347  acc.getService("PoolSvc").ReadCatalog += ["xmlcatalog_file:/det/dqm/GlobalMonitoring/PoolFileCatalog_M7/PoolFileCatalog.xml"]
348 
349  # #######################################
350  # Run
351  # #######################################
352  sc = acc.run()
353  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:142
python.egammaSteeringConfig.EGammaSteeringCfg
def EGammaSteeringCfg(flags, name="EGammaSteering")
Definition: egammaSteeringConfig.py:15
python.JetRecoSteering.JetRecoSteeringCfg
def JetRecoSteeringCfg(flags)
Definition: JetRecoSteering.py:63
python.AthenaMonitoringCfg.AthenaMonitoringCfg
def AthenaMonitoringCfg(flags)
Definition: AthenaMonitoringCfg.py:7
METRecCfg.METCfg
def METCfg(inputFlags)
Definition: METRecCfg.py:7
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:245
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:118
python.TrackRecoConfig.InDetTrackRecoCfg
def InDetTrackRecoCfg(flags)
Main ID tracking config #####################.
Definition: TrackRecoConfig.py:772
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
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
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:164
PFCfg
Definition: PFCfg.py:1