def plotMatchedHoTime(self): c2 = TCanvas("cTimeforMatchedHoHits","Matched Ho time",1200,400) c2.Divide(3,1) ### Plot matched DT/RPC c2.cd(1).SetLogy() hBxIdBest = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport_MatchedDtRpcHo_Time') hBxIdDtOnly = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport_UnmatchedDtHo_Time') hBxIdOther = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport_OtherCodesHo_Time') hBxIdBest.Sumw2() hBxIdDtOnly.Sumw2() hBxIdOther.Sumw2() hBxIdBest.SetLineColor(colorRwthDarkBlue) hBxIdBest.SetLineWidth(3) hBxIdBest.SetStats(0) hBxIdBest.SetTitle("Matched DT/RPC + HO") hBxIdBest.GetXaxis().SetRangeUser(-50,50) #hBxIdBest.GetYaxis().SetRangeUser(2e-4,1) hBxIdBest.Scale(1/hBxIdBest.Integral()) hBxIdBest.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdBest) setBigAxisTitles(hBxIdBest) hBxIdBest.Draw() label = self.drawLabel() ### Plot unmatched DT c2.cd(2).SetLogy() hBxIdDtOnly.SetLineColor(colorRwthDarkBlue) hBxIdDtOnly.SetLineWidth(3) hBxIdDtOnly.SetStats(0) hBxIdDtOnly.SetTitle("Unmatched DT + HO") hBxIdDtOnly.GetXaxis().SetRangeUser(-50,50) #hBxIdDtOnly.GetYaxis().SetRangeUser(2e-4,1) hBxIdDtOnly.Scale(1/hBxIdDtOnly.Integral()) hBxIdDtOnly.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdDtOnly) setBigAxisTitles(hBxIdDtOnly) hBxIdDtOnly.Draw() ### Plot other codes c2.cd(3).SetLogy() hBxIdOther.SetLineColor(colorRwthDarkBlue) hBxIdOther.SetLineWidth(3) hBxIdOther.SetStats(0) hBxIdOther.SetTitle("Lower quality muon + HO") hBxIdOther.GetXaxis().SetRangeUser(-50,50) #hBxIdOther.GetYaxis().SetRangeUser(2e-4,1) hBxIdOther.Scale(1/hBxIdOther.Integral()) hBxIdOther.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdOther) setBigAxisTitles(hBxIdOther) hBxIdOther.Draw() self.storeCanvas(c2,"matchedHoTime") return label,c2,hBxIdBest,hBxIdDtOnly,hBxIdOther
def plotImprovementInTightDt(self): #Prepare canvas canvas = TCanvas("canvasTightDtImprovement","tight DT improvement",1200,1200) canvas.SetLogy() histDt = self.fileHandler.getHistogram("timingSupport_tight_UnmatchedDtHo_BxId") histDtNoHo = self.fileHandler.getHistogram("timingSupport_tight_UnmatchedDt_BxId") #Define variables for integrals histHoTime = self.fileHandler.getHistogram('timingSupport_tight_UnmatchedDtHo_Time') integralHoCorrect = histHoTime.Integral(histHoTime.FindBin(-12.5),histHoTime.FindBin(12.5)) integralHoTotal = histHoTime.Integral() integralHoOutside = integralHoTotal - integralHoCorrect hoFractionWrong = integralHoOutside/float(integralHoTotal) hoFractionRight = integralHoCorrect/float(integralHoTotal) #Print some information heading = 'Integrals of the Ho timing (tight):' print CliColors.OKBLUE print 80*'#' print heading print len(heading)*'-' print 'Timing correct:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(integralHoCorrect,hoFractionRight*100,calcSigma(integralHoCorrect, integralHoTotal)*100) print 'Timing outside:\t%d\t=>\t%6.3f%% +/- %f%%'%(integralHoOutside,hoFractionWrong*100,calcSigma(integralHoOutside, integralHoTotal)*100) print 'Timing total:%d'%(integralHoTotal) print #Define Variables for bx id counts dtBx0 = histDt.GetBinContent(6) dtBxM1 = histDt.Integral(histDt.FindBin(-10),histDt.FindBin(-1))#histDt.GetBinContent(5) dtBxP1 = histDt.Integral(histDt.FindBin(1),histDt.FindBin(10))#histDt.GetBinContent(7) dtBxTotal = dtBx0 + dtBxM1 + dtBxP1 dtFractionWrongM1 = dtBxM1/float(dtBxTotal) dtFractionWrongP1 = dtBxP1/float(dtBxTotal) noHodtBx0 = histDtNoHo.GetBinContent(6) noHodtBxM1 = histDtNoHo.Integral(histDtNoHo.FindBin(-10),histDtNoHo.FindBin(-1)) noHodtBxP1 = histDtNoHo.Integral(histDtNoHo.FindBin(1),histDtNoHo.FindBin(10)) noHodtBxTotal = noHodtBx0 + noHodtBxM1 + noHodtBxP1 noHodtFractionWrongM1 = noHodtBxM1/float(noHodtBxTotal) noHodtFractionWrongP1 = noHodtBxP1/float(noHodtBxTotal) #Print some information heading = 'Bin contents for tight DT timing:' print heading print len(heading)*'-' print 'BX ID 0:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(dtBx0,dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)*100) print 'BX ID -1:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(dtBxM1,dtFractionWrongM1*100,calcSigma(dtBxM1, dtBxTotal)*100) print 'BX ID +1:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(dtBxP1,dtFractionWrongP1*100,calcSigma(dtBxP1, dtBxTotal)*100) print 'BX ID total:\t%d\t(hist integral: %d)' % (dtBxTotal,histDt.Integral()) print print 'NO HO' print 'BX ID 0:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(noHodtBx0,noHodtBx0/float(noHodtBxTotal)*100,calcSigma(noHodtBx0, noHodtBxTotal)*100) print 'BX ID -1:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(noHodtBxM1,noHodtFractionWrongM1*100,calcSigma(noHodtBxM1, noHodtBxTotal)*100) print 'BX ID +1:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(noHodtBxP1,noHodtFractionWrongP1*100,calcSigma(noHodtBxP1, noHodtBxTotal)*100) print 'BX ID total:\t%d\t(hist integral: %d)' % (noHodtBxTotal,histDtNoHo.Integral()) print #Calculate corrected numbers correctedBxIdM1 = dtBxM1 + hoFractionWrong*dtBx0/2. - hoFractionRight*dtBxM1 correctedBxId0 = dtBx0 - hoFractionWrong*dtBx0 + hoFractionRight*dtBxM1 + hoFractionRight*dtBxP1 correctedBxIdP1 = dtBxP1 + hoFractionWrong*dtBx0/2. - hoFractionRight*dtBxP1 correctedTotal = correctedBxIdM1 + correctedBxId0 + correctedBxIdP1 correctedRightFraction = correctedBxId0/float(correctedTotal) heading = 'DT After correction:' print heading print len(heading)*'-' print 'BX -1:\t',int(correctedBxIdM1) print 'BX 0:\t',int(correctedBxId0) print 'BX +1:\t',int(correctedBxIdP1) print #Fill corrected histogram histNew = TH1D("histNewTight","BX ID in tight DT only triggers;BX ID;rel. fraction",6,-2.5,3.5) histNew.SetBinContent(histNew.FindBin(-1),correctedBxIdM1) histNew.SetBinContent(histNew.FindBin(0),correctedBxId0) histNew.SetBinContent(histNew.FindBin(1),correctedBxIdP1) histNew.SetLineColor(colorRwthMagenta) histNew.SetStats(0) histNew.Scale(1/histNew.Integral()) histNew.SetLineStyle(9) setupAxes(histNew) setBigAxisTitles(histNew) histDt.GetXaxis().SetRangeUser(-3,3) histDt.SetLineWidth(3) histDt.Scale(1/histDt.Integral()) histDt.SetLineColor(colorRwthDarkBlue) histNew.Draw() histDt.Draw('same') histNew.Draw('same') histDtNoHo.Scale(1/histDtNoHo.Integral()) histDtNoHo.SetLineWidth(3) #histDtNoHo.Draw('same') #Add label label = self.drawLabel() #Add legend legend = TLegend(0.7,0.65,0.9,0.8) legend.AddEntry(histDt,"tight DT Only + HO","l") legend.AddEntry(histNew,"tight DT shifted with HO","l") legend.SetBorderSize(1) legend.Draw() #Add text object pText = TPaveText(0.52,0.8,0.9,0.9,'NDC') pText.AddText('Fraction in tight BX ID 0: %5.2f%% #pm %5.2f%%' % (dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)*100)) pText.AddText('Fraction in tight BX ID 0 (HO corr.): %5.2f%% #pm %5.2f%%' % (correctedRightFraction*100,calcSigma(correctedBxId0, correctedTotal)*100)) pText.SetBorderSize(1) pText.SetFillColor(0) pText.Draw() pText2 = TPaveText(0.7,0.6,0.9,0.65,'NDC') pText2.AddText('Entries: %d' % (histDt.GetEntries())) pText2.SetBorderSize(1) pText2.SetFillColor(0) pText2.Draw() #Print again some information heading = 'Fraction of correct BXID (tight):' print heading print len(heading)*'-' print 'Uncorrected:\t%5.2f%% #pm %f%%' % (dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)*100) print 'Corrected\t%5.2f%% #pm %f%%' % (correctedRightFraction*100,calcSigma(correctedBxId0, correctedTotal)*100) print 80*'#' print CliColors.ENDC setupAxes(histNew) canvas.Update() self.storeCanvas(canvas, 'correctedTightDt') return canvas, histDt,histNew,label,legend,pText2,pText,histDtNoHo
def plotMatchedHoTime(self): c2 = TCanvas("cTimeforMatchedHoHits","Matched Ho time",1200,400) c2.Divide(3,1) ### Plot matched DT/RPC c2.cd(1).SetLogy() hBxIdBest = self.fileHandler.getHistogram('timingSupport_MatchedDtRpcHo_Time') hBxIdDtOnly = self.fileHandler.getHistogram('timingSupport_UnmatchedDtHo_Time') hBxIdDtOnlyTight = self.fileHandler.getHistogram('timingSupport_tight_UnmatchedDtHo_Time') hBxIdOther = self.fileHandler.getHistogram('timingSupport_OtherCodesHo_Time') hIntegral = hBxIdDtOnly.Integral() hIntegralCentral = hBxIdDtOnly.Integral( hBxIdDtOnly.FindBin(-12.5), hBxIdDtOnly.FindBin(12.5)) hIntegralTight = hBxIdDtOnlyTight.Integral() hIntegralTighCentral = hBxIdDtOnlyTight.Integral( hBxIdDtOnlyTight.FindBin(-12.5), hBxIdDtOnlyTight.FindBin(12.5)) # hBxIdBest.Sumw2() # hBxIdDtOnly.Sumw2() # hBxIdOther.Sumw2() hBxIdBest.SetLineColor(colorRwthDarkBlue) hBxIdBest.SetLineWidth(3) hBxIdBest.SetStats(0) hBxIdBest.SetTitle("Matched DT/RPC + HO") hBxIdBest.GetXaxis().SetRangeUser(-50,50) #hBxIdBest.GetYaxis().SetRangeUser(2e-4,1) hBxIdBest.Scale(1/hBxIdBest.Integral()) hBxIdBest.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdBest) setBigAxisTitles(hBxIdBest) hBxIdBest.Draw() label = self.drawLabel() ### Plot unmatched DT c2.cd(2).SetLogy() hBxIdDtOnly.SetLineColor(colorRwthDarkBlue) hBxIdDtOnly.SetLineWidth(3) hBxIdDtOnly.SetStats(0) hBxIdDtOnly.SetTitle("Unmatched DT + HO") hBxIdDtOnly.GetXaxis().SetRangeUser(-50,50) #hBxIdDtOnly.GetYaxis().SetRangeUser(2e-4,1) hBxIdDtOnly.Scale(1/hBxIdDtOnly.Integral()) hBxIdDtOnly.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdDtOnly) setBigAxisTitles(hBxIdDtOnly) hBxIdDtOnly.Draw() ### Plot other codes c2.cd(3).SetLogy() hBxIdOther.SetLineColor(colorRwthDarkBlue) hBxIdOther.SetLineWidth(3) hBxIdOther.SetStats(0) hBxIdOther.SetTitle("Lower quality muon + HO") hBxIdOther.GetXaxis().SetRangeUser(-50,50) #hBxIdOther.GetYaxis().SetRangeUser(2e-4,1) hBxIdOther.Scale(1/hBxIdOther.Integral()) hBxIdOther.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdOther) setBigAxisTitles(hBxIdOther) hBxIdOther.Draw() self.storeCanvas(c2,"matchedHoTime") c = TCanvas('cDtOnlyWithTight',"DT only with tight",600,600) c.SetLogy() hBxIdDtOnlyCopy = hBxIdDtOnly.DrawCopy() hBxIdDtOnlyTight.Scale(1/hBxIdDtOnlyTight.Integral()) hBxIdDtOnlyTight.SetLineColor(colorRwthMagenta) hBxIdDtOnlyTight.Draw('same') legend = getLegend(y1=0.75,y2=.9) legend.AddEntry(hBxIdDtOnlyCopy,'DT only','l') legend.AddEntry(hBxIdDtOnlyTight,'DT only, tight','l') legend.Draw() self.debug(80*'#') self.debug('Not tight: Integral in [-12.5,12.5]:\t %8d => %5.2f%% +/- %5.2f%%' % (hIntegral, hIntegralCentral/float(hIntegral)*100,calcSigma(hIntegralCentral, hIntegral)*100)) self.debug('Tight: Integral in [-12.5,12.5]:\t\t %8d => %5.2f%% +/- %5.2f%%' % (hIntegralTight, hIntegralTighCentral/float(hIntegralTight)*100,calcSigma(hIntegralTighCentral, hIntegralTight)*100)) self.debug(80*'#') self.storeCanvas(c, 'matchedHoDtOnlyWithTight') return label,c2,hBxIdBest,hBxIdDtOnly,hBxIdOther,hBxIdDtOnlyTight,hBxIdDtOnlyCopy,c,legend
def plotL1BxId(self,tight = False): TIGHT_TOKEN = '_tight' if tight else '' c2 = TCanvas("cBxId" + TIGHT_TOKEN,"BX ID" + TIGHT_TOKEN,1200,400) c2.Divide(3,1) hBxIdBest = self.fileHandler.getHistogram('timingSupport%s_MatchedDtRpcHo_BxId' % TIGHT_TOKEN) hBxIdDtOnly = self.fileHandler.getHistogram('timingSupport%s_UnmatchedDtHo_BxId' % TIGHT_TOKEN) hBxIdOther = self.fileHandler.getHistogram('timingSupport%s_OtherCodesHo_BxId' % TIGHT_TOKEN) if not hBxIdBest or not hBxIdDtOnly or not hBxIdOther: return dtBx0BestCentral = hBxIdBest.GetBinContent(hBxIdBest.FindBin(0)) dtBx0BestIntegral = hBxIdBest.Integral() dtBx0BestOther = dtBx0BestIntegral - dtBx0BestCentral dtBx0DtOnlyCentral = hBxIdDtOnly.GetBinContent(hBxIdDtOnly.FindBin(0)) dtBx0DtOnlyIntegral = hBxIdDtOnly.Integral() dtBx0DtOnlyOther = dtBx0DtOnlyIntegral - dtBx0DtOnlyCentral dtBx0OtherCentral = hBxIdOther.GetBinContent(hBxIdOther.FindBin(0)) dtBx0OtherIntegral = hBxIdOther.Integral() dtBx0OtherOther = dtBx0OtherIntegral - dtBx0OtherCentral self.debug('#'*20) self.debug('!TIGHT!' if tight else '') self.debug('DT/RPC') self.debug('-'*10) self.debug('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0BestCentral,dtBx0BestCentral/float(dtBx0BestIntegral)*100,calcSigma(dtBx0BestCentral, dtBx0BestIntegral)*100)) self.debug('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0BestOther,dtBx0BestOther/float(dtBx0BestIntegral)*100,calcSigma(dtBx0BestOther, dtBx0BestIntegral)*100)) self.debug('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0BestCentral + dtBx0BestOther,dtBx0BestIntegral)) self.debug('') self.debug('DT') self.debug('-'*10) self.debug('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0DtOnlyCentral,dtBx0DtOnlyCentral/float(dtBx0DtOnlyIntegral)*100,calcSigma(dtBx0DtOnlyCentral, dtBx0DtOnlyIntegral)*100)) self.debug('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0DtOnlyOther,dtBx0DtOnlyOther/float(dtBx0DtOnlyIntegral)*100,calcSigma(dtBx0DtOnlyOther, dtBx0DtOnlyIntegral)*100)) self.debug('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0DtOnlyCentral + dtBx0DtOnlyOther,dtBx0DtOnlyIntegral)) self.debug('') self.debug('Other') self.debug('-'*10) self.debug('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0OtherCentral,dtBx0OtherCentral/float(dtBx0OtherIntegral)*100,calcSigma(dtBx0OtherCentral, dtBx0OtherIntegral)*100)) self.debug('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0OtherOther,dtBx0OtherOther/float(dtBx0OtherIntegral)*100,calcSigma(dtBx0OtherOther, dtBx0OtherIntegral)*100)) self.debug('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0OtherCentral + dtBx0OtherOther,dtBx0OtherIntegral)) self.debug('') self.debug('#'*20) ### Plot matched DT/RPC c2.cd(1).SetLogy() hBxIdBest.SetLineColor(colorRwthDarkBlue) hBxIdBest.SetLineWidth(3) hBxIdBest.SetStats(0) hBxIdBest.SetTitle("Matched DT/RPC + HO") hBxIdBest.GetXaxis().SetRangeUser(-5,5) hBxIdBest.GetYaxis().SetRangeUser(2e-4,1) hBxIdBest.Scale(1/hBxIdBest.Integral()) hBxIdBest.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdBest) setBigAxisTitles(hBxIdBest) hBxIdBest.Draw() label = self.drawLabel() ### Plot unmatched DT c2.cd(2).SetLogy() hBxIdDtOnly.SetLineColor(colorRwthDarkBlue) hBxIdDtOnly.SetLineWidth(3) hBxIdDtOnly.SetStats(0) hBxIdDtOnly.SetTitle("Unmatched DT + HO") hBxIdDtOnly.GetXaxis().SetRangeUser(-5,5) hBxIdDtOnly.GetYaxis().SetRangeUser(2e-4,1) hBxIdDtOnly.Scale(1/hBxIdDtOnly.Integral()) hBxIdDtOnly.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdDtOnly) setBigAxisTitles(hBxIdDtOnly) hBxIdDtOnly.Draw() ### Plot other codes c2.cd(3).SetLogy() hBxIdOther.SetLineColor(colorRwthDarkBlue) hBxIdOther.SetLineWidth(3) hBxIdOther.SetStats(0) hBxIdOther.SetTitle("Lower quality muon + HO") hBxIdOther.GetXaxis().SetRangeUser(-5,5) hBxIdOther.GetYaxis().SetRangeUser(2e-4,1) hBxIdOther.Scale(1/hBxIdOther.Integral()) hBxIdOther.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdOther) setBigAxisTitles(hBxIdOther) hBxIdOther.Draw() self.storeCanvas(c2,"bxId" + TIGHT_TOKEN) return label,c2,hBxIdBest,hBxIdDtOnly,hBxIdOther
def plotMatchedHoTime(self): c2 = TCanvas("cTimeforMatchedHoHits","Matched Ho time",1200,400) c2.Divide(3,1) c2.cd(1).SetLeftMargin(.12) c2.cd(2).SetLeftMargin(.12) c2.cd(3).SetLeftMargin(.12) ### Plot matched DT/RPC c2.cd(1).SetLogy() hBxIdBest = self.fileHandler.getHistogram('timingSupport_MatchedDtRpcHo_Time') hBxIdDtOnly = self.fileHandler.getHistogram('timingSupport_UnmatchedDtHo_Time') hBxIdDtOnlyTight = self.fileHandler.getHistogram('timingSupport_tight_UnmatchedDtHo_Time') hBxIdOther = self.fileHandler.getHistogram('timingSupport_OtherCodesHo_Time') hIntegral = hBxIdDtOnly.Integral() hIntegralCentral = hBxIdDtOnly.Integral( hBxIdDtOnly.FindBin(-12.5), hBxIdDtOnly.FindBin(12.5)) hIntegralTight = hBxIdDtOnlyTight.Integral() hIntegralTighCentral = hBxIdDtOnlyTight.Integral( hBxIdDtOnlyTight.FindBin(-12.5), hBxIdDtOnlyTight.FindBin(12.5)) # hBxIdBest.Sumw2() # hBxIdDtOnly.Sumw2() # hBxIdOther.Sumw2() hBxIdBest.SetLineColor(colorRwthDarkBlue) hBxIdBest.SetLineWidth(3) hBxIdBest.SetStats(0) hBxIdBest.SetTitle("Matched DT/RPC + HO") hBxIdBest.GetXaxis().SetRangeUser(-50,50) #hBxIdBest.GetYaxis().SetRangeUser(2e-4,1) hBxIdBest.Scale(1/hBxIdBest.Integral()) hBxIdBest.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdBest) setBigAxisTitles(hBxIdBest) hBxIdBest.Draw() ### Plot unmatched DT c2.cd(2).SetLogy() hBxIdDtOnly.SetLineColor(colorRwthDarkBlue) hBxIdDtOnly.SetLineWidth(3) hBxIdDtOnly.SetStats(0) hBxIdDtOnly.SetTitle("Unmatched DT + HO") hBxIdDtOnly.GetXaxis().SetRangeUser(-50,50) #hBxIdDtOnly.GetYaxis().SetRangeUser(2e-4,1) hBxIdDtOnly.Scale(1/hBxIdDtOnly.Integral()) hBxIdDtOnly.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdDtOnly) setBigAxisTitles(hBxIdDtOnly) hBxIdDtOnly.Draw() ### Plot other codes c2.cd(3).SetLogy() hBxIdOther.SetLineColor(colorRwthDarkBlue) hBxIdOther.SetLineWidth(3) hBxIdOther.SetStats(0) hBxIdOther.SetTitle("Lower quality muon + HO") hBxIdOther.GetXaxis().SetRangeUser(-50,50) #hBxIdOther.GetYaxis().SetRangeUser(2e-4,1) hBxIdOther.Scale(1/hBxIdOther.Integral()) hBxIdOther.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdOther) setBigAxisTitles(hBxIdOther) hBxIdOther.Draw() hBxIdBest.GetYaxis().SetTitleOffset(1) hBxIdDtOnly.GetYaxis().SetTitleOffset(1) hBxIdOther.GetYaxis().SetTitleOffset(1) self.storeCanvas(c2,"matchedHoTime") c = TCanvas('cDtOnlyWithTight',"DT only with tight",600,600) c.SetLogy() hBxIdDtOnlyCopy = hBxIdDtOnly.DrawCopy() hBxIdDtOnlyTight.Scale(1/hBxIdDtOnlyTight.Integral()) hBxIdDtOnlyTight.SetLineColor(colorRwthMagenta) hBxIdDtOnlyTight.Draw('same') legend = getLegend(y1=0.75,y2=.9) legend.AddEntry(hBxIdDtOnlyCopy,'DT only','l') legend.AddEntry(hBxIdDtOnlyTight,'DT only, tight','l') legend.Draw() self.debug(80*'#') self.debug('Not tight: Integral in [-12.5,12.5]:\t %8d => %5.2f%% +/- %5.2f%%' % (hIntegral, hIntegralCentral/float(hIntegral)*100,calcSigma(hIntegralCentral, hIntegral)*100)) self.debug('Tight: Integral in [-12.5,12.5]:\t\t %8d => %5.2f%% +/- %5.2f%%' % (hIntegralTight, hIntegralTighCentral/float(hIntegralTight)*100,calcSigma(hIntegralTighCentral, hIntegralTight)*100)) self.debug(80*'#') self.storeCanvas(c, 'matchedHoDtOnlyWithTight') return c2,hBxIdBest,hBxIdDtOnly,hBxIdOther,hBxIdDtOnlyTight,hBxIdDtOnlyCopy,c,legend
def plotL1BxId(self,tight = False): TIGHT_TOKEN = '_tight' if tight else '' c2 = TCanvas("cBxId" + TIGHT_TOKEN,"BX ID" + TIGHT_TOKEN,1200,400) c2.Divide(3,1) c2.cd(1).SetLeftMargin(.12) c2.cd(2).SetLeftMargin(.12) c2.cd(3).SetLeftMargin(.12) hBxIdBest = self.fileHandler.getHistogram('timingSupport%s_MatchedDtRpcHo_BxId' % TIGHT_TOKEN) hBxIdDtOnly = self.fileHandler.getHistogram('timingSupport%s_UnmatchedDtHo_BxId' % TIGHT_TOKEN) hBxIdOther = self.fileHandler.getHistogram('timingSupport%s_OtherCodesHo_BxId' % TIGHT_TOKEN) if not hBxIdBest or not hBxIdDtOnly or not hBxIdOther: return dtBx0BestCentral = hBxIdBest.GetBinContent(hBxIdBest.FindBin(0)) dtBx0BestIntegral = hBxIdBest.Integral() dtBx0BestOther = dtBx0BestIntegral - dtBx0BestCentral dtBx0DtOnlyCentral = hBxIdDtOnly.GetBinContent(hBxIdDtOnly.FindBin(0)) dtBx0DtOnlyIntegral = hBxIdDtOnly.Integral() dtBx0DtOnlyOther = dtBx0DtOnlyIntegral - dtBx0DtOnlyCentral dtBx0OtherCentral = hBxIdOther.GetBinContent(hBxIdOther.FindBin(0)) dtBx0OtherIntegral = hBxIdOther.Integral() dtBx0OtherOther = dtBx0OtherIntegral - dtBx0OtherCentral self.debug('#'*20) self.debug('!TIGHT!' if tight else '') self.debug('DT/RPC') self.debug('-'*10) self.debug('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0BestCentral,dtBx0BestCentral/float(dtBx0BestIntegral)*100,calcSigma(dtBx0BestCentral, dtBx0BestIntegral)*100)) self.debug('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0BestOther,dtBx0BestOther/float(dtBx0BestIntegral)*100,calcSigma(dtBx0BestOther, dtBx0BestIntegral)*100)) self.debug('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0BestCentral + dtBx0BestOther,dtBx0BestIntegral)) self.debug('') self.debug('DT') self.debug('-'*10) self.debug('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0DtOnlyCentral,dtBx0DtOnlyCentral/float(dtBx0DtOnlyIntegral)*100,calcSigma(dtBx0DtOnlyCentral, dtBx0DtOnlyIntegral)*100)) self.debug('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0DtOnlyOther,dtBx0DtOnlyOther/float(dtBx0DtOnlyIntegral)*100,calcSigma(dtBx0DtOnlyOther, dtBx0DtOnlyIntegral)*100)) self.debug('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0DtOnlyCentral + dtBx0DtOnlyOther,dtBx0DtOnlyIntegral)) self.debug('') self.debug('Other') self.debug('-'*10) self.debug('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0OtherCentral,dtBx0OtherCentral/float(dtBx0OtherIntegral)*100,calcSigma(dtBx0OtherCentral, dtBx0OtherIntegral)*100)) self.debug('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0OtherOther,dtBx0OtherOther/float(dtBx0OtherIntegral)*100,calcSigma(dtBx0OtherOther, dtBx0OtherIntegral)*100)) self.debug('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0OtherCentral + dtBx0OtherOther,dtBx0OtherIntegral)) self.debug('') self.debug('#'*20) ### Plot matched DT/RPC c2.cd(1).SetLogy() hBxIdBest.SetLineColor(colorRwthDarkBlue) hBxIdBest.SetLineWidth(3) hBxIdBest.SetStats(0) hBxIdBest.SetTitle("Matched DT/RPC + HO") hBxIdBest.GetXaxis().SetRangeUser(-5,5) hBxIdBest.GetYaxis().SetRangeUser(2e-4,1) hBxIdBest.Scale(1/hBxIdBest.Integral()) hBxIdBest.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdBest) setBigAxisTitles(hBxIdBest) hBxIdBest.Draw() ### Plot unmatched DT c2.cd(2).SetLogy() hBxIdDtOnly.SetLineColor(colorRwthDarkBlue) hBxIdDtOnly.SetLineWidth(3) hBxIdDtOnly.SetStats(0) hBxIdDtOnly.SetTitle("Unmatched DT + HO") hBxIdDtOnly.GetXaxis().SetRangeUser(-5,5) hBxIdDtOnly.GetYaxis().SetRangeUser(2e-4,1) hBxIdDtOnly.Scale(1/hBxIdDtOnly.Integral()) hBxIdDtOnly.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdDtOnly) setBigAxisTitles(hBxIdDtOnly) hBxIdDtOnly.Draw() ### Plot other codes c2.cd(3).SetLogy() hBxIdOther.SetLineColor(colorRwthDarkBlue) hBxIdOther.SetLineWidth(3) hBxIdOther.SetStats(0) hBxIdOther.SetTitle("Lower quality muon + HO") hBxIdOther.GetXaxis().SetRangeUser(-5,5) hBxIdOther.GetYaxis().SetRangeUser(2e-4,1) hBxIdOther.Scale(1/hBxIdOther.Integral()) hBxIdOther.GetYaxis().SetTitle("rel. fraction") setupAxes(hBxIdOther) setBigAxisTitles(hBxIdOther) hBxIdOther.Draw() hBxIdBest.GetYaxis().SetTitleOffset(1) hBxIdDtOnly.GetYaxis().SetTitleOffset(1) hBxIdOther.GetYaxis().SetTitleOffset(1) self.storeCanvas(c2,"bxId" + TIGHT_TOKEN, drawLabel = False) return c2,hBxIdBest,hBxIdDtOnly,hBxIdOther