2 from drawHistoAllChambers
import drawHisto
5 start = (station - 1)*12
8 def plot(fileName,sl,ymin=300,ymax=360,option="HISTOP",draw=True):
11 slStr =
"SL%d" % slType
14 ROOT.TH1.AddDirectory(
False)
16 file = ROOT.TFile(fileName,
'read')
18 wheels = (-2,-1,0,1,2)
23 histoName =
'Wheel%d_%s_TTrig' % (wh,slStr)
24 print "Accessing",histoName
25 histosWheel[wh] = file.Get(histoName)
30 if slType == 2: nBins = 180
31 histo = ROOT.TH1F(
"h_TTrigAll",
"TTrig",nBins,0,nBins)
34 if st == 4: nSectors = 14
35 if st == 4
and slType == 2:
continue
36 if verbose:
print "Station",st
38 if verbose:
print "Wheel",wh
39 for sec
in range(1,nSectors+1):
40 if verbose:
print "Sector",sec
42 if verbose:
print "Bin from histos:",binHisto
43 value = histosWheel[wh].GetBinContent(binHisto)
45 binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
46 if verbose:
print "Bin final",binHistoNew
47 histo.SetBinContent(binHistoNew,value)
50 label =
"Wheel %d" % wh
51 if wh == -2: label +=
" MB%d" % st
52 histo.GetXaxis().SetBinLabel(binHistoNew,label)
55 title=
"t_{Trig} (ns)",
56 ymin=ymin,ymax=ymax,option=option,draw=draw)
60 def compare(fileNames,sl,ymin=300,ymax=360,labels=[]):
62 colors = (2,4,12,44,55,38,27,46)
63 markers = (24,25,26,27,28,30,32,5)
69 for fileName
in fileNames:
71 if not idx: draw =
True
73 objs =
plot(fileName,sl,ymin,ymax,option,draw)
74 histos.append(objs[1])
75 histos[-1].SetName(
"%s_%d" % (histos[-1].GetName(),idx) )
82 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
83 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
84 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
86 histos[-1].Draw(option +
"SAME")
90 legend = ROOT.TLegend(0.4,0.7,0.95,0.8)
91 for idx
in range( len(histos) ):
93 label = histo.GetName()
94 if len(labels): label = labels[idx]
95 legend.AddEntry(histo,label,
"LP")
100 legend.SetFillColor( canvas.GetFillColor() )
103 objects.append(legend)
105 return (canvas,histos,objects)
109 colors = (2,4,9,12,38,44,46,55)
110 markers = (24,25,26,27,28,30,32,5)
113 canvases = [
None,
None]
118 for fileName
in fileNames:
119 objs =
plot(fileName,sl,300,360,
'',
False)
120 histos.append( objs[1].Clone(objs[1].GetName() +
"_diff") )
121 histos[-1].SetName(
"%s_%d" % (histos[-1].GetName(),idx) )
126 histos[-1].Add(histoRef,-1.)
129 if not idx: draw =
True
132 title=
"t_{Trig} difference (ns)",
133 ymin=ymin,ymax=ymax,option=option,draw=draw)
136 canvases[0] = objs[0]
141 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
142 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
143 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
145 histos[-1].Draw(option +
"SAME")
147 histosDist.append( ROOT.TH1F(histos[-1].GetName() +
"_dist",
"tTrig distribution",200,ymin,ymax) )
148 for ibin
in range(1,histos[-1].GetNbinsX()+1):
149 histosDist[-1].
Fill( histos[-1].GetBinContent(ibin) )
151 histosDist[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
152 histosDist[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
153 histosDist[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
158 canvases[1] = ROOT.TCanvas(
"c_tTrigDist")
159 canvases[1].SetGridy()
160 canvases[1].SetFillColor(0)
164 for histo
in histosDist:
166 histo.GetXaxis().SetTitle(
"t_{Trig} difference (ns)")
167 histo.GetYaxis().SetTitle(
"Number of chambers")
170 histo.Draw(option +
"SAME")
173 return (canvases,histos,histosDist,objects)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void Reset(std::vector< TH2F > &depth)