ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonValidation
MuonDQA
MuonRawDataMonitoring
RpcRawDataMonitoring
python
RPCPostProcessing.py
Go to the documentation of this file.
1
#
2
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
#
4
5
# local
6
import
RpcRawDataMonitoring.RPCRawDataMonUtils
as
RPCRawDataMonUtils
7
import
RpcRawDataMonitoring.CoreClass
as
CoreClass
8
import
RpcRawDataMonitoring.GetLBInfoFromCOOL
as
GetLBInfoFromCOOL
9
10
from
AthenaCommon.Utils.unixtools
import
find_datafile
11
12
13
def
readElementFromXML
():
14
import
xml.dom.minidom
as
Dom
15
import
os
16
17
# -- Get the validation xml file path
18
xml_file = find_datafile(
"RpcRawDataMonitoring/Element.xml"
)
19
20
if
not
os.path.isfile(xml_file):
21
print
(
"ERROR: can NOT find xml file: %s!"
%xml_file)
22
return
23
24
dom = Dom.parse(xml_file)
25
root_node = dom.documentElement
26
ele_nodes = root_node.childNodes
27
28
Dic_panels = {}
29
panel_property = {}
30
BMBO_StationNames = {2, 3, 4, 5, 8, 9, 10, 53}
31
for
i_node
in
ele_nodes:
32
if
i_node.nodeType != 1:
33
continue
34
35
# node_name = i_node.nodeName
36
ele_index = int(i_node.getAttribute(
"index"
))
37
38
panel_property[
"stationName"
] = int(i_node.getAttribute(
"stationName"
))
39
panel_property[
"stationEta"
] = int(i_node.getAttribute(
"stationEta"
))
40
panel_property[
"stationPhi"
] = int(i_node.getAttribute(
"stationPhi"
))
41
panel_property[
"doubletR"
] = int(i_node.getAttribute(
"doubletR"
))
42
panel_property[
"doubletZ"
] = int(i_node.getAttribute(
"doubletZ"
))
43
44
if
panel_property[
"stationName"
]
in
BMBO_StationNames:
45
ngasgap = 2
46
else
:
47
ngasgap = 3
48
49
for
dbPhi
in
[1,2]:
50
for
gasgap
in
range(1, ngasgap+1):
51
for
measPhi
in
[0, 1]:
52
panel_property[
"doubletPhi"
] = dbPhi
53
panel_property[
"gasGap"
] = gasgap
54
panel_property[
"measPhi"
] = measPhi
55
56
panel_index = (ele_index-1)*8 + (dbPhi - 1)*4 + (gasgap - 1)*2 + measPhi
57
i_panel =
RPCRawDataMonUtils.Panel
(panel_property, panel_index)
58
59
if
not
(panel_index
in
Dic_panels):
60
Dic_panels[panel_index] = i_panel
61
else
:
62
print
(
"ERROR: duplicated panel index!!!"
)
63
64
print
(
"RPCPostProcessing::readElementFromXML::INFO: count of read panels = %d"
%(len(Dic_panels)))
65
66
return
Dic_panels
67
68
69
def
getRun
(h_run):
70
xbins = h_run.GetNbinsX()
71
runs = []
72
73
for
i_bin
in
range(1, xbins+1):
74
if
h_run.GetBinContent(i_bin) > 0:
75
runs.append(int(h_run.GetBinLowEdge(i_bin))+1)
76
77
return
runs
78
79
80
def
make_evt_lumi
(inputs):
81
h_NEvt_LB = inputs[0][1][0].Clone()
82
h_run = inputs[0][1][1].Clone()
83
runs =
getRun
(h_run)
84
85
Dic_LBLumi =
GetLBInfoFromCOOL.GetLumiInfoDic
(runs[0], runs[-1]+1)
86
87
g_name =
'NEvent_VS_Lumi'
88
g_title =
'NEvent VS Lumi'
89
g_Xtitle =
'Inst Luminosity [10^{34} cm^{-2}s^{-1}]'
90
g_Ytitle =
'NEvent'
91
92
x = []
93
y = []
94
y_err = []
95
96
if
Dic_LBLumi
is
not
None
:
97
print
(
"len(Dic_LBLumi) = "
, len(Dic_LBLumi))
98
99
for
LB, lbInfo
in
Dic_LBLumi.items():
100
if
lbInfo[
'AtlasPhysics'
] ==
'false'
or
float(lbInfo[
'Duration'
])<50.:
101
continue
102
103
hit_content = h_NEvt_LB.GetBinContent(LB)
104
hit_err = h_NEvt_LB.GetBinError(LB)
105
106
x.append( float(lbInfo[
'InstLumi'
]) )
107
y.append( hit_content )
108
y_err.append( hit_err )
109
110
x_err = [0]*len(x)
111
112
g =
RPCRawDataMonUtils.creatGraph
(x, y, x_err, y_err, g_name, g_title, g_Xtitle, g_Ytitle)
113
114
return
[g]
115
116
117
def
make_hit_rate
(inputs):
118
h_hit_panels = inputs[0][1][0].Clone()
# "NPRDHit_Panels_All"
119
h_NEvt_LB = inputs[0][1][1].Clone()
# evtLB
120
h_run = inputs[0][1][2].Clone()
# run
121
122
runs =
getRun
(h_run)
123
if
len(runs) > 1:
124
print
(
"make_hit_rate::WARNING - Input file contain data in "
, len(runs),
" **runs**, which should only include 1-run and full data !!!"
)
125
return
126
127
dic_hists = {}
128
129
Dic_LBLumi =
GetLBInfoFromCOOL.GetLumiInfoDic
(runs[0], runs[0]+1)
130
131
if
Dic_LBLumi
is
not
None
:
132
print
(
"len(Dic_LBLumi) = "
, len(Dic_LBLumi))
133
# GetLBInfoFromCOOL.printLumiInfo(Dic_LBLumi)
134
135
DicPanels =
readElementFromXML
()
136
137
138
draw_occu =
CoreClass.Draw_Occupancy
(h_hit_panels)
139
draw_occu.SetPanelDic(DicPanels)
140
draw_occu.SetLumiInfoDic(Dic_LBLumi)
141
draw_occu.doNEvtScale(h_NEvt_LB)
142
143
h_name =
"NPRDHit_Panels_All"
144
145
# -----------------------------------------------------------------------
146
list_hist_all = []
147
list_hist_layer = []
148
list_hist_subDetector = []
149
for
i_var
in
[
"p0"
,
"p1"
,
"chi2"
,
"predRate"
,
"meanRate"
]:
150
153
list_hist1D_secLayer = draw_occu.GetHist1D_ySectorsAndLayers([h_name, i_var])
154
155
158
list_hist1D_panels = draw_occu.GetHist1D_yPanels([h_name, i_var])
159
160
list_hist_all += list_hist1D_secLayer+list_hist1D_panels
161
162
165
list_summary_allSectorsAndLayers = draw_occu.GetSummary_allSectorsAndLayers([h_name, i_var])
166
167
170
list_hist2d_EtaPhi_allLayer = draw_occu.GetHist2D_EtaPhi_allLayer([h_name, i_var])
171
172
list_hist_layer += list_summary_allSectorsAndLayers+list_hist2d_EtaPhi_allLayer
173
174
177
if
i_var
in
[
"p0"
,
"chi2"
,
"predRate"
]:
178
list_summary_eachSectorsAndLayers = draw_occu.GetSummary_eachSectorsAndLayers([h_name, i_var])
179
180
list_hist_subDetector += list_summary_eachSectorsAndLayers
181
182
getHistNames
(list_hist_all,
"Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/HitRate_vs_InstLumi"
, dic_hists)
183
getHistNames
(list_hist_layer,
"Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/HitRate_vs_InstLumi/Layers"
, dic_hists)
184
getHistNames
(list_hist_subDetector,
"Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/HitRate_vs_InstLumi/SubDetector"
, dic_hists)
185
186
return
dic_hists
187
188
189
def
make_2dhits
(inputs):
190
hist_2dhits = inputs[0][1][0].Clone()
#"NPRDHit_Panels_All"
191
hist_projY = hist_2dhits.ProjectionY(
"NPRDHit_Panels_All_py"
)
192
DicPanels =
readElementFromXML
()
193
194
draw_hits =
CoreClass.Draw_2DCount
(hist_projY)
195
draw_hits.SetPanelDic(DicPanels)
196
197
h_name =
"NPRDHit_Panels_All_py"
198
199
# -----------------------------------------------------------------------
200
variable =
"prdhits"
201
config = [h_name, variable]
202
dic_histos = {}
203
204
207
list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False
)
208
getHistNames
(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/Hits"
, dic_histos)
209
210
return
dic_histos
211
212
213
214
def
make_hitMulti
(inputs):
215
hist = inputs[0][1][0].Clone()
216
DicPanels =
readElementFromXML
()
217
218
print
(
"make_hitMulti - hist = "
, hist)
219
220
draw_hitmulti =
CoreClass.Draw_HitMultiplicity
(hist)
221
draw_hitmulti.SetPanelDic(DicPanels)
222
223
# -----------------------------------------------------------------------
224
# draw hit multiplicity
225
h_name =
"HitMultiplicity_Panels"
226
variable =
"hitMultiplicity"
227
228
231
list_hist1D_secLayer_hitMu = draw_hitmulti.GetHist1D_ySectorsAndLayers([h_name, variable])
232
233
236
list_hist1D_panels_hitMu = draw_hitmulti.GetHist1D_yPanels([h_name, variable])
237
238
# -----------------------------------------------------------------------
239
# draw cluster size
240
h2_CS =
"ClusterSize_Panels"
241
variable =
"averageClusterSize"
242
hist_clus = inputs[0][1][1].Clone()
243
draw_clus =
CoreClass.Draw_HitMultiplicity
(hist_clus)
244
draw_clus.SetPanelDic(DicPanels)
245
246
249
list_hist1D_secLayer_cluster = draw_hitmulti.GetHist1D_ySectorsAndLayers([h2_CS, variable])
250
251
254
list_hist1D_panels_cluster = draw_hitmulti.GetHist1D_yPanels([h2_CS, variable])
255
256
return
list_hist1D_secLayer_hitMu+list_hist1D_panels_hitMu+list_hist1D_secLayer_cluster+list_hist1D_panels_cluster
257
258
259
def
make_detection_eff
(inputs):
260
hist = inputs[0][1][0].Clone()
261
DicPanels =
readElementFromXML
()
262
263
draw_eff =
CoreClass.Draw_DetectEfficiency
(hist)
264
draw_eff.SetPanelDic(DicPanels)
265
266
h_name =
"Detection_Efficiency_MuonFromZ"
267
268
# -----------------------------------------------------------------------
269
variable =
"detEff"
270
config = [h_name, variable]
271
dic_histos = {}
272
273
276
list_summary_allSectorsAndLayers = draw_eff.GetSummary_allSectorsAndLayers(config)
277
getHistNames
(list_summary_allSectorsAndLayers,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff"
, dic_histos)
278
279
282
list_summary_eachSectorsAndLayers= draw_eff.GetSummary_eachSectorsAndLayers(config)
283
getHistNames
(list_summary_eachSectorsAndLayers,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff/SubDetector"
, dic_histos)
284
285
288
list_hist2d_EtaPhi_allLayer = draw_eff.GetHist2D_EtaPhi_allLayer(config)
289
getHistNames
(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff"
, dic_histos)
290
291
294
list_hist1D_secLayer = draw_eff.GetHist1D_ySectorsAndLayers(config)
295
getHistNames
(list_hist1D_secLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff"
, dic_histos)
296
297
300
list_hist1D_panels = draw_eff.GetHist1D_yPanels(config)
301
getHistNames
(list_hist1D_panels,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff"
, dic_histos)
302
303
return
dic_histos
304
305
306
def
make_2d_nmuons_Z
(inputs):
307
hist_eff = inputs[0][1][0].Clone()
#"Detection_Efficiency_MuonFromZ"
308
DicPanels =
readElementFromXML
()
309
310
dic_histos = {}
311
314
hist_num = hist_eff.GetPassedHistogram()
315
draw_hits =
CoreClass.Draw_2DCount
(hist_num)
316
draw_hits.SetPanelDic(DicPanels)
317
318
# -----------------------------------------------------------------------
319
h_name =
"Muon_Z_ex2RpcPanelWithHit"
320
variable =
"muon_Z_num"
321
config = [h_name, variable]
322
323
# "muon_Z_num_layer[1-8]_measPhi[01]",
324
list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False
)
325
getHistNames
(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/NMuon"
, dic_histos)
326
327
330
hist_num = hist_eff.GetTotalHistogram()
331
draw_hits =
CoreClass.Draw_2DCount
(hist_num)
332
draw_hits.SetPanelDic(DicPanels)
333
334
# -----------------------------------------------------------------------
335
h_name =
"Muon_Z_ex2RpcPanel"
336
variable =
"muon_Z_den"
337
config = [h_name, variable]
338
339
# "muon_Z_den_layer[1-8]_measPhi[01]",
340
list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False
)
341
getHistNames
(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/NMuon"
, dic_histos)
342
343
return
dic_histos
344
345
346
def
make_2d_nmuons_all
(inputs):
347
hist_eff = inputs[0][1][0].Clone()
#"Detection_Efficiency_AllMuons"
348
DicPanels =
readElementFromXML
()
349
350
dic_histos = {}
351
354
hist_num = hist_eff.GetPassedHistogram()
355
draw_hits =
CoreClass.Draw_2DCount
(hist_num)
356
draw_hits.SetPanelDic(DicPanels)
357
358
# -----------------------------------------------------------------------
359
h_name =
"Muon_all_ex2RpcPanelWithHit"
360
variable =
"muon_all_num"
361
config = [h_name, variable]
362
363
# "muon_all_num_layer[1-8]_measPhi[01]",
364
list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False
)
365
getHistNames
(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/NMuon"
, dic_histos)
366
367
370
hist_num = hist_eff.GetTotalHistogram()
371
draw_hits =
CoreClass.Draw_2DCount
(hist_num)
372
draw_hits.SetPanelDic(DicPanels)
373
374
# -----------------------------------------------------------------------
375
h_name =
"Muon_all_ex2RpcPanel"
376
variable =
"muon_all_den"
377
config = [h_name, variable]
378
379
# "muon_all_den_layer[1-8]_measPhi[01]",
380
list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False
)
381
getHistNames
(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/NMuon"
, dic_histos)
382
383
return
dic_histos
384
385
386
def
make_hitFrac
(inputs):
387
DicPanels =
readElementFromXML
()
388
389
390
# -----------------------------------------------------------------------
391
# out-of-time fraction of hits
392
# -----------------------------------------------------------------------
393
hist = inputs[0][1][0].Clone()
394
draw_histFrac =
CoreClass.Draw_HitOuttimeFraction
(hist)
395
draw_histFrac.SetPanelDic(DicPanels)
396
397
h_name =
"OuttimeHitFraction_PRDHit"
398
var =
"outTimeHitFrac"
399
config = [h_name, var]
400
401
404
list_hist1D_secLayer_hitFrac = draw_histFrac.GetHist1D_ySectorsAndLayers(config)
405
406
409
list_hist1D_panels_hitFrac = draw_histFrac.GetHist1D_yPanels(config)
410
411
# -----------------------------------------------------------------------
412
# out-of-time fraction of hits on track
413
# -----------------------------------------------------------------------
414
hist_onTrack = inputs[0][1][1].Clone()
415
draw_histFrac_onTrack =
CoreClass.Draw_HitOuttimeFraction
(hist_onTrack)
416
draw_histFrac_onTrack.SetPanelDic(DicPanels)
417
418
h_name =
"OuttimeHitFraction_PRDHit_onTrack"
419
var =
"outTimeHitFrac_onTrack"
420
config = [h_name, var]
421
422
425
list_hist1D_secLayer_hitFracOnTrack = draw_histFrac_onTrack.GetHist1D_ySectorsAndLayers(config)
426
427
430
list_hist1D_panels_hitFracOnTrack = draw_histFrac_onTrack.GetHist1D_yPanels(config)
431
432
return
list_hist1D_secLayer_hitFrac+list_hist1D_panels_hitFrac+list_hist1D_secLayer_hitFracOnTrack+list_hist1D_panels_hitFracOnTrack
433
434
435
436
def
getHistNames
(hist_list, prefix, dic_hist):
437
for
i_hist
in
hist_list:
438
i_name =
"%s/%s"
%(prefix, i_hist.GetName())
439
dic_hist[i_name] = i_hist
440
441
442
443
if
__name__ ==
'__main__'
:
444
print
(
"RPCPostProcessing: Hello, World !"
)
445
446
# infile = ROOT.TFile("ExampleMonitorOutput.root", "READ")
447
# hist = infile.Get("run_358615/Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/NPRDHit_Panels_All")
448
# inputs = [[0, [hist]]]
449
# dic_ = make_2dhits(inputs)
450
CoreClass.Draw_2DCount
Definition
CoreClass.py:1148
CoreClass.Draw_DetectEfficiency
Definition
CoreClass.py:974
CoreClass.Draw_HitMultiplicity
Definition
CoreClass.py:875
CoreClass.Draw_HitOuttimeFraction
Definition
CoreClass.py:1073
CoreClass.Draw_Occupancy
Definition
CoreClass.py:661
RPCRawDataMonUtils.Panel
Definition
RPCRawDataMonUtils.py:76
GetLBInfoFromCOOL.GetLumiInfoDic
GetLumiInfoDic(beg_run, end_run)
Definition
GetLBInfoFromCOOL.py:173
RPCPostProcessing.make_2d_nmuons_Z
make_2d_nmuons_Z(inputs)
Definition
RPCPostProcessing.py:306
RPCPostProcessing.make_hit_rate
make_hit_rate(inputs)
Definition
RPCPostProcessing.py:117
RPCPostProcessing.make_2d_nmuons_all
make_2d_nmuons_all(inputs)
Definition
RPCPostProcessing.py:346
RPCPostProcessing.make_hitMulti
make_hitMulti(inputs)
Definition
RPCPostProcessing.py:214
RPCPostProcessing.make_detection_eff
make_detection_eff(inputs)
Definition
RPCPostProcessing.py:259
RPCPostProcessing.readElementFromXML
readElementFromXML()
Definition
RPCPostProcessing.py:13
RPCPostProcessing.getRun
getRun(h_run)
Definition
RPCPostProcessing.py:69
RPCPostProcessing.getHistNames
getHistNames(hist_list, prefix, dic_hist)
Definition
RPCPostProcessing.py:436
RPCPostProcessing.make_hitFrac
make_hitFrac(inputs)
Definition
RPCPostProcessing.py:386
RPCPostProcessing.make_2dhits
make_2dhits(inputs)
Definition
RPCPostProcessing.py:189
RPCPostProcessing.make_evt_lumi
make_evt_lumi(inputs)
Definition
RPCPostProcessing.py:80
RPCRawDataMonUtils.creatGraph
creatGraph(xs, ys, x_errs, y_errs, g_name, g_title, g_Xtitle, g_Ytitle)
Definition
RPCRawDataMonUtils.py:8
Generated on
for ATLAS Offline Software by
1.17.0