ATLAS Offline Software
Loading...
Searching...
No Matches
RpcMonitorAlgorithm.py
Go to the documentation of this file.
2# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3#
4
5'''
6@file RPCMonitoringConfig.py
7@brief Python configuration of RPC Monitoring for the Run III
8'''
9
10def RpcMonitoringConfig(inputFlags):
11
12 from AthenaConfiguration.ComponentFactory import CompFactory
13 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
14 result = ComponentAccumulator()
15
16 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
17 result.merge(AtlasFieldCacheCondAlgCfg(inputFlags))
18
19 from AthenaMonitoring import AthMonitorCfgHelper
20 helper = AthMonitorCfgHelper(inputFlags,'RpcMonitoringCfg')
21
22
25 from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
26 extrapolator = result.popToolsAndMerge(AtlasExtrapolatorCfg(inputFlags))
27
28 rpcTrackAnaAlg = helper.addAlgorithm(CompFactory.RpcTrackAnaAlg, "RpcTrackAnaAlgAlg", TrackExtrapolator = extrapolator)
29
30 from TrackingGeometryCondAlg.AtlasTrackingGeometryCondAlgConfig import TrackingGeometryCondAlgCfg
31 result.merge( TrackingGeometryCondAlgCfg(inputFlags ) )
32
33 rpcTrackAnaAlg.plotMuonEff = True
34 rpcTrackAnaAlg.plotPRD = True
35 rpcTrackAnaAlg.ElementsFileName = "RpcRawDataMonitoring/Element.xml"
36 rpcTrackAnaAlg.TagAndProbe = False
37
38 if not inputFlags.DQ.triggerDataAvailable:
39 rpcTrackAnaAlg.MuonRoIContainerName = ''
40 else:
41 # LVL1MuonRoIs are only available after the HLTResultMTByteStreamDecoderAlg has executed
42 from TrigDecisionTool.TrigDecisionToolConfig import getRun3NavigationContainerFromInput
43 rpcTrackAnaAlg.ExtraInputs.add(('xAOD::TrigCompositeContainer' , 'StoreGateSvc+'+getRun3NavigationContainerFromInput(inputFlags)))
44
45
48 myGroup_track = helper.addGroup(rpcTrackAnaAlg, 'RpcTrackAnaAlg', 'Muon/MuonRawDataMonitoring/RPC/')
49
50 myGroup_track.defineHistogram('run;Run',
51 title='Run Number;run;Events',
52 type='TH1I',
53 path='RpcOccupancy',
54 xbins=800000,xmin=200000.5,xmax=1000000.5)
55
56 myGroup_track.defineHistogram('evtLB',
57 title='Number of Event;Luminosity Block;N Event',
58 type='TH1I',
59 path='RpcOccupancy',
60 xbins=2000, xmin=0.5, xmax=2000.5)
61
62 myGroup_track.defineHistogram('prdTime',
63 title="Number of RPC Hit;Time;NHit",
64 type='TH1D',
65 path='RpcOccupancy',
66 xbins=36, xmin=-101.5625, xmax=10.9375)
67
68 myGroup_track.defineHistogram('prd_sec,prd_layer;NPRDHit_sectorVSlayer',
69 title="NPRDHit_sectorVSlayer;Sector(- for C side, + for A side);layer((dbR-1)*2+gasGap);NHit",
70 type='TH2I',
71 path='RpcOccupancy',
72 xbins=33, xmin=-16.5, xmax=16.5,
73 ybins=8, ymin=0.5, ymax=8.5)
74 myGroup_track.defineHistogram('prd_sec_1214,prd_layer_1214;NPRDHit_sectorVSlayer_Sector1214',
75 title="NPRDHit_sectorVSlayer_Sector1214;Sector(- for C side, + for A side);layer((dbR-1)*2+gasGap);NHit",
76 type='TH2I',
77 path='RpcOccupancy',
78 xbins=[-14.5,-13.5,-12.5,-11.5, 11.5, 12.5, 13.5, 14.5],
79 ybins=8, ymin=0.5, ymax=8.5)
80 myGroup_track.defineHistogram('prd_sec_eta,prd_layer_eta;NPRDHit_sectorVSlayer_Eta',
81 title="NPRDHit_sectorVSlayer_eta;Sector(- for C side, + for A side);layer((dbR-1)*2+gasGap);NHit",
82 type='TH2I',
83 path='RpcOccupancy',
84 xbins=33, xmin=-16.5, xmax=16.5,
85 ybins=8, ymin=0.5, ymax=8.5)
86 myGroup_track.defineHistogram('prd_sec_phi,prd_layer_phi;NPRDHit_sectorVSlayer_Phi',
87 title="NPRDHit_sectorVSlayer_phi;Sector(- for C side, + for A side);layer((dbR-1)*2+gasGap);NHit",
88 type='TH2I',
89 path='RpcOccupancy',
90 xbins=33, xmin=-16.5, xmax=16.5,
91 ybins=8, ymin=0.5, ymax=8.5)
92
93 myGroup_track.defineHistogram('LB,panelInd;NPRDHit_Panels_All',
94 title='Number of RPC Hit;Luminosity Block;Panel Index;NHit',
95 type='TH2I',
96 path='RpcOccupancy',
97 xbins=2000, xmin=0.5, xmax=2000.5, ybins=8592, ymin=-0.5, ymax=8591.5)
98 myGroup_track.defineHistogram('LB;NPRDHitVSLB_All',
99 title="Number of RPC Hit;Luminosity Block;NHit",
100 type='TH1I',
101 path='RpcOccupancy',
102 xbins=2000, xmin=0.5, xmax=2000.5)
103
104
107 trackPath = 'TrackMatch'
108
109 myGroup_track.defineHistogram('LB_nrpchit,PhiSector;NPRDHitFromMuon_PhiSector_vs_LB',
110 title='Number of RPC hits for muons decayed from Z candidates;Luminosity Block;#phi sector(- for C side, + for A side);NHit',
111 type='TH2I',
112 path=trackPath,
113 xbins=2000, xmin=0.5, xmax=2000.5, ybins=33, ymin=-16.5, ymax=16.5)
114
115
116 myGroup_track.defineHistogram('muPt_MuonFromZ;Pt_MuonFromZ',
117 title='Pt of muons decayed from Z candidates;Pt[MeV];NMuon',
118 type='TH1D',
119 path='PlotCand',
120 xbins=100,xmin=0,xmax=400e3)
121 myGroup_track.defineHistogram('muEta_MuonFromZ;Eta_MuonFromZ',
122 title='#eta of muons decayed from Z candidates;#eta;NMuon',
123 type='TH1D',
124 path='PlotCand',
125 xbins=42, xmin=-1.05, xmax=1.05)
126 myGroup_track.defineHistogram('muPhi_MuonFromZ;Phi_MuonFromZ',
127 title='#phi of muons decayed from Z candidates;#phi;NMuon',
128 type='TH1D',
129 path='PlotCand',
130 xbins=32, xmin=-3.1415926, xmax=3.1415926)
131 myGroup_track.defineHistogram('muEta_MuonFromZ,muPhi_MuonFromZ;EtaVSPhi_MuonFromZ',
132 type='TH2D',
133 title='Eta vs phi for muons decayed from Z;#eta;#phi;NMuon',
134 path='PlotCand',
135 xbins=42,xmin=-1.05, xmax=1.05,
136 ybins=32,ymin=-3.1415926,ymax=3.1415926)
137 myGroup_track.defineHistogram('muEta_p_MuonFromZ,muPhi_p_MuonFromZ;EtaVSPhi_MuonFromZ_plateau',
138 type='TH2D',
139 title='Eta vs phi for muons decayed from Z(pT>25GeV);#eta;#phi;NMuon',
140 path='PlotCand',
141 xbins=42,xmin=-1.05, xmax=1.05,
142 ybins=32,ymin=-3.1415926,ymax=3.1415926)
143
144 myGroup_track.defineHistogram('hitMulti_eta;HitMultiplicity_eta',
145 type='TH1I',
146 title='Hit multiplicity in #eta view for muons decayed from Z candidates;#eta strip hit Multiplicity;muon entries',
147 path=trackPath,
148 xbins=11,xmin=-0.5, xmax=10.5)
149
150 myGroup_track.defineHistogram('hitMulti_phi;HitMultiplicity_phi',
151 type='TH1I',
152 title='Hit multiplicity in #phi view for muons decayed from Z candidates;#phi strip hit Multiplicity;muon entries',
153 path=trackPath,
154 xbins=11,xmin=-0.5, xmax=10.5)
155
156 myGroup_track.defineHistogram('hitMulti,panelInd_hM;HitMultiplicity_Panels',
157 title='Hit multiplicity for muons decayed from Z candidates;Hit Multiplicity;Panel Index;NMuon',
158 type='TH2I',
159 path=trackPath,
160 xbins=11, xmin=-0.5, xmax=10.5, ybins=8592, ymin=-0.5, ymax=8591.5)
161
162 myGroup_track.defineHistogram('clusterSize_eta;ClusterSize_etaView',
163 type='TH1I',
164 title='Cluster size in #eta view for muons decayed from Z candidates;Cluster size;NCluster',
165 path=trackPath,
166 xbins=11,xmin=-0.5, xmax=10.5)
167
168 myGroup_track.defineHistogram('clusterSize_phi;ClusterSize_phiView',
169 type='TH1I',
170 title='Cluster size in #phi view for muons decayed from Z candidates;Cluster size;NCluster',
171 path=trackPath,
172 xbins=11,xmin=-0.5, xmax=10.5)
173
174 myGroup_track.defineHistogram('clusterSize,panelInd_clust;ClusterSize_Panels',
175 title='Cluster size for muons decayed from Z candidates;Cluster size;Panel Index;NCluster',
176 type='TH2I',
177 path=trackPath,
178 xbins=11, xmin=-0.5, xmax=10.5, ybins=8592, ymin=-0.5, ymax=8591.5)
179
180 myGroup_track.defineHistogram('muon_passExtrap,panelInd_hM;Detection_Efficiency_MuonFromZ',
181 title='Panels detection efficiency for muons decayed from Z candidates;Panel Index;Efficiency',
182 type='TEfficiency',
183 path=trackPath,
184 xbins=8592, xmin=-0.5, xmax=8591.5)
185 myGroup_track.defineHistogram('muon_passExtrap_or,panelInd_hM;Detection_Efficiency_MuonFromZ_EtaORPhi',
186 title='Panels(eta or phi) detection efficiency for muons decayed from Z candidates;Panel Index;Efficiency',
187 type='TEfficiency',
188 path=trackPath,
189 xbins=8592, xmin=-0.5, xmax=8591.5)
190 myGroup_track.defineHistogram('muon_passExtrap_and,panelInd_hM;Detection_Efficiency_MuonFromZ_EtaANDPhi',
191 title='Panels(eta and phi) detection efficiency for muons decayed from Z candidates;Panel Index;Efficiency',
192 type='TEfficiency',
193 path=trackPath,
194 xbins=8592, xmin=-0.5, xmax=8591.5)
195 myGroup_track.defineHistogram('muon_passExtrap_signalhit_or,panelInd_hM;Detection_Efficiency_MuonFromZ_signalHit_EtaORPhi',
196 title='Panels(eta or phi) detection efficiency for muons decayed from Z candidates(Signal hits);Panel Index;Efficiency',
197 type='TEfficiency',
198 path=trackPath,
199 xbins=8592, xmin=-0.5, xmax=8591.5)
200 myGroup_track.defineHistogram('muon_passExtrap_signalhit_and,panelInd_hM;Detection_Efficiency_MuonFromZ_signalHit_EtaANDPhi',
201 title='Panels(eta and phi) detection efficiency for muons decayed from Z candidates(Signal hits);Panel Index;Efficiency',
202 type='TEfficiency',
203 path=trackPath,
204 xbins=8592, xmin=-0.5, xmax=8591.5)
205 myGroup_track.defineHistogram('muon_passExtrap_signalhit,panelInd_hM;Detection_Efficiency_MuonFromZ_signalHit',
206 title='Panels detection efficiency for muons decayed from Z candidates(Signal hits);Panel Index;Efficiency',
207 type='TEfficiency',
208 path=trackPath,
209 xbins=8592, xmin=-0.5, xmax=8591.5)
210 myGroup_track.defineHistogram('muon_passExtrap,LB_detEff;Detection_Efficiency_LB_MuonFromZ',
211 title='Panels detection efficiency for muons decayed from Z candidates;Luminosity Block;Efficiency',
212 type='TEfficiency',
213 path=trackPath,
214 xbins=2000, xmin=0.5, xmax=2000.5)
215
216 myGroup_track.defineHistogram('isOutTime_prd,panelInd_prd;OuttimeHitFraction_PRDHit',
217 title='Fraction of out-of-time hits for muons decayed from Z candidates;Panel Index;Fraction of out-of-time hits',
218 type='TEfficiency',
219 path=trackPath,
220 xbins=8592, xmin=-0.5, xmax=8591.5)
221
222 myGroup_track.defineHistogram('isOutTime_prd_onTrack,panelInd_prd_onTrack;OuttimeHitFraction_PRDHit_onTrack',
223 title='Fraction of out-of-time hits on tracks of muons decayed from Z candidates;Panel Index;Fraction of out-of-time hits',
224 type='TEfficiency',
225 path=trackPath,
226 xbins=8592, xmin=-0.5, xmax=8591.5)
227
228 myGroup_track.defineHistogram('residual_eta;residual_eta',
229 title='Distance between extrapolated muon track position and RPC eta hit;Distance [mm];Number of hit',
230 type='TH1D',
231 path=trackPath,
232 xbins=200, xmin=-100., xmax=100.)
233
234 myGroup_track.defineHistogram('residual_phi;residual_phi',
235 title='Distance between extrapolated muon track position and RPC eta hit;Distance [mm];Number of hit',
236 type='TH1D',
237 path=trackPath,
238 xbins=200, xmin=-100., xmax=100.)
239
240 myGroup_track.defineHistogram('closest_residual_eta;closest_residual_eta',
241 title='The closest distance between extrapolated muon track position and RPC eta hit;Distance [mm];Number of muon track position',
242 type='TH1D',
243 path=trackPath,
244 xbins=200, xmin=-100., xmax=100.)
245
246 myGroup_track.defineHistogram('closest_residual_phi;closest_residual_phi',
247 title='The closest distance between extrapolated muon track position and RPC eta hit;Distance [mm];Number of muon track position',
248 type='TH1D',
249 path=trackPath,
250 xbins=200, xmin=-100., xmax=100.)
251
252 myGroup_track.defineHistogram('residual_panel,panelInd_res_inTime;Residual_Panels',
253 title='Distance between extrapolated muon track position and RPC hit;Panel Index;Distance [mm];Number of hit',
254 type='TH2D',
255 path=trackPath,
256 xbins=100, xmin=-50., xmax=50., ybins=8592, ymin=-0.5, ymax=8591.5)
257
258
259 myGroup_track.defineHistogram('muPt_allMu;Pt_AllMuons',
260 title='Pt of muons in all events;Pt[MeV];NMuon',
261 type='TH1D',
262 path='PlotCand',
263 xbins=100,xmin=0,xmax=400e3)
264 myGroup_track.defineHistogram('muEta_allMu;Eta_AllMuons',
265 title='#eta of muons in all events;#eta;NMuon',
266 type='TH1D',
267 path='PlotCand',
268 xbins=42, xmin=-1.05, xmax=1.05)
269 myGroup_track.defineHistogram('muPhi_allMu;Phi_AllMuons',
270 title='#phi of muons in all events;#phi;NMuon',
271 type='TH1D',
272 path='PlotCand',
273 xbins=32, xmin=-3.1415926, xmax=3.1415926)
274 myGroup_track.defineHistogram('muEta_allMu,muPhi_allMu;EtaVSPhi_AllMuons',
275 type='TH2D',
276 title='Eta vs phi of all muons;#eta;#phi;NMuon',
277 path='PlotCand',
278 xbins=42,xmin=-1.05, xmax=1.05,
279 ybins=32,ymin=-3.1415926,ymax=3.1415926)
280
281
282 myGroup_track.defineHistogram('muon_passExtrap_allMu,panelInd_hM_allMu;Detection_Efficiency_AllMuons',
283 title='Panels detection efficiency for all muons;Panel Index;Efficiency',
284 type='TEfficiency',
285 path=trackPath,
286 xbins=8592, xmin=-0.5, xmax=8591.5)
287
288
289 sectors = ["sector"+str(k) for k in range(1, 16+1)]
290 array_sectors = helper.addArray([sectors], rpcTrackAnaAlg, 'RpcTrackAnaAlg', 'Muon/MuonRawDataMonitoring/RPC/')
291
292 array_sectors.defineHistogram('cs_sec;ClusterSize',
293 title='Cluster size on {0};Cluster size;NCluster',
294 type='TH1I',
295 path='TrackMatch/ClusterSize',
296 xbins=11, xmin=-0.5, xmax=10.5)
297
298 array_sectors.defineHistogram('hitTime_sec;PRDHitTime_MuonFromZ',
299 title='Hit time on {0};Hit time;NHits',
300 type='TH1I',
301 path='TrackMatch/PRDHitTime',
302 xbins=36, xmin=-101.5625, xmax=10.9375)
303
304
307 myGroup_track.defineHistogram('nMu;NMuon',
308 title='Number of Muons;nMuons;Events',
309 type='TH1I',
310 path='PlotCand',
311 xbins=10,xmin=-0.5,xmax=9.5)
312 myGroup_track.defineHistogram('nMuBarrel;NMuonBarrel',
313 title='Number of Barrel Muons;nMuons;Events',
314 type='TH1I',
315 path='PlotCand',
316 xbins=5,xmin=-0.5,xmax=4.5)
317 myGroup_track.defineHistogram('roiEta;roiEta',
318 title='roi eta;roi #eta;rois',
319 type='TH1D',
320 path='PlotCand',
321 xbins=50,xmin=-2.5,xmax=2.5)
322
323 myGroup_track.defineHistogram('roiBarrelEta;roiBarrelEta',
324 title='Barrel roi eta;roi #eta;rois',
325 type='TH1D',
326 path='PlotCand',
327 xbins=50,xmin=-2.5,xmax=2.5)
328
329 myGroup_track.defineHistogram('roiBarrelThr;roiBarrelThrs',
330 title='Barrel roi threshold;roi threshold;rois',
331 type='TH1I',
332 path='PlotCand',
333 xbins=6,xmin=0.5,xmax=6.5)
334
335 lv1Triggers = ["thr"+str(k) for k in range(1, 6+1)]
336 array_triggerThr = helper.addArray([lv1Triggers], rpcTrackAnaAlg, 'RpcTrackAnaAlg', 'Muon/MuonRawDataMonitoring/RPC/')
337
338 array_triggerThr.defineHistogram('passTrigger,muPt_l1;L1TriggerEff_muPt',
339 title='L1 Trigger Efficiency for {0};Pt[MeV];#epsilon for {0}',
340 type='TEfficiency',
341 path='L1Trigger',
342 xbins=10, xmin=0.0, xmax=80.0e3)
343
344 array_triggerThr.defineHistogram('passTrigger_plateau,muEta_l1;L1TriggerEff_muEta',
345 title='L1 Trigger Efficiency for {0};#eta;#epsilon for {0}',
346 type='TEfficiency',
347 path='L1Trigger',
348 xbins=42,xmin=-1.05, xmax=1.05)
349
350 array_triggerThr.defineHistogram('passTrigger_plateau,muPhi_l1;L1TriggerEff_muPhi',
351 title='L1 Trigger Efficiency for {0};#phi;#epsilon for {0}',
352 type='TEfficiency',
353 path='L1Trigger',
354 xbins=32,xmin=-3.1415926,xmax=3.1415926)
355
356 array_triggerThr.defineHistogram('passTrigger_plateau,muEta_l1,muPhi_l1;L1TriggerEff_eta_phi',
357 title='L1 Trigger Efficiency for {0};#eta;#phi;#epsilon for {0}',
358 type='TEfficiency',
359 path='L1Trigger',
360 xbins=42,xmin=-1.05, xmax=1.05,
361 ybins=32,ymin=-3.1415926,ymax=3.1415926)
362
363 result.merge(helper.result())
364 print(" RpcMonitorAlgorithm END !")
365
366 return result
367
368
369if __name__=="__main__":
370 print(" In RpcMonitorAlgorithm !")
371 # Setup logs
372 from AthenaCommon.Logging import log
373 from AthenaCommon.Constants import INFO
374 log.setLevel(INFO)
375
376 # Set the Athena configuration flags
377 from AthenaConfiguration.AllConfigFlags import initConfigFlags
378 flags = initConfigFlags()
379
380 # Config Input/Output
381 import os
382
383 file_list = []
384 if os.path.exists('input.txt'):
385 infile = open('input.txt', "r")
386 file_list = infile.readlines()
387 file_list = [ filename.strip() for filename in file_list ]
388 print ("read files path from input.txt .")
389 print ("files paths: \n", file_list)
390 else:
391 file_list = ['/eos/atlas/atlascerngroupdisk/det-rpc/data/DESDM_MCP/data18_13TeV.00358615.physics_Main.merge.DESDM_MCP.f961_m2024/data18_13TeV.00358615.physics_Main.merge.DESDM_MCP.f961_m2024._0005.1']
392
393 print ("file input.txt does not exist")
394 print ("WIll use files: \n", file_list)
395
396 flags.Input.Files = file_list
397 flags.Output.HISTFileName = 'RPCMonitoringOutput.root'
398 from AthenaConfiguration.TestDefaults import defaultGeometryTags
399 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
400
401 flags.lock()
402 flags.dump()
403
404 # Initialize configuration object, add accumulator, merge and run.
405 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
406 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
407 cfg = MainServicesCfg(flags)
408 cfg.merge(PoolReadCfg(flags))
409
411 acc.OutputLevel = INFO
412 cfg.merge(acc)
413
414 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
415 cfg.merge(AtlasFieldCacheCondAlgCfg(flags))
416
417 if flags.DQ.Steering.Muon.doTrackMon:
418 # do not run in RAW->ESD
419 if flags.DQ.Environment not in ('tier0Raw',):
420 from MuonTrackMonitoring.MuonTrackMonitorAlgorithm import MuonTrackConfig
421 cfg.merge(MuonTrackConfig(flags))
422
423 cfg.printConfig(withDetails=True, summariseProps = True)
424
425 cfg.run()
void print(char *figname, TCanvas *c1)