1 from __future__
import print_function
2 from __future__
import absolute_import
4 from .drawHistoAllChambers
import drawHisto
7 if sl
is 3
and station
is 4:
return 11
8 if sl
is 2
and station
is 4:
return None
9 start = (station - 1)*3
12 def plot(fileName,sl,run,ymin=-5,ymax=5,option="HISTOP",draw=True):
13 path =
"DQMData/Run "+
str(run)+
"/DT/Run summary/DtCalib/TTrigDBValidation/"
15 slStr =
"SL%d" % slType
18 ROOT.TH1.AddDirectory(
False)
20 file = ROOT.TFile(fileName,
'read')
22 wheels = (-2,-1,0,1,2)
35 histo = ROOT.TH1F(
"h_TTrigAll",
"TTrig Run "+
str(run),nBins,0,nBins)
38 if st == 4: nSectors = 14
39 if st == 4
and sl == 2:
continue
40 if verbose:
print(
"Station",st)
42 if verbose:
print(
"Wheel",wh)
43 for sec
in range(1,nSectors+1):
44 if verbose:
print(
"Sector",sec)
46 if verbose:
print(
"Bin from histos:",binHisto)
47 histoName = path+
'Wheel%d/TTrigDifference_W%d_Sec%d' % (wh,wh,sec)
48 value = file.Get(histoName).GetBinContent(binHisto)
50 binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec
51 if verbose:
print(
"Bin final",binHistoNew,value)
52 histo.SetBinContent(binHistoNew,value)
55 label =
"Wheel %d" % wh
56 if wh == -2: label +=
" MB%d" % st
57 histo.GetXaxis().SetBinLabel(binHistoNew,label)
60 title=
"#Deltat_{Trig} (ns)",
61 ymin=ymin,ymax=ymax,option=option,draw=draw)
65 def SLcompare(fileName,sls,run,ymin=-5,ymax=5,labels=[]):
67 colors = (2,4,12,44,55,38,27,46)
68 markers = (24,25,26,27,28,30,32,5)
76 if not idx: draw =
True
78 objs =
plot(fileName,sl,run,ymin,ymax,option,draw)
79 histos.append(objs[1])
80 histos[-1].SetName(
"SL %d" % sl)
87 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
88 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
89 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
91 histos[-1].Draw(option +
"SAME")
95 legend = ROOT.TLegend(0.4,0.7,0.95,0.8)
96 for idx
in range( len(histos) ):
98 label = histo.GetName()
99 if len(labels): label = labels[idx]
100 legend.AddEntry(histo,label,
"LP")
105 legend.SetFillColor( canvas.GetFillColor() )
108 objects.append(legend)
110 return (canvas,histos,objects)
114 colors = (2,4,9,12,38,44,46,55)
115 markers = (24,25,26,27,28,30,32,5)
118 canvases = [
None,
None]
123 for fileName
in fileNames:
124 objs =
plot(fileName,sl,300,360,
'',
False)
125 histos.append( objs[1].Clone(objs[1].GetName() +
"_diff") )
126 histos[-1].SetName(
"%s_%d" % (histos[-1].GetName(),idx) )
131 histos[-1].Add(histoRef,-1.)
134 if not idx: draw =
True
137 title=
"t_{Trig} difference (ns)",
138 ymin=ymin,ymax=ymax,option=option,draw=draw)
141 canvases[0] = objs[0]
146 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
147 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
148 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
150 histos[-1].Draw(option +
"SAME")
152 histosDist.append( ROOT.TH1F(histos[-1].GetName() +
"_dist",
"tTrig distribution",200,ymin,ymax) )
153 for ibin
in range(1,histos[-1].GetNbinsX()+1):
154 histosDist[-1].
Fill( histos[-1].GetBinContent(ibin) )
156 histosDist[-1].SetLineColor(colors[ (idx - 1) % len(colors) ])
157 histosDist[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ])
158 histosDist[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ])
163 canvases[1] = ROOT.TCanvas(
"c_tTrigDist")
164 canvases[1].SetGridy()
165 canvases[1].SetFillColor(0)
169 for histo
in histosDist:
171 histo.GetXaxis().SetTitle(
"t_{Trig} difference (ns)")
172 histo.GetYaxis().SetTitle(
"Number of chambers")
175 histo.Draw(option +
"SAME")
178 return (canvases,histos,histosDist,objects)