2 from drawHistoAllChambers
import drawHisto
5 if sl
is 3
and station
is 4:
return 11
6 if sl
is 2
and station
is 4:
return None 7 start = (station - 1)*3
10 def plot(fileName,sl,run,ymin=-5,ymax=5,option="HISTOP",draw=True):
11 path =
"DQMData/Run "+
str(run)+
"/DT/Run summary/DtCalib/TTrigDBValidation/" 13 slStr =
"SL%d" % slType
16 ROOT.TH1.AddDirectory(
False)
18 file = ROOT.TFile(fileName,
'read')
20 wheels = (-2,-1,0,1,2)
33 histo = ROOT.TH1F(
"h_TTrigAll",
"TTrig Run "+
str(run),nBins,0,nBins)
36 if st == 4: nSectors = 14
37 if st == 4
and sl == 2:
continue 38 if verbose:
print "Station",st
40 if verbose:
print "Wheel",wh
41 for sec
in range(1,nSectors+1):
42 if verbose:
print "Sector",sec
44 if verbose:
print "Bin from histos:",binHisto
45 histoName = path+
'Wheel%d/TTrigDifference_W%d_Sec%d' % (wh,wh,sec)
46 value = file.Get(histoName).GetBinContent(binHisto)
48 binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
49 if verbose:
print "Bin final",binHistoNew,value
50 histo.SetBinContent(binHistoNew,value)
53 label =
"Wheel %d" % wh
54 if wh == -2: label +=
" MB%d" % st
55 histo.GetXaxis().SetBinLabel(binHistoNew,label)
58 title=
"#Deltat_{Trig} (ns)",
59 ymin=ymin,ymax=ymax,option=option,draw=draw)
63 def SLcompare(fileName,sls,run,ymin=-5,ymax=5,labels=[]):
65 colors = (2,4,12,44,55,38,27,46)
66 markers = (24,25,26,27,28,30,32,5)
74 if not idx: draw =
True 76 objs =
plot(fileName,sl,run,ymin,ymax,option,draw)
77 histos.append(objs[1])
78 histos[-1].SetName(
"SL %d" % sl)
85 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
86 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
87 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
89 histos[-1].Draw(option +
"SAME")
93 legend = ROOT.TLegend(0.4,0.7,0.95,0.8)
94 for idx
in range( len(histos) ):
96 label = histo.GetName()
97 if len(labels): label = labels[idx]
98 legend.AddEntry(histo,label,
"LP")
103 legend.SetFillColor( canvas.GetFillColor() )
106 objects.append(legend)
108 return (canvas,histos,objects)
112 colors = (2,4,9,12,38,44,46,55)
113 markers = (24,25,26,27,28,30,32,5)
116 canvases = [
None,
None]
121 for fileName
in fileNames:
122 objs =
plot(fileName,sl,300,360,
'',
False)
123 histos.append( objs[1].Clone(objs[1].GetName() +
"_diff") )
124 histos[-1].SetName(
"%s_%d" % (histos[-1].GetName(),idx) )
129 histos[-1].Add(histoRef,-1.)
132 if not idx: draw =
True 135 title=
"t_{Trig} difference (ns)",
136 ymin=ymin,ymax=ymax,option=option,draw=draw)
139 canvases[0] = objs[0]
144 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
145 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
146 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
148 histos[-1].Draw(option +
"SAME")
150 histosDist.append( ROOT.TH1F(histos[-1].GetName() +
"_dist",
"tTrig distribution",200,ymin,ymax) )
151 for ibin
in range(1,histos[-1].GetNbinsX()+1):
152 histosDist[-1].
Fill( histos[-1].GetBinContent(ibin) )
154 histosDist[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
155 histosDist[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
156 histosDist[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
161 canvases[1] = ROOT.TCanvas(
"c_tTrigDist")
162 canvases[1].SetGridy()
163 canvases[1].SetFillColor(0)
167 for histo
in histosDist:
169 histo.GetXaxis().SetTitle(
"t_{Trig} difference (ns)")
170 histo.GetYaxis().SetTitle(
"Number of chambers")
173 histo.Draw(option +
"SAME")
176 return (canvases,histos,histosDist,objects)
def plot(fileName, sl, run, ymin=-5, ymax=5, option="HISTOP", draw=True)
def binNumber(station, sl)
def SLcompare(fileName, sls, run, ymin=-5, ymax=5, labels=[])
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
def compareDiff(fileNames, sl, ymin=-15., ymax=15.)
void Reset(std::vector< TH2F > &depth)
def drawHisto(histo, title, ymin, ymax, option="HISTOP", draw=True)