ATLAS Offline Software
Loading...
Searching...
No Matches
extractSporadic.py
Go to the documentation of this file.
1#!/usr/bin env python
2
3# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4
5
6# ======================================================================
7def printProperties(h,q,hLB):
8
9 print ("=======================Harware coordinates :",h.GetName()[0:h.GetName().find("Phi")-1])
10 print ("Coordinates : Eta = ",h.GetName()[h.GetName().find("Eta")+3:h.GetName().find("Eta")+7]," Phi = ",h.GetName()[h.GetName().find("Phi")+3:h.GetName().find("Phi")+7])
11
12
13 # Nb of events with E>20GeV and mean energy
14 nbEvts20GeV = 0
15 meanE = 0
16 for ix in range(61,h.GetNbinsX()+2):# Bin 61 = 20GeV
17 nbEvts20GeV = nbEvts20GeV+h.GetBinContent(ix)
18 meanE = meanE + h.GetBinContent(ix)*h.GetBinCenter(ix)
19 meanE = meanE / nbEvts20GeV/ 1000
20
21 # Nb of events with q factor > 4000
22 nbEvts4000 = 0
23 for ix in range(11,q.GetNbinsX()+2):# Bin 11 = 4000
24 nbEvts4000 = nbEvts4000 + q.GetBinContent(ix)
25
26 # Nb of LBs where at least one event with E>20GeV is found
27 nbLB20GeV = 0
28 allLBs = ""
29 for ix in range(1,hLB.GetNbinsX()+1):
30 lbAff = False
31 for iy in range(61,hLB.GetNbinsY()+2):# Bin 61 = 20GeV
32 if hLB.GetBinContent(ix,iy) != 0:
33 lbAff = True
34 if lbAff:
35 nbLB20GeV = nbLB20GeV+1
36 allLBs = allLBs + " %d"%ix
37
38 print ("# of events: E>20GeV / E>20GeV && q>4000 : %d / %d"%(nbEvts4000,nbEvts20GeV))
39 print ("Mean energy above 20geV: %.2f GeV"%meanE)
40 print (nbLB20GeV," LBs contains energetic events: ", allLBs )
41 return
42
43# ======================================================================
44def displayHistos(h,q,hLB,canvas):
45 canvas.Divide(1,2)
46 canvas.cd(1)
47 ROOT.gPad.Divide(2,1)
48 ROOT.gPad.cd(1)
49 ROOT.gPad.SetLogy()
50 gStyle.SetOptStat(100110)
51 h.Draw()
52
53 canvas.cd(1)
54 ROOT.gPad.cd(2)
55 q.Draw()
56
57 canvas.cd(2)
58 hLB.SetStats(0)
59 hLB.Draw("COLZ")
60
61 canvas.cd()
62 return
63
64
65# Main =================================================================
66import sys
67
68if len(sys.argv)<4:
69 print ("python -i extractSporadic.py 159041 x29_m545 EMBA [FT29Sl2Ch68]")
70 print ("If no channel is specified, displays all with more than 20 events above 20 GeV")
71 sys.exit()
72
73#os.system("nsls /castor/cern.ch/grid/atlas/tzero/prod1/perm/data10_7TeV/physics_CosmicCalo/0"+sys.argv[1])
74
75import ROOT
76from ROOT import gROOT, gDirectory
77from ROOT import gStyle, TCanvas
78from ROOT import TRFIOFile
79
80gROOT.Reset()
81gStyle.SetPalette(1)
82
83nameFile = "/castor/cern.ch/grid/atlas/tzero/prod1/perm/data10_7TeV/physics_CosmicCalo/0"+sys.argv[1]+"/data10_7TeV.00"+sys.argv[1]+".physics_CosmicCalo.merge.HIST."+sys.argv[2]+"/data10_7TeV.00"+sys.argv[1]+".physics_CosmicCalo.merge.HIST."+sys.argv[2]+"._0001.1"
84nameDir = "run_"+sys.argv[1]+"/CaloMonitoring/LArCellMon_NoTrigSel/Sporadic20GeV/"+sys.argv[3]
85
86myFile = TRFIOFile(nameFile)
87
88# General numbers
89hNbEvts = myFile.Get("run_"+sys.argv[1]+"/LAr/FEBMon/perPartitionData/Eventtype")
90print ("This stream contains %d events"%hNbEvts.GetEntries())
91
92myFile.cd(nameDir)
93
94# Compile all channels
95if len(sys.argv) == 4:
96 h=[]
97 q=[]
98 hLB=[]
99 listOfKeys = gDirectory.GetListOfKeys()
100 for key in listOfKeys:
101 name = key.GetName()
102 type = key.GetClassName()
103 if type == "TH1F" and name.find("EN") != -1 :
104 h.append(myFile.Get(nameDir+"/"+name))
105 if type == "TH1F" and name.find("Quality") != -1 :
106 q.append(myFile.Get(nameDir+"/"+name))
107 if type == "TH2F" and name.find("ENLB") != -1 :
108 hLB.append(myFile.Get(nameDir+"/"+name))
109
110 nhists = len(h)
111 print ("retrieved %i histos"%nhists)
112
113 for i in range(0, nhists):
114 if h[i].Integral(61,h[i].GetNbinsX()+1) >= 20:
115 printProperties(h[i],q[i],hLB[i])
116
117# Extract the corresponding channel
118if len(sys.argv) == 5:
119 nameHisto = sys.argv[4]
120 listOfKeys = gDirectory.GetListOfKeys()
121 for key in listOfKeys:
122 name = key.GetName()
123 type = key.GetClassName()
124 if type == "TH1F" and name.find("EN") != -1 and name.find(nameHisto) != -1:
125 h = myFile.Get(nameDir+"/"+name)
126 if type == "TH2F" and name.find("ENLB") != -1 and name.find(nameHisto) != -1:
127 hLB = myFile.Get(nameDir+"/"+name)
128 if type == "TH1F" and name.find("Quality") != -1 and name.find(nameHisto) != -1:
129 q = myFile.Get(nameDir+"/"+name)
130
131 if (h != 0):
132 printProperties(h,q,hLB)
133 c1 = TCanvas('c1','c1',1000,600)
134 displayHistos(h,q,hLB,c1)
135
136
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
displayHistos(h, q, hLB, canvas)
printProperties(h, q, hLB)