Functions | |
def | binNumber |
def | compare |
def | compareDiff |
def | plot |
def plotTTrigFromHistos::binNumber | ( | station, | |
sector | |||
) |
Definition at line 4 of file plotTTrigFromHistos.py.
Referenced by FourVectorHLTOnline::analyze(), HLTMonBitSummary::analyze(), FourVectorHLTOffline::analyze(), DTnoiseDBValidation::beginRun(), DTnoiseDBValidation::bookHisto(), FourVectorHLTOnline::countHLTGroupBXHitsEndLumiBlock(), FourVectorHLTOffline::countHLTGroupBXHitsEndLumiBlock(), TrigResRateMon::countHLTGroupBXHitsEndLumiBlock(), and TrigResRateMon::DatasetInfo::fillRawCountsForPath().
def plotTTrigFromHistos::compare | ( | fileNames, | |
sl, | |||
ymin = 300 , |
|||
ymax = 360 , |
|||
labels = [] |
|||
) |
Definition at line 60 of file plotTTrigFromHistos.py.
00061 : 00062 option = "HISTOP" 00063 colors = (2,4,12,44,55,38,27,46) 00064 markers = (24,25,26,27,28,30,32,5) 00065 00066 idx = 0 00067 canvas = None 00068 objects = None 00069 histos = [] 00070 for fileName in fileNames: 00071 draw = False 00072 if not idx: draw = True 00073 00074 objs = plot(fileName,sl,ymin,ymax,option,draw) 00075 histos.append(objs[1]) 00076 histos[-1].SetName( "%s_%d" % (histos[-1].GetName(),idx) ) 00077 if not idx: 00078 canvas = objs[0] 00079 objects = objs[2] 00080 00081 canvas.cd() 00082 if idx: 00083 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ]) 00084 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ]) 00085 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ]) 00086 00087 histos[-1].Draw(option + "SAME") 00088 00089 idx += 1 00090 00091 legend = ROOT.TLegend(0.4,0.7,0.95,0.8) 00092 for idx in range( len(histos) ): 00093 histo = histos[idx] 00094 label = histo.GetName() 00095 if len(labels): label = labels[idx] 00096 legend.AddEntry(histo,label,"LP") 00097 00098 idx += 1 00099 00100 canvas.cd() 00101 legend.SetFillColor( canvas.GetFillColor() ) 00102 legend.Draw("SAME") 00103 00104 objects.append(legend) 00105 00106 return (canvas,histos,objects)
def plotTTrigFromHistos::compareDiff | ( | fileNames, | |
sl, | |||
ymin = -15. , |
|||
ymax = 15. |
|||
) |
Definition at line 107 of file plotTTrigFromHistos.py.
00108 : 00109 option = "HISTOP" 00110 colors = (2,4,9,12,38,44,46,55) 00111 markers = (24,25,26,27,28,30,32,5) 00112 00113 idx = 0 00114 canvases = [None,None] 00115 objects = None 00116 histoRef = None 00117 histos = [] 00118 histosDist = [] 00119 for fileName in fileNames: 00120 objs = plot(fileName,sl,300,360,'',False) 00121 histos.append( objs[1].Clone(objs[1].GetName() + "_diff") ) 00122 histos[-1].SetName( "%s_%d" % (histos[-1].GetName(),idx) ) 00123 if not idx: 00124 histoRef = objs[1] 00125 histos[-1].Reset() 00126 else: 00127 histos[-1].Add(histoRef,-1.) 00128 00129 draw = False 00130 if not idx: draw = True 00131 00132 objs = drawHisto(histos[-1], 00133 title="t_{Trig} difference (ns)", 00134 ymin=ymin,ymax=ymax,option=option,draw=draw) 00135 00136 if not idx: 00137 canvases[0] = objs[0] 00138 objects = objs[2] 00139 00140 if idx: 00141 canvases[0].cd() 00142 histos[-1].SetLineColor(colors[ (idx - 1) % len(colors) ]) 00143 histos[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ]) 00144 histos[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ]) 00145 00146 histos[-1].Draw(option + "SAME") 00147 00148 histosDist.append( ROOT.TH1F(histos[-1].GetName() + "_dist","tTrig distribution",200,ymin,ymax) ) 00149 for ibin in range(1,histos[-1].GetNbinsX()+1): 00150 histosDist[-1].Fill( histos[-1].GetBinContent(ibin) ) 00151 00152 histosDist[-1].SetLineColor(colors[ (idx - 1) % len(colors) ]) 00153 histosDist[-1].SetMarkerColor(colors[ (idx - 1) % len(colors) ]) 00154 histosDist[-1].SetMarkerStyle(markers[ (idx - 1) % len(markers) ]) 00155 00156 idx += 1 00157 00158 00159 canvases[1] = ROOT.TCanvas("c_tTrigDist") 00160 canvases[1].SetGridy() 00161 canvases[1].SetFillColor(0) 00162 canvases[1].cd() 00163 option = "HISTO" 00164 idx = 0 00165 for histo in histosDist: 00166 if not idx: 00167 histo.GetXaxis().SetTitle("t_{Trig} difference (ns)") 00168 histo.GetYaxis().SetTitle("Number of chambers") 00169 histo.Draw(option) 00170 else: 00171 histo.Draw(option + "SAME") 00172 idx += 1 00173 00174 return (canvases,histos,histosDist,objects)
def plotTTrigFromHistos::plot | ( | fileName, | |
sl, | |||
ymin = 300 , |
|||
ymax = 360 , |
|||
option = "HISTOP" , |
|||
draw = True |
|||
) |
Definition at line 8 of file plotTTrigFromHistos.py.
00009 : 00010 00011 slType = sl 00012 slStr = "SL%d" % slType 00013 verbose = False 00014 00015 ROOT.TH1.AddDirectory(False) 00016 00017 file = ROOT.TFile(fileName,'read') 00018 00019 wheels = (-2,-1,0,1,2) 00020 stations = (1,2,3,4) 00021 00022 histosWheel = {} 00023 for wh in wheels: 00024 histoName = 'Wheel%d_%s_TTrig' % (wh,slStr) 00025 print "Accessing",histoName 00026 histosWheel[wh] = file.Get(histoName) 00027 00028 # (Wh-2 MB1 Sec1 ... Wh-2 MB1 Sec12 ... Wh-1 MB1 Sec1 ... Wh-1 MB1 Sec12 ...) 00029 # (Wh-2 MB2 Sec1 ... Wh-2 MB2 Sec12 ... Wh-1 MB2 Sec1 ... Wh-1 MB1 Sec12 ...) ... 00030 nBins = 250 00031 if slType == 2: nBins = 180 00032 histo = ROOT.TH1F("h_TTrigAll","TTrig",nBins,0,nBins) 00033 for st in stations: 00034 nSectors = 12 00035 if st == 4: nSectors = 14 00036 if st == 4 and slType == 2: continue 00037 if verbose: print "Station",st 00038 for wh in wheels: 00039 if verbose: print "Wheel",wh 00040 for sec in range(1,nSectors+1): 00041 if verbose: print "Sector",sec 00042 binHisto = binNumber(st,sec) 00043 if verbose: print "Bin from histos:",binHisto 00044 value = histosWheel[wh].GetBinContent(binHisto) 00045 00046 binHistoNew = (st - 1)*60 + (wh + 2)*nSectors + sec 00047 if verbose: print "Bin final",binHistoNew 00048 histo.SetBinContent(binHistoNew,value) 00049 00050 if sec == 1: 00051 label = "Wheel %d" % wh 00052 if wh == -2: label += " MB%d" % st 00053 histo.GetXaxis().SetBinLabel(binHistoNew,label) 00054 00055 objects = drawHisto(histo, 00056 title="t_{Trig} (ns)", 00057 ymin=ymin,ymax=ymax,option=option,draw=draw) 00058 00059 return objects