1 from __future__
import print_function
3 from drawHistoAllChambers
import drawHisto
6 start = (station - 1)*12
9 def plot(fileName,sl,ymin=300,ymax=360,option="HISTOP",draw=True):
12 slStr =
"SL%d" % slType
15 ROOT.TH1.AddDirectory(
False)
17 file = ROOT.TFile(fileName,
'read')
19 wheels = (-2,-1,0,1,2)
24 histoName =
'Wheel%d_%s_TTrig' % (wh,slStr)
25 print(
"Accessing",histoName)
26 histosWheel[wh] = file.Get(histoName)
31 if slType == 2: nBins = 180
32 histo = ROOT.TH1F(
"h_TTrigAll",
"TTrig",nBins,0,nBins)
35 if st == 4: nSectors = 14
36 if st == 4
and slType == 2:
continue 37 if verbose:
print(
"Station",st)
39 if verbose:
print(
"Wheel",wh)
40 for sec
in range(1,nSectors+1):
41 if verbose:
print(
"Sector",sec)
43 if verbose:
print(
"Bin from histos:",binHisto)
44 value = histosWheel[wh].GetBinContent(binHisto)
46 binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
47 if verbose:
print(
"Bin final",binHistoNew)
48 histo.SetBinContent(binHistoNew,value)
51 label =
"Wheel %d" % wh
52 if wh == -2: label +=
" MB%d" % st
53 histo.GetXaxis().SetBinLabel(binHistoNew,label)
56 title=
"t_{Trig} (ns)",
57 ymin=ymin,ymax=ymax,option=option,draw=draw)
61 def compare(fileNames,sl,ymin=300,ymax=360,labels=[]):
63 colors = (2,4,12,44,55,38,27,46)
64 markers = (24,25,26,27,28,30,32,5)
70 for fileName
in fileNames:
72 if not idx: draw =
True 74 objs =
plot(fileName,sl,ymin,ymax,option,draw)
75 histos.append(objs[1])
76 histos[-1].SetName(
"%s_%d" % (histos[-1].GetName(),idx) )
83 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
84 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
85 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
87 histos[-1].Draw(option +
"SAME")
91 legend = ROOT.TLegend(0.4,0.7,0.95,0.8)
92 for idx
in range( len(histos) ):
94 label = histo.GetName()
95 if len(labels): label = labels[idx]
96 legend.AddEntry(histo,label,
"LP")
101 legend.SetFillColor( canvas.GetFillColor() )
104 objects.append(legend)
106 return (canvas,histos,objects)
110 colors = (2,4,9,12,38,44,46,55)
111 markers = (24,25,26,27,28,30,32,5)
114 canvases = [
None,
None]
119 for fileName
in fileNames:
120 objs =
plot(fileName,sl,300,360,
'',
False)
121 histos.append( objs[1].Clone(objs[1].GetName() +
"_diff") )
122 histos[-1].SetName(
"%s_%d" % (histos[-1].GetName(),idx) )
127 histos[-1].Add(histoRef,-1.)
130 if not idx: draw =
True 133 title=
"t_{Trig} difference (ns)",
134 ymin=ymin,ymax=ymax,option=option,draw=draw)
137 canvases[0] = objs[0]
142 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
143 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
144 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
146 histos[-1].Draw(option +
"SAME")
148 histosDist.append( ROOT.TH1F(histos[-1].GetName() +
"_dist",
"tTrig distribution",200,ymin,ymax) )
149 for ibin
in range(1,histos[-1].GetNbinsX()+1):
150 histosDist[-1].
Fill( histos[-1].GetBinContent(ibin) )
152 histosDist[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
153 histosDist[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
154 histosDist[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
159 canvases[1] = ROOT.TCanvas(
"c_tTrigDist")
160 canvases[1].SetGridy()
161 canvases[1].SetFillColor(0)
165 for histo
in histosDist:
167 histo.GetXaxis().SetTitle(
"t_{Trig} difference (ns)")
168 histo.GetYaxis().SetTitle(
"Number of chambers")
171 histo.Draw(option +
"SAME")
174 return (canvases,histos,histosDist,objects)
def binNumber(station, sector)
def plot(fileName, sl, ymin=300, ymax=360, option="HISTOP", draw=True)
S & print(S &os, JobReport::InputFile const &f)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
def compare(fileNames, sl, ymin=300, ymax=360, labels=[])
def compareDiff(fileNames, sl, ymin=-15., ymax=15.)
void Reset(std::vector< TH2F > &depth)
def drawHisto(histo, title, ymin, ymax, option="HISTOP", draw=True)