8 import RpcRawDataMonitoring.RPCRawDataMonUtils
as RPCRawDataMonUtils
9 import RpcRawDataMonitoring.CoreClass
as CoreClass
10 import RpcRawDataMonitoring.GetLBInfoFromCOOL
as GetLBInfoFromCOOL
15 import xml.dom.minidom
as Dom
20 xml_file = ROOT.PathResolver.find_file(
"Element.xml",
"DATAPATH", ROOT.PathResolver.RecursiveSearch)
22 if not os.path.isfile(xml_file):
23 print (
"ERROR: can NOT find xml file: %s!" %xml_file)
26 dom = Dom.parse(xml_file)
27 root_node = dom.documentElement
28 ele_nodes = root_node.childNodes
32 BMBO_StationNames = {2, 3, 4, 5, 8, 9, 10, 53}
33 for i_node
in ele_nodes:
34 if i_node.nodeType != 1:
38 ele_index =
int(i_node.getAttribute(
"index"))
40 panel_property[
"stationName"] =
int(i_node.getAttribute(
"stationName"))
41 panel_property[
"stationEta" ] =
int(i_node.getAttribute(
"stationEta"))
42 panel_property[
"stationPhi" ] =
int(i_node.getAttribute(
"stationPhi"))
43 panel_property[
"doubletR" ] =
int(i_node.getAttribute(
"doubletR"))
44 panel_property[
"doubletZ" ] =
int(i_node.getAttribute(
"doubletZ"))
46 if panel_property[
"stationName"]
in BMBO_StationNames:
52 for gasgap
in range(1, ngasgap+1):
53 for measPhi
in [0, 1]:
54 panel_property[
"doubletPhi"] = dbPhi
55 panel_property[
"gasGap"] = gasgap
56 panel_property[
"measPhi"] = measPhi
58 panel_index = (ele_index-1)*8 + (dbPhi - 1)*4 + (gasgap - 1)*2 + measPhi
61 if not (panel_index
in Dic_panels):
62 Dic_panels[panel_index] = i_panel
64 print (
"ERROR: duplicated panel index!!!")
66 print (
"RPCPostProcessing::readElementFromXML::INFO: count of read panels = %d" %(len(Dic_panels)))
72 xbins = h_run.GetNbinsX()
75 for i_bin
in range(1, xbins+1):
76 if h_run.GetBinContent(i_bin) > 0:
77 runs.append(
int(h_run.GetBinLowEdge(i_bin))+1)
83 h_NEvt_LB = inputs[0][1][0].Clone()
84 h_run = inputs[0][1][1].Clone()
89 g_name =
'NEvent_VS_Lumi'
90 g_title =
'NEvent VS Lumi'
91 g_Xtitle =
'Inst Luminosity [10^{34} cm^{-2}s^{-1}]'
98 if Dic_LBLumi
is not None:
99 print (
"len(Dic_LBLumi) = ", len(Dic_LBLumi))
101 for LB, lbInfo
in Dic_LBLumi.items():
102 if lbInfo[
'AtlasPhysics'] ==
'false' or float(lbInfo[
'Duration'])<50.:
105 hit_content = h_NEvt_LB.GetBinContent(LB)
106 hit_err = h_NEvt_LB.GetBinError(LB)
108 x.append(
float(lbInfo[
'InstLumi']) )
109 y.append( hit_content )
110 y_err.append( hit_err )
120 h_hit_panels = inputs[0][1][0].Clone()
121 h_NEvt_LB = inputs[0][1][1].Clone()
122 h_run = inputs[0][1][2].Clone()
126 print (
"make_hit_rate::WARNING - Input file contain data in ", len(runs),
" **runs**, which should only include 1-run and full data !!!")
133 if Dic_LBLumi
is not None:
134 print (
"len(Dic_LBLumi) = ", len(Dic_LBLumi))
141 draw_occu.SetPanelDic(DicPanels)
142 draw_occu.SetLumiInfoDic(Dic_LBLumi)
143 draw_occu.doNEvtScale(h_NEvt_LB)
145 h_name =
"NPRDHit_Panels_All"
150 list_hist_subDetector = []
151 for i_var
in [
"p0",
"p1",
"chi2",
"predRate",
"meanRate"]:
155 list_hist1D_secLayer = draw_occu.GetHist1D_ySectorsAndLayers([h_name, i_var])
160 list_hist1D_panels = draw_occu.GetHist1D_yPanels([h_name, i_var])
162 list_hist_all += list_hist1D_secLayer+list_hist1D_panels
167 list_summary_allSectorsAndLayers = draw_occu.GetSummary_allSectorsAndLayers([h_name, i_var])
172 list_hist2d_EtaPhi_allLayer = draw_occu.GetHist2D_EtaPhi_allLayer([h_name, i_var])
174 list_hist_layer += list_summary_allSectorsAndLayers+list_hist2d_EtaPhi_allLayer
179 if i_var
in [
"p0",
"chi2",
"predRate"]:
180 list_summary_eachSectorsAndLayers = draw_occu.GetSummary_eachSectorsAndLayers([h_name, i_var])
182 list_hist_subDetector += list_summary_eachSectorsAndLayers
184 getHistNames(list_hist_all,
"Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/HitRate_vs_InstLumi", dic_hists)
185 getHistNames(list_hist_layer,
"Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/HitRate_vs_InstLumi/Layers", dic_hists)
186 getHistNames(list_hist_subDetector,
"Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/HitRate_vs_InstLumi/SubDetector", dic_hists)
192 hist_2dhits = inputs[0][1][0].Clone()
193 hist_projY = hist_2dhits.ProjectionY(
"NPRDHit_Panels_All_py")
197 draw_hits.SetPanelDic(DicPanels)
199 h_name =
"NPRDHit_Panels_All_py"
203 config = [h_name, variable]
209 list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False)
210 getHistNames(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/RpcOccupancy/Hits", dic_histos)
217 hist = inputs[0][1][0].Clone()
220 print (
"make_hitMulti - hist = ", hist)
223 draw_hitmulti.SetPanelDic(DicPanels)
227 h_name =
"HitMultiplicity_Panels"
228 variable =
"hitMultiplicity"
233 list_hist1D_secLayer_hitMu = draw_hitmulti.GetHist1D_ySectorsAndLayers([h_name, variable])
238 list_hist1D_panels_hitMu = draw_hitmulti.GetHist1D_yPanels([h_name, variable])
242 h2_CS =
"ClusterSize_Panels"
243 variable =
"averageClusterSize"
244 hist_clus = inputs[0][1][1].Clone()
246 draw_clus.SetPanelDic(DicPanels)
251 list_hist1D_secLayer_cluster = draw_hitmulti.GetHist1D_ySectorsAndLayers([h2_CS, variable])
256 list_hist1D_panels_cluster = draw_hitmulti.GetHist1D_yPanels([h2_CS, variable])
258 return list_hist1D_secLayer_hitMu+list_hist1D_panels_hitMu+list_hist1D_secLayer_cluster+list_hist1D_panels_cluster
262 hist = inputs[0][1][0].Clone()
266 draw_eff.SetPanelDic(DicPanels)
268 h_name =
"Detection_Efficiency_MuonFromZ"
272 config = [h_name, variable]
278 list_summary_allSectorsAndLayers = draw_eff.GetSummary_allSectorsAndLayers(config)
279 getHistNames(list_summary_allSectorsAndLayers,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff", dic_histos)
284 list_summary_eachSectorsAndLayers= draw_eff.GetSummary_eachSectorsAndLayers(config)
285 getHistNames(list_summary_eachSectorsAndLayers,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff/SubDetector", dic_histos)
290 list_hist2d_EtaPhi_allLayer = draw_eff.GetHist2D_EtaPhi_allLayer(config)
291 getHistNames(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff", dic_histos)
296 list_hist1D_secLayer = draw_eff.GetHist1D_ySectorsAndLayers(config)
297 getHistNames(list_hist1D_secLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff", dic_histos)
302 list_hist1D_panels = draw_eff.GetHist1D_yPanels(config)
303 getHistNames(list_hist1D_panels,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/MuonDetectionEff", dic_histos)
309 hist_eff = inputs[0][1][0].Clone()
316 hist_num = hist_eff.GetPassedHistogram()
318 draw_hits.SetPanelDic(DicPanels)
321 h_name =
"Muon_Z_ex2RpcPanelWithHit"
322 variable =
"muon_Z_num"
323 config = [h_name, variable]
326 list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False)
327 getHistNames(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/NMuon", dic_histos)
332 hist_num = hist_eff.GetTotalHistogram()
334 draw_hits.SetPanelDic(DicPanels)
337 h_name =
"Muon_Z_ex2RpcPanel"
338 variable =
"muon_Z_den"
339 config = [h_name, variable]
342 list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False)
343 getHistNames(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/NMuon", dic_histos)
349 hist_eff = inputs[0][1][0].Clone()
356 hist_num = hist_eff.GetPassedHistogram()
358 draw_hits.SetPanelDic(DicPanels)
361 h_name =
"Muon_all_ex2RpcPanelWithHit"
362 variable =
"muon_all_num"
363 config = [h_name, variable]
366 list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False)
367 getHistNames(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/NMuon", dic_histos)
372 hist_num = hist_eff.GetTotalHistogram()
374 draw_hits.SetPanelDic(DicPanels)
377 h_name =
"Muon_all_ex2RpcPanel"
378 variable =
"muon_all_den"
379 config = [h_name, variable]
382 list_hist2d_EtaPhi_allLayer = draw_hits.GetHist2D_EtaPhi_allLayer(config, doSetZRange =
False)
383 getHistNames(list_hist2d_EtaPhi_allLayer,
"Muon/MuonRawDataMonitoring/RPC/TrackMatch/NMuon", dic_histos)
395 hist = inputs[0][1][0].Clone()
397 draw_histFrac.SetPanelDic(DicPanels)
399 h_name =
"OuttimeHitFraction_PRDHit"
400 var =
"outTimeHitFrac"
401 config = [h_name, var]
406 list_hist1D_secLayer_hitFrac = draw_histFrac.GetHist1D_ySectorsAndLayers(config)
411 list_hist1D_panels_hitFrac = draw_histFrac.GetHist1D_yPanels(config)
416 hist_onTrack = inputs[0][1][1].Clone()
418 draw_histFrac_onTrack.SetPanelDic(DicPanels)
420 h_name =
"OuttimeHitFraction_PRDHit_onTrack"
421 var =
"outTimeHitFrac_onTrack"
422 config = [h_name, var]
427 list_hist1D_secLayer_hitFracOnTrack = draw_histFrac_onTrack.GetHist1D_ySectorsAndLayers(config)
432 list_hist1D_panels_hitFracOnTrack = draw_histFrac_onTrack.GetHist1D_yPanels(config)
434 return list_hist1D_secLayer_hitFrac+list_hist1D_panels_hitFrac+list_hist1D_secLayer_hitFracOnTrack+list_hist1D_panels_hitFracOnTrack
439 for i_hist
in hist_list:
440 i_name =
"%s/%s" %(prefix, i_hist.GetName())
441 dic_hist[i_name] = i_hist
445 if __name__ ==
'__main__':
446 print (
"RPCPostProcessing: Hello, World !")