def plotHoTime(self): c3 = TCanvas("c3","HO Time",1200,1200) skipNoisePlot = False if not skipNoisePlot: c3.Divide(1,2) c3.cd(1).SetLogy() label = getLabelCmsPrivateSimulation() label.Draw() hHoTime = self.fileHandler.getHistogram('hoRecHits_Time') hHoTime.SetStats(0) hHoTime.SetTitle("Time distribution for all HO Rec Hits") hHoTime.SetLineColor(colorRwthDarkBlue) hHoTime.SetLineWidth(3) hHoTime.Draw() label = getLabelCmsPrivateSimulation() label.Draw() hHoTimeAboveThr = self.fileHandler.getHistogram('hoRecHitsAboveThr_Time') c3.cd(2).SetLogy() hHoTimeAboveThr.SetStats(0) hHoTimeAboveThr.SetTitle("Time distribution for HO Rec Hits > 0.2 GeV") hHoTimeAboveThr.SetLineColor(colorRwthDarkBlue) hHoTimeAboveThr.SetLineWidth(3) setupAxes(hHoTimeAboveThr) hHoTimeAboveThr.Draw() label = getLabelCmsPrivateSimulation() label.Draw() self.debug(80*'#') self.debug( 'Integral of HO > 0.2 GeV time histogram:') self.debug( hHoTimeAboveThr.Integral()) self.debug('') xLow = -5 xHigh = 5 histogramBetween = hHoTimeAboveThr.Integral(hHoTimeAboveThr.FindBin(xLow),hHoTimeAboveThr.FindBin(xHigh)) histogramTotal = float(hHoTimeAboveThr.Integral()) self.debug( 'Histogram integral between %.f ns and %.f ns' % (xLow,xHigh) ) self.debug( '%d/%d => %.2f +/- %f' % (histogramBetween,histogramTotal ,histogramBetween/histogramTotal,calcSigma(histogramBetween, histogramTotal))) self.debug( 80*'#') fit = TF1("fit","gaus",-10,10) hHoTimeAboveThr.Fit(fit) pText = TPaveText(0.7,0.8,0.9,0.9,'NDC') pText.AddText('Mean: %.2f ns' % (fit.GetParameter(1))) pText.AddText('#sigma: %.2f ns' % (fit.GetParameter(2))) pText.SetBorderSize(1) pText.SetFillColor(0) pText.Draw() c3.Update() self.storeCanvas(c3,"hoTime") return c3,label,hHoTimeAboveThr,pText
def plotHoTimeLog(self): c3 = TCanvas("c3Log","HO Time Log",1200,1200) skipNoisePlot = True if not skipNoisePlot: c3.Divide(1,2) c3.cd(1).SetLogy() label = getLabelCmsPrivateSimulation() label.Draw() hHoTime = self.fileHandler.getHistogram('hoRecHits_Time') hHoTime.SetStats(0) hHoTime.SetTitle() hHoTime.SetLineColor(colorRwthDarkBlue) hHoTime.SetLineWidth(3) hHoTime.Draw() label = getLabelCmsPrivateSimulation() label.Draw() hHoTimeAboveThr = self.fileHandler.getHistogram('hoRecHitsAboveThr_Time') c3.cd(2).SetLogy() hHoTimeAboveThr.SetStats(0) hHoTimeAboveThr.SetTitle('') hHoTimeAboveThr.SetLineColor(colorRwthDarkBlue) hHoTimeAboveThr.SetLineWidth(3) hHoTimeAboveThr.GetXaxis().SetRangeUser(-50,50) setupAxes(hHoTimeAboveThr) hHoTimeAboveThr.Draw() fit = TF1("fit","gaus",-10,10) fit.SetParameter(1,0) fit.SetParameter(2,1) fit.SetLineWidth(3) hHoTimeAboveThr.Fit(fit,'','R',-12.5,7) self.debug(80*'#') self.debug('Chi^2: %5.2f' % fit.GetChisquare()) self.debug('NDF: %d' % fit.GetNDF()) self.debug(80*'#') legend = getLegend(x1=.1, y1=.85, x2=.415, y2=.95) legend.AddEntry(hHoTimeAboveThr,'HO (E_{Rec} > 0.2 GeV)','l') legend.AddEntry(fit,'Fit','l') legend.Draw() pText = TPaveText(0.78,0.85,0.97,0.95,'NDC') pText.AddText('Mean: %.2f ns' % (fit.GetParameter(1))) pText.AddText('#sigma: %.2f ns' % (fit.GetParameter(2))) pText.SetBorderSize(1) pText.SetFillColor(0) pText.Draw() c3.Update() self.storeCanvas(c3,"hoTimeLog",marginRight=.03) return c3,pText,hHoTimeAboveThr,legend
def plotHoTimeLog(self): c3 = TCanvas("c3Log","HO Time Log",1200,1200) skipNoisePlot = True if not skipNoisePlot: c3.Divide(1,2) c3.cd(1).SetLogy() label = getLabelCmsPrivateSimulation() label.Draw() hHoTime = self.fileHandler.getHistogram('hoRecHits_Time') hHoTime.SetStats(0) hHoTime.SetTitle("Time distribution for all HO Rec Hits") hHoTime.SetLineColor(colorRwthDarkBlue) hHoTime.SetLineWidth(3) hHoTime.Draw() label = getLabelCmsPrivateSimulation() label.Draw() hHoTimeAboveThr = self.fileHandler.getHistogram('hoRecHitsAboveThr_Time') c3.cd(2).SetLogy() hHoTimeAboveThr.SetStats(0) hHoTimeAboveThr.SetTitle("Time distribution for HO Rec Hits > 0.2 GeV") hHoTimeAboveThr.SetLineColor(colorRwthDarkBlue) hHoTimeAboveThr.SetLineWidth(3) setupAxes(hHoTimeAboveThr) hHoTimeAboveThr.Draw() label = getLabelCmsPrivateSimulation() label.Draw() fit = TF1("fit","gaus",-10,10) fit.SetParameter(1,0) fit.SetParameter(2,1) hHoTimeAboveThr.Fit(fit,'','R',-12.5,12.5) self.debug(80*'#') self.debug('Chi^2: %5.2f' % fit.GetChisquare()) self.debug('NDF: %d' % fit.GetNDF()) self.debug(80*'#') pText = TPaveText(0.7,0.8,0.9,0.9,'NDC') pText.AddText('Mean: %.2f ns' % (fit.GetParameter(1))) pText.AddText('#sigma: %.2f ns' % (fit.GetParameter(2))) pText.SetBorderSize(1) pText.SetFillColor(0) pText.Draw() c3.Update() self.storeCanvas(c3,"hoTimeLog") return c3,pText,hHoTimeAboveThr
def plotHoTimeLog(self): c3 = TCanvas("c3Log","HO Time Log",1200,1200) skipNoisePlot = True if not skipNoisePlot: c3.Divide(1,2) c3.cd(1).SetLogy() label = getLabelCmsPrivateSimulation() label.Draw() hHoTime = self.fileHandler.getHistogram('hoMuonAnalyzer/hoRecHits_Time') hHoTime.SetStats(0) hHoTime.SetTitle("Time distribution for all HO Rec Hits") hHoTime.SetLineColor(colorRwthDarkBlue) hHoTime.SetLineWidth(3) hHoTime.Draw() label = getLabelCmsPrivateSimulation() label.Draw() hHoTimeAboveThr = self.fileHandler.getHistogram('hoMuonAnalyzer/hoRecHitsAboveThr_Time') c3.cd(2).SetLogy() hHoTimeAboveThr.SetStats(0) hHoTimeAboveThr.SetTitle("Time distribution for HO Rec Hits > 0.2 GeV") hHoTimeAboveThr.SetLineColor(colorRwthDarkBlue) hHoTimeAboveThr.SetLineWidth(3) setupAxes(hHoTimeAboveThr) hHoTimeAboveThr.Draw() label = getLabelCmsPrivateSimulation() label.Draw() fit = TF1("fit","gaus",-10,10) fit.SetParameter(1,0) fit.SetParameter(2,1) hHoTimeAboveThr.Fit(fit,'','R',-12.5,12.5) self.output(80*'#') self.output('Chi^2: %5.2f' % fit.GetChisquare()) self.output('NDF: %d' % fit.GetNDF()) self.output(80*'#') pText = TPaveText(0.7,0.8,0.9,0.9,'NDC') pText.AddText('Mean: %.2f ns' % (fit.GetParameter(1))) pText.AddText('#sigma: %.2f ns' % (fit.GetParameter(2))) pText.SetBorderSize(1) pText.SetFillColor(0) pText.Draw() c3.Update() self.storeCanvas(c3,"hoTimeLog") return c3,pText,hHoTimeAboveThr
def plotFractionInTimeWindow(): c = TCanvas("cFraction","Fraction in Time Window",900,900) fileVaried = TFile.Open('condor/FractionTimeWindow.root') if(fileVaried.IsZombie()): print 'Error opening file: condor/FractionTimeWindow.root' sys.exit(1) hVaried = fileVaried.Get('hist') min = 94 max = 99.6 c.cd(1) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle('Fraction of HO Rec Hits in [-12.5,12.5], GEN cone varied') hVaried.Draw('colz') label = getLabelCmsPrivateSimulation() label.Draw() c.Update() c.SaveAs('fractionInTimeWindow.pdf') c.SaveAs('fractionInTimeWindow.png') return fileVaried,c,hVaried,label
def plotRecHitVsDigiTime(): canvas = TCanvas("canvasRecHitVsDigi", "RecHitTime Vs Simple Digi", 1200, 1200) hoDigiTime = fileHandler.getGraph( 'hoDigiAnalyzer/correlation/hoTimeRecHitVsDigi') setupAxes(hoDigiTime) hoDigiTime.GetXaxis().SetTitle('digi time / ns') hoDigiTime.GetYaxis().SetTitle('rec hit time / ns') hoDigiTime.GetYaxis().SetTitleOffset(1.2) hoDigiTime.SetMarkerStyle(6) hoDigiTime.SetMarkerColor(colorRwthDarkBlue) hoDigiTime.SetTitle('HORecHit time vs. simple digi time estimation') hoDigiTime.Draw('ap') #Label for CMS private label = getLabelCmsPrivateSimulation() label.Draw() canvas.Update() canvas.SaveAs('plots/timing/digiTimeVsRecHitTime.png') return canvas, label, hoDigiTime
def plotPtAndPhiOfWrongBxId(self): #Prepare canvas canvas = TCanvas("canvasPtPhiBxWrong","PtPhiBxWrong",1200,1200) canvas.cd().Draw() #prepare histogram hist = self.fileHandler.getHistogram("etaPhi/3D/BxWrongGen_EtaPhiPt") stack = THStack(hist,"zy","2dStack","",-1,-1,-1,-1,"zy","") #Create new histogram and add the histograms from the stack histNew = TH2D("histPtPhiBxWrong","p_{T} vs. #phi distribution for wrong BX ID;#phi;p_{T} / 5 GeV;#",80,-3.2,3.2,40,0,200) histNew.GetYaxis().SetTitleOffset(1.2) for i in stack.GetHists(): histNew.Add(i) gStyle.SetPalette(1) histNew.SetStats(0) setupAxes(histNew) histNew.Draw('COLZ') canvas.Update() palette = histNew.FindObject("palette") palette.SetX1NDC(0.9) palette.SetX2NDC(0.92) #add label label = getLabelCmsPrivateSimulation() label.Draw() canvas.Update() self.storeCanvas(canvas,"bxWrongPtPhi") return canvas,hist,stack,histNew,label
def plotAverageEMaxAroundL1(self): canvas = TCanvas('canvasAverageEMax','Average EMax',1200,1200) canvas.cd().SetLogz() hSum = self.fileHandler.getHistogram('hoMuonAnalyzer/deltaEtaDeltaPhiEnergy/averageEMaxAroundPoint' + self.key + '_2dSummedWeights') hCounter = self.fileHandler.getHistogram('hoMuonAnalyzer/deltaEtaDeltaPhiEnergy/averageEMaxAroundPoint' + self.key + '_2dCounter') hSum = setupEAvplot(hSum, hCounter,same=True,limitForAll=0.3) hSum.SetTitle('Mean E_{Max} in HO tiles around L1 direction') hSum.SetMaximum(2) hSum.Draw('colz') setupEAvplot(hCounter,same=True,limitForAll=0.3).Draw('same,text') label = getLabelCmsPrivateSimulation() label.Draw() canvas.Update() setupPalette(hSum) canvas.Update() self.storeCanvas(canvas, 'averageEmax') hCounter.SaveAs('histogramEMaxCounter.root') return canvas,hSum,label,hCounter
def plotAverageEMaxAroundL1(self): canvas = TCanvas('canvasAverageEMax','Average EMax',1200,1200) canvas.cd().SetLogz() hSum = self.fileHandler.getHistogram('deltaEtaDeltaPhiEnergy/averageEMaxAroundPoint' + self.key + '_2dSummedWeights') hCounter = self.fileHandler.getHistogram('deltaEtaDeltaPhiEnergy/averageEMaxAroundPoint' + self.key + '_2dCounter') hSum = setupEAvplot(hSum, hCounter,same=True,limitForAll=0.3) hSum.SetTitle('Mean E_{Max} in HO tiles around L1 direction') hSum.SetMaximum(2) hSum.Draw('colz') setupEAvplot(hCounter,same=True,limitForAll=0.3).Draw('same,text') label = getLabelCmsPrivateSimulation() label.Draw() canvas.Update() setupPalette(hSum) canvas.Update() self.storeCanvas(canvas, 'averageEmax') hCounter.SaveAs('histogramEMaxCounter.root') return canvas,hSum,label,hCounter
def plotFractionInTimeWindow(): c = TCanvas("cFraction", "Fraction in Time Window", 900, 900) fileVaried = TFile.Open('condor/FractionTimeWindow.root') if (fileVaried.IsZombie()): print 'Error opening file: condor/FractionTimeWindow.root' sys.exit(1) hVaried = fileVaried.Get('hist') min = 94 max = 99.6 c.cd(1) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle( 'Fraction of HO Rec Hits in [-12.5,12.5], GEN cone varied') hVaried.Draw('colz') label = getLabelCmsPrivateSimulation() label.Draw() c.Update() c.SaveAs('fractionInTimeWindow.pdf') c.SaveAs('fractionInTimeWindow.png') return fileVaried, c, hVaried, label
def plotHoMatchEfficiency(): c = TCanvas("cHoEff","hoEff",1800,900) c.Divide(2,1) fileVaried = TFile.Open('condor/HoEff.root') if(fileVaried.IsZombie()): print 'Error opening file: condor/HoEff.root' sys.exit(1) fileFixed = TFile.Open('condorFixedGenDeltaR/HoEff.root') if(fileFixed.IsZombie()): print 'Error opening file: condorFixedGenDeltaR/HoEff.root' sys.exit(1) fileNL1Varied = TFile.Open('condor/Histtotal.root') fileNL1Fixed = TFile.Open('condorFixedGenDeltaR/Histtotal.root') histNL1Varied = fileNL1Varied.Get('histTotalTruth') histNL1Varied.SetName('histTotalTruthVaried') histNL1Fixed = fileNL1Fixed.Get('histTotalTruth') histNL1Fixed.SetName('histTotalTruthFixed') hVaried = fileVaried.Get('histEff') hVaried.SetName('histEffVaried') hFixed = fileFixed.Get('histEff') hFixed.SetName('histEffFixed') min = 18 max = 100 label = getLabelCmsPrivateSimulation() c.cd(1) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle('HO matched to "true" L1, GEN cone varied') hVaried.Draw('colz') label.Draw() # histNL1Varied.Draw('Same,box') c.cd(2) hFixed.SetMinimum(min) hFixed.SetMaximum(max) hFixed.SetTitle('HO matched to "true" L1, GEN cone fixed') hFixed.Draw('colz') # histNL1Fixed.Draw('same,box') label.Draw() c.Update() c.SaveAs('hoMatchEfficiency.png') c.SaveAs('hoMatchEfficiency.pdf') return c,hFixed,hVaried,fileFixed,fileVaried,histNL1Varied,histNL1Fixed,fileNL1Fixed,fileNL1Varied,label
def plotHoMatchEfficiency(): c = TCanvas("cHoEff", "hoEff", 1800, 900) c.Divide(2, 1) fileVaried = TFile.Open('condor/HoEff.root') if (fileVaried.IsZombie()): print 'Error opening file: condor/HoEff.root' sys.exit(1) fileFixed = TFile.Open('condorFixedGenDeltaR/HoEff.root') if (fileFixed.IsZombie()): print 'Error opening file: condorFixedGenDeltaR/HoEff.root' sys.exit(1) fileNL1Varied = TFile.Open('condor/Histtotal.root') fileNL1Fixed = TFile.Open('condorFixedGenDeltaR/Histtotal.root') histNL1Varied = fileNL1Varied.Get('histTotalTruth') histNL1Varied.SetName('histTotalTruthVaried') histNL1Fixed = fileNL1Fixed.Get('histTotalTruth') histNL1Fixed.SetName('histTotalTruthFixed') hVaried = fileVaried.Get('histEff') hVaried.SetName('histEffVaried') hFixed = fileFixed.Get('histEff') hFixed.SetName('histEffFixed') min = 18 max = 100 label = getLabelCmsPrivateSimulation() c.cd(1) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle('HO matched to "true" L1, GEN cone varied') hVaried.Draw('colz') label.Draw() # histNL1Varied.Draw('Same,box') c.cd(2) hFixed.SetMinimum(min) hFixed.SetMaximum(max) hFixed.SetTitle('HO matched to "true" L1, GEN cone fixed') hFixed.Draw('colz') # histNL1Fixed.Draw('same,box') label.Draw() c.Update() c.SaveAs('hoMatchEfficiency.png') c.SaveAs('hoMatchEfficiency.pdf') return c, hFixed, hVaried, fileFixed, fileVaried, histNL1Varied, histNL1Fixed, fileNL1Fixed, fileNL1Varied, label
def compareHistogramMethods(self): canvas = TCanvas('cComparison','Comparison btween histograms') # canvas.Divide(2,1) histNormal = self.fileHandler.getHistogram('averageEnergy/averageEnergyAroundPoint' + self.key + '_SummedEnergy') histNormalCounter = self.fileHandler.getHistogram('averageEnergy/averageEnergyAroundPoint' + self.key + '_Counter') histNormal = setupEAvplot(histNormal, histNormalCounter,same=True,limitForAll=0.6) # histNew = self.fileHandler.getHistogram('deltaEtaDeltaPhiEnergy/averageEnergyAroundPoint_2dSummedWeightsIEtaIPhi') # histNewCounter = self.fileHandler.getHistogram('deltaEtaDeltaPhiEnergy/averageEnergyAroundPoint_2dCounterIEtaIPhi') canvas.cd(1).SetLogz() histNormal.SetTitle('Average Energy in HO tiles around L1 direction, i#eta by binning') histNormal.SetStats(1) histNormal.Draw('colz') label = getLabelCmsPrivateSimulation() label.Draw() # canvas.cd(2).SetLogz() # histNew = average2DHistogramBinwise(histNew, histNewCounter) # histNew.GetXaxis().SetRangeUser(-8,8) # histNew.GetYaxis().SetRangeUser(-8,8) # histNew.GetXaxis().SetTitle('#Delta#eta') # histNew.GetYaxis().SetTitle('#Delta#phi') # histNew.GetZaxis().SetTitle('Reconstructed Energy / GeV') # histNew.SetTitle('Mean Energy in HO tiles around L1 direction, i#eta by binning') # histNew.Draw('colz') # label2 = getLabelCmsPrivateSimulation() # label2.Draw() canvas.Update() #Setup plot style setStatBoxOptions(histNormal,1100) setStatBoxPosition(histNormal) setupPalette(histNormal) # setupAxes(histNew) # setStatBoxOptions(histNew,1100) # setStatBoxPosition(histNew) # setupPalette(histNew) canvas.Update() #TODO: Print the bin contents subtracted return canvas, histNormal,label#,histNew,label2
def plotRpcVsHo(): hist =fileHandler.getHistogram('hoMuonAnalyzer/correlation/RpcHoAboveThr_TimeCorrelation') canvas = TCanvas('canvasRpcVsHo',"RPC vs. HO",1200,1200) canvas.cd().SetLogz() histNew = getTH2D("histRpcVsHo","RPC BX ID vs. HO > E_{Thr};HO time / ns;BX ID",5,-37.5,87.5#24,-56.25,93.75 ,5,-2.5,2.5) xAxis = hist.GetXaxis() yAxis = hist.GetYaxis() nBinsX = xAxis.GetNbins() nBinsY = yAxis.GetNbins() #Fill new histogram with fewer bins for i in range( 1 , nBinsX + 1 ): for j in range( 1 , nBinsY + 1 ): histNew.Fill(xAxis.GetBinCenter(i),yAxis.GetBinCenter(j)/25.,hist.GetBinContent(i,j)) histNew.SetStats(0) histNew.Draw('colz') canvas.Update() pal = histNew.GetListOfFunctions().FindObject("palette") pal.SetX2NDC(0.92) #Calcualte fraction at (0,0) nCentral = histNew.GetBinContent(histNew.FindBin(0,0)) nTotal = histNew.Integral() fraction = nCentral/float(nTotal) fractionUncert = calcSigma(nCentral,nTotal) sliceFraction = 0 for i in range(0,5): sliceFraction += histNew.GetBinContent(histNew.FindBin(0,-2.5+i)) sliceFractionUncert = calcSigma(sliceFraction,nTotal) sliceFraction /= nTotal paveTextAboveThr = TPaveText(0.1,0.8,0.5,0.9,'NDC') paveTextAboveThr.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction*100, fractionUncert*100)) paveTextAboveThr.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction*100, sliceFractionUncert*100)) paveTextAboveThr.SetBorderSize(1) paveTextAboveThr.Draw() label = getLabelCmsPrivateSimulation() label.Draw() canvas.SaveAs('plots/timeCorrelation/rpcVsHo.pdf') canvas.SaveAs('plots/timeCorrelation/rpcVsHo.png') return hist,canvas,paveTextAboveThr,label
def plotCorrectedL1MatchEfficiency(): c = TCanvas("cL1EffCorrected", "L1EffCorected", 1800, 900) c.Divide(2, 1) fileVaried = TFile.Open('condor/L1Eff.root') if (fileVaried.IsZombie()): print 'Error opening file: condor/L1Eff.root' sys.exit(1) hVaried = fileVaried.Get('histL1Eff') hOriginal = hVaried.Clone('clone') hVaried.SetName('histL1EffVariedCorrected') min = 0 max = 100 label = getLabelCmsPrivateSimulation() correctionsFile = open('geometricEfficiencies.txt') correctionsList = [] for line in correctionsFile.readlines(): if line.startswith('#'): continue correctionsList.append(float((line.split())[1])) print correctionsList print hVaried.GetNbinsX() for i in range(2, hVaried.GetNbinsX()): for j in range(2, hVaried.GetNbinsY()): if (correctionsList[i - 2] != 0): print hVaried.GetBinContent(i, j), hVaried.GetBinContent( i, j) / correctionsList[i - 2] * 100, correctionsList[i - 2] hVaried.SetBinContent( i, j, hVaried.GetBinContent(i, j) / correctionsList[i - 2] * 100) c.cd(1) hOriginal.SetMinimum(min) hOriginal.SetMaximum(max) hOriginal.Draw('colz') c.cd(2) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle('L1 matched to GEN, GEN cone varied, Corrected') hVaried.Draw('colz') label.Draw() c.Update() c.SaveAs('L1MatchEfficiencyCorr.png') c.SaveAs('L1MatchEfficiencyCorr.pdf') return c, hVaried, fileVaried, label
def plotCorrectedL1MatchEfficiency(): c = TCanvas("cL1EffCorrected","L1EffCorected",1800,900) c.Divide(2,1) fileVaried = TFile.Open('condor/L1Eff.root') if(fileVaried.IsZombie()): print 'Error opening file: condor/L1Eff.root' sys.exit(1) hVaried = fileVaried.Get('histL1Eff') hOriginal = hVaried.Clone('clone') hVaried.SetName('histL1EffVariedCorrected') min = 0 max = 100 label = getLabelCmsPrivateSimulation() correctionsFile = open('geometricEfficiencies.txt') correctionsList = [] for line in correctionsFile.readlines(): if line.startswith('#'): continue correctionsList.append(float((line.split())[1])) print correctionsList print hVaried.GetNbinsX() for i in range(2,hVaried.GetNbinsX()): for j in range(2,hVaried.GetNbinsY()): if(correctionsList[i-2] != 0): print hVaried.GetBinContent(i,j),hVaried.GetBinContent(i,j)/correctionsList[i-2]*100,correctionsList[i-2] hVaried.SetBinContent(i,j, hVaried.GetBinContent(i,j)/correctionsList[i-2]*100 ) c.cd(1) hOriginal.SetMinimum(min) hOriginal.SetMaximum(max) hOriginal.Draw('colz') c.cd(2) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle('L1 matched to GEN, GEN cone varied, Corrected') hVaried.Draw('colz') label.Draw() c.Update() c.SaveAs('L1MatchEfficiencyCorr.png') c.SaveAs('L1MatchEfficiencyCorr.pdf') return c,hVaried,fileVaried,label
def plotProduct(): c = TCanvas("cProduct", "product", 1800, 900) c.Divide(2, 1) fileVaried = TFile.Open('condor/product.root') if (fileVaried.IsZombie()): print 'Error opening file: condor/product.root' sys.exit(1) fileFixed = TFile.Open('condorFixedGenDeltaR/product.root') if (fileFixed.IsZombie()): print 'Error opening file: condorFixedGenDeltaR/product.root' sys.exit(1) hVaried = fileVaried.Get('histEffp') hVaried.SetName('histEffpVaried') hFixed = fileFixed.Get('histEffp') min = 15 max = 97 label = getLabelCmsPrivateSimulation() c.cd(1) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle( 'Fraction in TimeWindow #times HO matched to "true" L1, GEN cone varied' ) hVaried.Draw('colz') label.Draw() c.cd(2) hFixed.SetMinimum(min) hFixed.SetMaximum(max) hFixed.SetTitle( 'Fraction in TimeWindow #times HO matched to "true" L1, GEN cone fixed' ) hFixed.Draw('colz') label.Draw() c.Update() c.SaveAs('productTimeWindowAndEfficiency.png') c.SaveAs('productTimeWindowAndEfficiency.pdf') return c, hVaried, hFixed, fileFixed, fileVaried, label
def plotDigiDeltaTime(): canvas = TCanvas("canvasDigiDeltaTime", "Simple Digi Delta Time", 1200, 1200) canvas.SetLogy() histHoTime = fileHandler.getHistogram( 'hoDigiAnalyzer/hoTimeFromDigi_DeltaTime') setupAxes(histHoTime) histHoTime.GetXaxis().SetTitle('#Deltatime / ns') histHoTime.SetLineColor(colorRwthDarkBlue) histHoTime.SetStats(0) histHoTime.SetLineWidth(3) histHoTime.SetTitle( '#DeltaTime of L1 and simple time reconstruction from HO digi') histHoTime.Draw() #Label for CMS private label = getLabelCmsPrivateSimulation() label.Draw() #Add legend legend = TLegend(0.65, 0.75, 0.9, 0.9) legend.AddEntry(histHoTime, "L1 - Digi time", "l") legend.Draw() canvas.Update() canvas.SaveAs('plots/timing/digiTimeDeltaTime.pdf') canvas.SaveAs('plots/timing/digiTimeDeltaTime.png') histRecHitTime = fileHandler.getHistogram( 'hoMuonAnalyzer/L1MuonAboveThr_DeltaTime') histRecHitTime.SetLineColor(colorRwthMagenta) histRecHitTime.SetLineWidth(3) histRecHitTime.Draw('same') legend.AddEntry(histRecHitTime, "L1 - RecHit time", "l") legend.Draw() canvas.Update() canvas.SaveAs('plots/timing/digiTimeDeltaTimePlusRecHit.pdf') canvas.SaveAs('plots/timing/digiTimeDeltaTimePlusRecHit.png') return canvas, label, histHoTime, histRecHitTime, legend
def plotL1MatchEfficiency(): c = TCanvas("cL1Eff", "L1Eff", 1800, 900) c.Divide(2, 1) fileVaried = TFile.Open('condor/L1Eff.root') if (fileVaried.IsZombie()): print 'Error opening file: condor/L1Eff.root' sys.exit(1) fileFixed = TFile.Open('condorFixedGenDeltaR/L1Eff.root') if (fileFixed.IsZombie()): print 'Error opening file: condorFixedGenDeltaR/L1Eff.root' sys.exit(1) hVaried = fileVaried.Get('histL1Eff') hVaried.SetName('histL1EffVaried') hFixed = fileFixed.Get('histL1Eff') min = 0 max = 100 label = getLabelCmsPrivateSimulation() c.cd(1) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle('L1 matched to GEN, GEN cone varied') hVaried.Draw('colz') label.Draw() c.cd(2) hFixed.SetMinimum(min) hFixed.SetMaximum(max) hFixed.SetTitle('L1 matched to GEN, GEN cone fixed') hFixed.Draw('colz') label.Draw() c.Update() c.SaveAs('L1MatchEfficiency.png') c.SaveAs('L1MatchEfficiency.pdf') return c, hFixed, hVaried, fileFixed, fileVaried, label
def plotProduct(): c = TCanvas("cProduct","product",1800,900) c.Divide(2,1) fileVaried = TFile.Open('condor/product.root') if(fileVaried.IsZombie()): print 'Error opening file: condor/product.root' sys.exit(1) fileFixed = TFile.Open('condorFixedGenDeltaR/product.root') if(fileFixed.IsZombie()): print 'Error opening file: condorFixedGenDeltaR/product.root' sys.exit(1) hVaried = fileVaried.Get('histEffp') hVaried.SetName('histEffpVaried') hFixed = fileFixed.Get('histEffp') min = 15 max = 97 label = getLabelCmsPrivateSimulation() c.cd(1) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle('Fraction in TimeWindow #times HO matched to "true" L1, GEN cone varied') hVaried.Draw('colz') label.Draw() c.cd(2) hFixed.SetMinimum(min) hFixed.SetMaximum(max) hFixed.SetTitle('Fraction in TimeWindow #times HO matched to "true" L1, GEN cone fixed') hFixed.Draw('colz') label.Draw() c.Update() c.SaveAs('productTimeWindowAndEfficiency.png') c.SaveAs('productTimeWindowAndEfficiency.pdf') return c,hVaried,hFixed,fileFixed,fileVaried,label
def plotL1MatchEfficiency(): c = TCanvas("cL1Eff","L1Eff",1800,900) c.Divide(2,1) fileVaried = TFile.Open('condor/L1Eff.root') if(fileVaried.IsZombie()): print 'Error opening file: condor/L1Eff.root' sys.exit(1) fileFixed = TFile.Open('condorFixedGenDeltaR/L1Eff.root') if(fileFixed.IsZombie()): print 'Error opening file: condorFixedGenDeltaR/L1Eff.root' sys.exit(1) hVaried = fileVaried.Get('histL1Eff') hVaried.SetName('histL1EffVaried') hFixed = fileFixed.Get('histL1Eff') min = 0 max = 100 label = getLabelCmsPrivateSimulation() c.cd(1) hVaried.SetMinimum(min) hVaried.SetMaximum(max) hVaried.SetTitle('L1 matched to GEN, GEN cone varied') hVaried.Draw('colz') label.Draw() c.cd(2) hFixed.SetMinimum(min) hFixed.SetMaximum(max) hFixed.SetTitle('L1 matched to GEN, GEN cone fixed') hFixed.Draw('colz') label.Draw() c.Update() c.SaveAs('L1MatchEfficiency.png') c.SaveAs('L1MatchEfficiency.pdf') return c,hFixed,hVaried,fileFixed,fileVaried,label
def plotEtaPhiOfWrongBxId(self): canvasEtaPhiBxWrong = TCanvas("canvasEtaPhiBxWrong","canvasEtaPhiBxWrong",1200,1200) hWrong = self.fileHandler.getHistogram('hoMuonAnalyzer/BxWrongGen_Pt') hRight = self.fileHandler.getHistogram('hoMuonAnalyzer/BxRightGen_Pt') nRight = hRight.Integral() nWrong = hWrong.Integral() nEventsWithL1 = self.fileHandler.getHistogram('hoMuonAnalyzer/count/L1MuonPresent_Count').GetBinContent(2) etaPhiBxWrongNC = self.fileHandler.getGraph("hoMuonAnalyzer/graphs/BxWrongGen") etaPhiBxWrong = convertToHcalCoords(etaPhiBxWrongNC) etaPhiBxWrong.GetXaxis().SetTitle("i#eta / a.u.") etaPhiBxWrong.GetYaxis().SetTitle("i#phi / a.u.") etaPhiBxWrong.SetMarkerStyle(6) etaPhiBxWrong.SetMarkerColor(colorRwthDarkBlue) etaPhiBxWrong.SetTitle("#eta #phi plot of events with BX ID wrong") etaPhiBxWrong.Draw("AP") pText = TPaveText(0.7,0.85,0.9,0.9,'NDC') pText.AddText('Events with L1 objects: %d' % (nEventsWithL1)) pText.AddText('Events in Plot: %d' % (etaPhiBxWrong.GetN())) pText.SetBorderSize(1) pText.Draw() chimney1Converted = convertToHcalCoords(chimney1) chimney2Converted = convertToHcalCoords(chimney2) chimney1Converted.SetLineColor(colorRwthMagenta) chimney2Converted.SetLineColor(colorRwthMagenta) chimney1Converted.Draw("same,l") chimney2Converted.Draw("same,l") labelCmsPrivateSimulation = getLabelCmsPrivateSimulation() labelCmsPrivateSimulation.Draw() legend = TLegend(0.1,0.87,0.3,0.9) legend.AddEntry(chimney2Converted,"chimney","l") legend.Draw() canvasEtaPhiBxWrong.Update() self.storeCanvas(canvasEtaPhiBxWrong,"bxWrongEtaPhi")
def plotAdcTimeSliceCorrelation(): hist = fileHandler.getHistogram('hoDigiAnalyzer/correlation/MaxTimeSliceVsAdc_Correlation') canvas = TCanvas('canvasTSvsADC',"ADC vs. TS",1200,1200) canvas.cd().SetLogz() hist.GetXaxis().SetRangeUser(-1,11) hist.GetYaxis().SetRangeUser(10,130) hist.SetTitle("Max ADC Value vs. Time Slice;Time slice ID;ADC") hist.SetStats(0) setupAxes(hist) hist.Draw('colz') canvas.Update() pal = hist.GetListOfFunctions().FindObject("palette") pal.SetX2NDC(0.92) label = getLabelCmsPrivateSimulation() label.Draw() canvas.SaveAs('plots/timeCorrelation/adcVsTs.pdf') canvas.SaveAs('plots/timeCorrelation/adcVsTs.png') return hist,canvas,label
def plotAdcTimeSliceCorrelation(): hist = fileHandler.getHistogram( 'hoDigiAnalyzer/correlation/MaxTimeSliceVsAdc_Correlation') canvas = TCanvas('canvasTSvsADC', "ADC vs. TS", 1200, 1200) canvas.cd().SetLogz() hist.GetXaxis().SetRangeUser(-1, 11) hist.GetYaxis().SetRangeUser(10, 130) hist.SetTitle("Max ADC Value vs. Time Slice;Time slice ID;ADC") hist.SetStats(0) setupAxes(hist) hist.Draw('colz') canvas.Update() pal = hist.GetListOfFunctions().FindObject("palette") pal.SetX2NDC(0.92) label = getLabelCmsPrivateSimulation() label.Draw() canvas.SaveAs('plots/timeCorrelation/adcVsTs.pdf') canvas.SaveAs('plots/timeCorrelation/adcVsTs.png') return hist, canvas, label
def plotAverageEnergyAroundL1(self): canvas = TCanvas('canvasAverageEnergy','Average energy',1200,1200) canvas.cd().SetLogz() hSum = self.fileHandler.getHistogram('hoMuonAnalyzer/averageEnergy/averageEnergyAroundPoint' + self.key + '_SummedEnergy') hCounter = self.fileHandler.getHistogram('hoMuonAnalyzer/averageEnergy/averageEnergyAroundPoint' + self.key + '_Counter') for i in range(0,hSum.GetNbinsX()): for j in range(0,hSum.GetNbinsY()): if hCounter.GetBinContent(hCounter.GetBin(i,j)) != 0: hSum.SetBinContent(hSum.GetBin(i,j),hSum.GetBinContent(hSum.GetBin(i,j))/hCounter.GetBinContent(hCounter.GetBin(i,j))) pass hSum.GetXaxis().SetRangeUser(-0.6,0.6) hSum.GetYaxis().SetRangeUser(-0.6,0.6) # hSum.SetStats(0) hSum.GetXaxis().SetTitle('#Delta#eta') hSum.GetYaxis().SetTitle('#Delta#phi') hSum.GetZaxis().SetTitle('Reconstructed Energy / GeV') hSum.SetTitle('Average Energy in HO tiles around L1 direction') hSum.Draw('colz') # hCounter.Draw('same,text') label = getLabelCmsPrivateSimulation() label.Draw() canvas.Update() #Setup plot style setupAxes(hSum) setStatBoxOptions(hSum,1100) setStatBoxPosition(hSum) setupPalette(hSum) canvas.Update() self.storeCanvas(canvas,'averageEnergy') return canvas,hSum,label,hCounter
def plotEtaPhiOfWrongBxId(self): canvasEtaPhiBxWrong = TCanvas("canvasEtaPhiBxWrong","canvasEtaPhiBxWrong",1200,1200) nEventsWithL1 = self.fileHandler.getHistogram('count/L1MuonPresent_Count').GetBinContent(2) etaPhiBxWrongNC = self.fileHandler.getGraph("graphs/BxWrongGen") etaPhiBxWrong = convertToHcalCoords(etaPhiBxWrongNC) etaPhiBxWrong.GetXaxis().SetTitle("i#eta / a.u.") etaPhiBxWrong.GetYaxis().SetTitle("i#phi / a.u.") etaPhiBxWrong.SetMarkerStyle(6) etaPhiBxWrong.SetMarkerColor(colorRwthDarkBlue) etaPhiBxWrong.SetTitle("#eta #phi plot of events with BX ID wrong") etaPhiBxWrong.Draw("AP") pText = TPaveText(0.7,0.85,0.9,0.9,'NDC') pText.AddText('Events with L1 objects: %d' % (nEventsWithL1)) pText.AddText('Events in Plot: %d' % (etaPhiBxWrong.GetN())) pText.SetBorderSize(1) pText.Draw() chimney1Converted = convertToHcalCoords(chimney1) chimney2Converted = convertToHcalCoords(chimney2) chimney1Converted.SetLineColor(colorRwthMagenta) chimney2Converted.SetLineColor(colorRwthMagenta) chimney1Converted.Draw("same,l") chimney2Converted.Draw("same,l") labelCmsPrivateSimulation = getLabelCmsPrivateSimulation() labelCmsPrivateSimulation.Draw() legend = TLegend(0.1,0.87,0.3,0.9) legend.AddEntry(chimney2Converted,"chimney","l") legend.Draw() canvasEtaPhiBxWrong.Update() self.storeCanvas(canvasEtaPhiBxWrong,"bxWrongEtaPhi")
def plotDigiVsPhi(): canvas = TCanvas("canvasDigiPhi", "Simple Digi Phi", 1200, 1200) hoDigiTime = fileHandler.getGraph( 'hoDigiAnalyzer/correlation/hoTimeFromDigiPhi') setupAxes(hoDigiTime) hoDigiTime.GetXaxis().SetTitle('#phi') hoDigiTime.GetYaxis().SetTitle('time / ns') hoDigiTime.GetYaxis().SetTitleOffset(1.4) hoDigiTime.SetMarkerStyle(5) hoDigiTime.SetMarkerColor(colorRwthDarkBlue) hoDigiTime.SetTitle('Simple time reco vs. #phi') hoDigiTime.Draw('ap') #Label for CMS private label = getLabelCmsPrivateSimulation() label.Draw() canvas.Update() canvas.SaveAs('plots/timing/digiTimeVsphi.png') return canvas, hoDigiTime, label
def plotRpcVsHo(): hist = fileHandler.getHistogram( 'hoMuonAnalyzer/correlation/RpcHoAboveThr_TimeCorrelation') canvas = TCanvas('canvasRpcVsHo', "RPC vs. HO", 1200, 1200) canvas.cd().SetLogz() histNew = getTH2D( "histRpcVsHo", "RPC BX ID vs. HO > E_{Thr};HO time / ns;BX ID", 5, -37.5, 87.5 #24,-56.25,93.75 , 5, -2.5, 2.5) xAxis = hist.GetXaxis() yAxis = hist.GetYaxis() nBinsX = xAxis.GetNbins() nBinsY = yAxis.GetNbins() #Fill new histogram with fewer bins for i in range(1, nBinsX + 1): for j in range(1, nBinsY + 1): histNew.Fill(xAxis.GetBinCenter(i), yAxis.GetBinCenter(j) / 25., hist.GetBinContent(i, j)) histNew.SetStats(0) histNew.Draw('colz') canvas.Update() pal = histNew.GetListOfFunctions().FindObject("palette") pal.SetX2NDC(0.92) #Calcualte fraction at (0,0) nCentral = histNew.GetBinContent(histNew.FindBin(0, 0)) nTotal = histNew.Integral() fraction = nCentral / float(nTotal) fractionUncert = calcSigma(nCentral, nTotal) sliceFraction = 0 for i in range(0, 5): sliceFraction += histNew.GetBinContent(histNew.FindBin(0, -2.5 + i)) sliceFractionUncert = calcSigma(sliceFraction, nTotal) sliceFraction /= nTotal paveTextAboveThr = TPaveText(0.1, 0.8, 0.5, 0.9, 'NDC') paveTextAboveThr.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction * 100, fractionUncert * 100)) paveTextAboveThr.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction * 100, sliceFractionUncert * 100)) paveTextAboveThr.SetBorderSize(1) paveTextAboveThr.Draw() label = getLabelCmsPrivateSimulation() label.Draw() canvas.SaveAs('plots/timeCorrelation/rpcVsHo.pdf') canvas.SaveAs('plots/timeCorrelation/rpcVsHo.png') return hist, canvas, paveTextAboveThr, label
def plotDigiTest(): #Prepare canvas canvas = TCanvas("canvasBxId", "BXID", 1200, 1200) canvas.SetLogy() histBx = fileHandler.getHistogram("hoDigiAnalyzer/hoDigi_BxId") histBx.GetXaxis().SetRangeUser(-3, 3) histBx.SetLineWidth(3) histBx.Scale(1 / histBx.Integral()) histBx.SetStats(0) histBx.SetLineColor(colorRwthDarkBlue) histBx.Draw('') #Add label label = getLabelCmsPrivateSimulation() label.Draw() # #Add legend # legend = TLegend(0.7,0.65,0.9,0.8) # legend.AddEntry(histBx,"DT Only","l") # legend.AddEntry(histNew,"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 BX ID 0: %6.3f%% #pm %6.3f%%' % (dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal))) # pText.AddText('Fraction in BX ID 0 (HO corr.): %6.3f%% #pm %6.3f%%' % (correctedRightFraction*100,calcSigma(correctedBxId0, correctedTotal))) # pText.SetBorderSize(1) # pText.SetFillColor(0) # pText.Draw() # pText2 = TPaveText(0.7, 0.85, 0.9, 0.9, 'NDC') pText2.AddText('Entries: %d' % (histBx.GetEntries())) pText2.SetBorderSize(1) pText2.SetFillColor(0) pText2.Draw() canvas.Update() canvas.SaveAs('plots/timing/digiBxId.pdf') canvas.SaveAs('plots/timing/digiBxId.png') canvasAdcSum = TCanvas("cavasAdcSum", "ADC Sum", 1200, 1200) canvasAdcSum.SetLogy() histAdcSum = fileHandler.getHistogram( "hoMuonAnalyzer/hoDigiAdcSum_Multiplicity") histAdcSum.GetXaxis().SetRangeUser(-0.5, 500) histAdcSum.GetXaxis().SetTitle('ADC counts') histAdcSum.GetYaxis().SetTitle('#') histAdcSum.SetLineWidth(3) histAdcSum.SetStats(0) histAdcSum.SetLineColor(colorRwthDarkBlue) histAdcSum.Draw() canvasAdcSum.Update() canvasAdcSum.SaveAs('plots/timing/digiAdcSum.pdf') canvasAdcSum.SaveAs('plots/timing/digiAdcSum.png') canvasTS4 = TCanvas("cavasTS4", "TS4", 1200, 1200) canvasTS4.SetLogy() histAdcTS4 = fileHandler.getHistogram( "hoMuonAnalyzer/hoDigiAdcTS4_Multiplicity") histAdcTS4.GetXaxis().SetRangeUser(-0.5, 500) histAdcTS4.GetXaxis().SetTitle('ADC counts') histAdcTS4.GetYaxis().SetTitle('#') histAdcTS4.SetLineWidth(3) histAdcTS4.SetStats(0) histAdcTS4.SetLineColor(colorRwthDarkBlue) histAdcTS4.Draw() canvasTS4.Update() canvasTS4.SaveAs('plots/timing/digiAdcTs4.pdf') canvasTS4.SaveAs('plots/timing/digiAdcTs4.png') print histAdcSum.Integral(histAdcSum.FindBin(17), histAdcSum.FindBin(500)) return canvas, histBx, label, canvasAdcSum, histAdcSum, canvasTS4, histAdcTS4
def plotDeltaTime(self): hDeltaTAllHo = self.fileHandler.getHistogram('L1MuonPresentHoMatch_DeltaTime') hDeltaTCleanHo = self.fileHandler.getHistogram('timingSupport_UnmatchedDtHo_DeltaTime') c = TCanvas("c","Delta Time",1200,1200) c.SetLogy() hDeltaTAllHo.SetLineColor(colorRwthDarkBlue) hDeltaTAllHo.SetLineWidth(3) hDeltaTAllHo.SetFillColor(colorRwthDarkBlue) hDeltaTAllHo.SetFillStyle(3017) hDeltaTAllHo.SetTitle("#Delta time") hDeltaTAllHo.SetStats(0) hDeltaTCleanHo.SetLineColor(8) hDeltaTCleanHo.SetFillColor(8) hDeltaTCleanHo.SetLineWidth(3) hDeltaTCleanHo.SetFillStyle(3002) #hDeltaTAllHo.Scale(1/hDeltaTAllHo.Integral()) #hDeltaTCleanHo.Scale(1/hDeltaTCleanHo.Integral()) print hDeltaTCleanHo.Integral(),hDeltaTAllHo.Integral() fitFirstMin = TF1("fitFirstMin","[0]+x*[1]+[2]*x**2") fitSecondMin = TF1("fitsecondMin","[0]+x*[1]+[2]*x**2",10,20) hDeltaTCleanHo.Fit(fitFirstMin,"+q","",-20,-10) hDeltaTCleanHo.Fit(fitSecondMin,"R+q","") hDeltaTAllHo.Draw() legend = TLegend(0.6,0.75,0.9,0.9) legend.AddEntry(hDeltaTAllHo,"L1Muon matched to any HO","le") legend.Draw() label = getLabelCmsPrivateSimulation() label.Draw() c.Update() self.storeCanvas(c,"deltaTimeAllHo") hDeltaTCleanHo.Draw('same') fitFirstMin.SetRange(-50,50) fitSecondMin.SetRange(-50,50) #fitFirstMin.Draw('lSame') #fitSecondMin.Draw('lSame') lineFirstMin = TLine(fitFirstMin.GetMinimumX(-20,-10),hDeltaTAllHo.GetMinimum(),fitFirstMin.GetMinimumX(-20,-10),hDeltaTAllHo.GetMaximum()) lineFirstMin.SetLineWidth(3) lineFirstMin.SetLineColor(colorRwthRot) lineFirstMin.Draw() lineSecondMin = TLine(fitSecondMin.GetMinimumX(10,20),hDeltaTAllHo.GetMinimum(),fitSecondMin.GetMinimumX(10,20),hDeltaTAllHo.GetMaximum()) lineSecondMin.SetLineWidth(3) lineSecondMin.SetLineColor(colorRwthRot) lineSecondMin.Draw() legend.AddEntry(hDeltaTCleanHo,"L1Muon matched to HO > 0.2 GeV","le") legend.AddEntry(lineFirstMin,"Integral boundaries","e") legend.Draw() integralCenter = hDeltaTCleanHo.Integral(hDeltaTCleanHo.FindBin(fitFirstMin.GetMinimumX(-20,-10)),hDeltaTCleanHo.FindBin(fitSecondMin.GetMinimumX(10,20))) integralCenterAll = hDeltaTAllHo.Integral(hDeltaTAllHo.FindBin(fitFirstMin.GetMinimumX(-20,-10)),hDeltaTAllHo.FindBin(fitSecondMin.GetMinimumX(10,20))) self.debug(80*'#') self.debug('Integral of center area in clean histogram :%d' % integralCenter) self.debug('==> %.2f%% +/- %.2f%%' % (integralCenter/hDeltaTCleanHo.Integral()*100 ,calcSigma(integralCenter, hDeltaTCleanHo.Integral())*100)) self.debug('Integral of center area in all matched HO events:%d' % integralCenterAll) self.debug('==> %.2f%% +/- %.2f%%' % (integralCenterAll/hDeltaTAllHo.Integral()*100 ,calcSigma(integralCenterAll, hDeltaTAllHo.Integral())*100)) self.debug(80*'#') paveText = TPaveText(0.6,0.7,0.9,0.75,'NDC') paveText.AddText('%s' % ('Central peak contains (filtered hist.)')) paveText.AddText('%.2f%% +/- %.2f%%' % (integralCenter/hDeltaTCleanHo.Integral()*100,calcSigma(integralCenter, hDeltaTCleanHo.Integral())*100)) paveText.SetBorderSize(1) paveText.Draw() label = getLabelCmsPrivateSimulation() label.Draw() c.Update() self.storeCanvas(c,"deltaTime") return c, hDeltaTCleanHo
def plotHoL1Correlation(): #Select whether matching to all HO should also be plotted plotBoth = True histAll = fileHandler.getHistogram( 'hoMuonAnalyzer/correlation/L1MuonPresentHoMatch_TimeCorrelation') histAboveThr = fileHandler.getHistogram( 'hoMuonAnalyzer/correlation/L1MuonAboveThr_TimeCorrelation') label = getLabelCmsPrivateSimulation() canvas = TCanvas("canvasHoL1Correlation", "canvasHoL1Correlation", 1600, 1200) if (plotBoth): canvas.Divide(2, 1) canvas.cd(1).SetLogz() histNew = getTH2D( "histNew", "Correlation between L1 BX ID and HO;HO time / ns;L1 / BX ID", 5, -37.5, 87.5 #24,-56.25,93.75 , 5, -2.5, 2.5) xAxis = histAll.GetXaxis() yAxis = histAll.GetYaxis() nBinsX = xAxis.GetNbins() nBinsY = yAxis.GetNbins() #Fill new histogram with fewer bins for i in range(1, nBinsX + 1): for j in range(1, nBinsY + 1): histNew.Fill(xAxis.GetBinCenter(i), yAxis.GetBinCenter(j) / 25., histAll.GetBinContent(i, j)) histNew.SetStats(0) histNew.Draw('colz') canvas.Update() pal = histNew.GetListOfFunctions().FindObject("palette") pal.SetX2NDC(0.92) #Calcualte fraction at (0,0) nCentral = histNew.GetBinContent(histNew.FindBin(0, 0)) nTotal = histNew.Integral() fraction = nCentral / float(nTotal) fractionUncert = calcSigma(nCentral, nTotal) sliceFraction = 0 for i in range(0, 5): sliceFraction += histNew.GetBinContent(histNew.FindBin( 0, -2.5 + i)) sliceFractionUncert = calcSigma(sliceFraction, nTotal) sliceFraction /= nTotal paveText = TPaveText(0.1, 0.8, 0.5, 0.9, 'NDC') paveText.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction * 100, fractionUncert * 100)) paveText.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction * 100, sliceFractionUncert * 100)) paveText.SetBorderSize(1) paveText.Draw() label.Draw() canvas.cd(2).SetLogz() histAboveThr.SetStats(0) xAxis = histAboveThr.GetXaxis() yAxis = histAboveThr.GetYaxis() nBinsX = xAxis.GetNbins() nBinsY = yAxis.GetNbins() histNewAboveThr = getTH2D( "histNewAboveThr", "Correlation between L1 BX ID and HO > E_{Thr};HO time / ns;L1 / BX ID", 5, -37.5, 87.5 #,12,-56.25,93.75 , 5, -2.5, 2.5) for i in range(1, nBinsX + 1): for j in range(1, nBinsY + 1): histNewAboveThr.Fill(xAxis.GetBinCenter(i), yAxis.GetBinCenter(j) / 25., histAboveThr.GetBinContent(i, j)) histNewAboveThr.SetStats(0) histNewAboveThr.Draw('colz') canvas.Update() pal = histNewAboveThr.GetListOfFunctions().FindObject("palette") pal.SetX2NDC(0.92) #Calcualte fraction at (0,0) nCentral = histNewAboveThr.GetBinContent(histNewAboveThr.FindBin(0, 0)) nTotal = histNewAboveThr.Integral() fraction = nCentral / float(nTotal) fractionUncert = calcSigma(nCentral, nTotal) sliceFraction = 0 for i in range(0, 5): sliceFraction += histNewAboveThr.GetBinContent( histNewAboveThr.FindBin(0, -2.5 + i)) sliceFractionUncert = calcSigma(sliceFraction, nTotal) sliceFraction /= nTotal paveTextAboveThr = TPaveText(0.1, 0.8, 0.5, 0.9, 'NDC') paveTextAboveThr.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction * 100, fractionUncert * 100)) paveTextAboveThr.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction * 100, sliceFractionUncert * 100)) paveTextAboveThr.SetBorderSize(1) paveTextAboveThr.Draw() label.Draw() canvas.Update() canvas.SaveAs('plots/timeCorrelation/l1AndHoCorrelation.pdf') canvas.SaveAs('plots/timeCorrelation/l1AndHoCorrelation.png') return canvas, histAll, histAboveThr, label, histNewAboveThr, histNew, paveTextAboveThr
def plotDigiTime(truth=False): additionalString = 'Truth' if truth else '' canvas = TCanvas("canvasDigiSimpleTime" + additionalString, "Simple Digi Time " + additionalString, 1200, 1200) canvas.SetLogy() histHoTime = fileHandler.getHistogram('hoDigiAnalyzer/hoTimeFromDigi_Time') setupAxes(histHoTime) histHoTime.GetXaxis().SetTitle('time / ns') histHoTime.GetXaxis().SetRangeUser(-100, 100) histHoTime.SetLineColor(colorRwthDarkBlue) histHoTime.SetStats(0) histHoTime.SetFillStyle(3004) histHoTime.SetFillColor(colorRwthDarkBlue) histHoTime.SetLineWidth(3) histHoTime.SetTitle('Simple time reconstruction from HO digi') histHoTime.Draw() #Label for CMS private label = getLabelCmsPrivateSimulation() label.Draw() #Add legend legend = TLegend(0.65, 0.75, 0.9, 0.9) legend.AddEntry(histHoTime, "All Digi times", "f") legend.Draw() canvas.Update() canvas.SaveAs('plots/timing/digiTimeAllHo.pdf') canvas.SaveAs('plots/timing/digiTimeAllHo.png') #Now add next plot histHoTimeAboveThr = fileHandler.getHistogram( 'hoDigiAnalyzer/hoTimeFromDigiAboveThr' + additionalString + '_Time') histHoTimeAboveThr.SetLineColor(colorRwthTuerkis) histHoTimeAboveThr.SetStats(0) histHoTimeAboveThr.SetLineWidth(3) histHoTimeAboveThr.SetFillStyle(3005) histHoTimeAboveThr.SetFillColor(colorRwthTuerkis) histHoTimeAboveThr.Draw('same') legend.AddEntry(histHoTimeAboveThr, "4 TS sum > E_{Thr} " + additionalString, "f") legend.Draw() canvas.Update() canvas.SaveAs('plots/timing/digiTimePlusThr' + additionalString + '.pdf') canvas.SaveAs('plots/timing/digiTimePlusThr' + additionalString + '.png') #Now add Ho rec hit time plot histHoRecHitTime = fileHandler.getHistogram( 'hoMuonAnalyzer/hoRecHitsAboveThr_Time') histHoRecHitTime.SetLineColor(colorRwthMagenta) histHoRecHitTime.SetStats(0) histHoRecHitTime.SetLineWidth(3) histHoRecHitTime.Draw('same') legend.AddEntry(histHoRecHitTime, "HO Rec Hit Time > E_{Thr}", "l") legend.Draw() canvas.Update() canvas.SaveAs('plots/timing/digiTime' + additionalString + 'PlusRecHits.pdf') canvas.SaveAs('plots/timing/digiTime' + additionalString + 'PlusRecHits.png') return canvas, label, histHoTime, legend, histHoTimeAboveThr, histHoRecHitTime
def plotFractionsOfBxId(self): ##BX right plotting pt canvasBxRightPt = TCanvas("cBxRightPt","cBxRightPt",1200,1200) canvasBxRightPt.cd().SetLeftMargin(0.15) hBxRightPt = self.fileHandler.getHistogram('BxRightGen_Pt').Clone() setPlotStyle() hBxRightPt.Rebin(50) hBxRightPt.GetXaxis().SetRangeUser(0,200) hBxRightPt.GetYaxis().SetTitle("normalized Entries / 5 GeV") hBxRightPt.GetXaxis().SetTitle("p_{T} Gen") hBxRightPt.GetYaxis().SetTitleOffset(2) hBxRightPt.SetTitle("Events with right BX ID vs. p_{T}") hBxRightPt.SetStats(0) hBxRightPt.SetLineWidth(2) hBxRightPt.Scale(1/hBxRightPt.Integral()) hBxRightPt.Draw() label = getLabelCmsPrivateSimulation() label.Draw() self.storeCanvas(canvasBxRightPt,"bxRightPt") ##BX wrong plotting pt canvasBxWrongPt = TCanvas("cBxWrongPt","cBxWrongPt",1200,1200) canvasBxWrongPt.cd().SetLeftMargin(0.15) hBxWrongPt = self.fileHandler.getHistogram('BxWrongGen_Pt').Clone() setPlotStyle() hBxWrongPt.Rebin(50) hBxWrongPt.GetXaxis().SetRangeUser(0,200) hBxWrongPt.GetYaxis().SetTitle("normalized Entries / 5 GeV") hBxWrongPt.GetXaxis().SetTitle("p_{T} Gen") hBxWrongPt.GetYaxis().SetTitleOffset(2) hBxWrongPt.SetTitle("Events with wrong BX ID vs. p_{T}") hBxWrongPt.SetStats(0) hBxWrongPt.SetLineWidth(2) hBxWrongPt.Scale(1/hBxWrongPt.Integral()) hBxWrongPt.DrawCopy() label = getLabelCmsPrivateSimulation() label.Draw() self.storeCanvas(canvasBxWrongPt,"bxWrongPt") #Plot the histogram stack canvasStack = TCanvas("cStacked","cStacked",1200,1200) canvasStack.cd().SetLeftMargin(0.15) hWrong = self.fileHandler.getHistogram('BxWrongGen_Pt') hRight = self.fileHandler.getHistogram('BxRightGen_Pt') hRightFraction = TH1D('hRightFraction','',100,0,500) hWrongFraction = TH1D('hWrongFraction','',100,0,500) #hWrong.Rebin(50) #hRight.Rebin(50) #Fill the histograms with the bin wise fractions for i in range(0,hRight.GetNbinsX()): nRight = hRight.GetBinContent(i+1) nWrong = hWrong.GetBinContent(i+1) if(nRight + nWrong == 0): continue hRightFraction.SetBinContent(i+1,nRight/(nRight+nWrong)) hWrongFraction.SetBinContent(i+1,nWrong/(nRight+nWrong)) #Create the stack stack = THStack("hstack","Fractions of events for BX ID correct and wrong") nRight = hRight.Integral() nWrong = hWrong.Integral() hRightFraction.SetLineColor(colorRwthDarkBlue) hRightFraction.SetFillColor(colorRwthDarkBlue) hRightFraction.SetFillStyle(3002) hWrongFraction.SetLineColor(colorRwthMagenta) hWrongFraction.SetFillColor(colorRwthMagenta) hWrongFraction.SetFillStyle(3002) stack.Add(hRightFraction) stack.Add(hWrongFraction) stack.Draw() stack.GetXaxis().SetRangeUser(0.5,201) stack.GetYaxis().SetTitle('rel. fraction / 5 GeV') stack.GetYaxis().SetTitleOffset(2) stack.GetXaxis().SetTitle('p_{T} Gen') stack.SetMinimum(0.9) stack.SetMaximum(1) legend = TLegend(0.6,0.75,0.9,0.9) legend.AddEntry(hRightFraction,"BX ID right","f") legend.AddEntry(hWrongFraction,"BX ID wrong","f") legend.Draw() label = getLabelCmsPrivateSimulation() label.Draw() canvasStack.Update() self.storeCanvas(canvasStack,"bxStacked")
def plotDetectorContributionsToTiming(self): #Prepare canvas canvas = TCanvas("canvasDetectorContributions","detectorContributions",1200,600) canvas.Divide(2,1) canvas.cd(1).SetGridx(0) canvas.cd(1).SetGridy(0) canvas.cd(1).SetLogy() #prepare histogram hist = self.fileHandler.getHistogram("multiplicity/detectorIndexBxWrong_Multiplicity") hist.GetXaxis().SetRangeUser(0.5,5.5) hist.SetLineColor(colorRwthDarkBlue) hist.SetFillColor(colorRwthDarkBlue) #Prepare the bin labels x = ['RPC','DT','DT/RPC','CSC','CSC/RPC'] for i in range(1,6): hist.GetXaxis().SetBinLabel(i+1,x[i-1]) hist.GetXaxis().SetLabelFont(62) hist.GetYaxis().SetLabelFont(62) hist.GetYaxis().SetTitleFont(62) hist.Scale(1/hist.Integral()) hist.GetYaxis().SetTitle('rel. fraction') hist.SetStats(0) hist.SetTitle('Subdetectors in wrong L1 BX ID') hist.Draw() #add label label = getLabelCmsPrivateSimulation() label.Draw() #Make a histogram to grey out the CSC parts histGrey = TH1D('greyHist','grey hist',2,3.5,5.5) histGrey.SetBinContent(1,1) histGrey.SetBinContent(2,1) histGrey.SetFillStyle(3004) histGrey.SetLineWidth(2) histGrey.SetLineColor(1) histGrey.SetFillColor(1) histGrey.Draw('same') pText = TPaveText(0.7,0.33,0.79,0.62,"NDC") tTextPointer = pText.AddText('Not in #eta range') tTextPointer.SetTextAngle(90) tTextPointer.SetTextSize(0.039) pText.SetBorderSize(1) pText.SetFillColor(0) pText.Draw() canvas.cd(2).SetGridx(0) canvas.cd(2).SetGridy(0) canvas.cd(2).SetLogy() #prepare second histogram hist2 = self.fileHandler.getHistogram("multiplicity/detectorIndexBxRight_Multiplicity") hist2.GetXaxis().SetRangeUser(0.5,5.5) hist2.SetLineColor(colorRwthDarkBlue) hist2.SetFillColor(colorRwthDarkBlue) #Prepare the bin labels x = ['RPC','DT','DT/RPC','CSC','CSC/RPC'] for i in range(1,6): hist2.GetXaxis().SetBinLabel(i+1,x[i-1]) hist2.GetXaxis().SetLabelFont(62) hist2.GetYaxis().SetLabelFont(62) hist2.GetYaxis().SetTitleFont(62) hist2.Scale(1/hist2.Integral()) hist2.GetYaxis().SetTitle('rel. fraction') hist2.SetStats(0) hist2.SetTitle('Subdetectors in right L1 BX ID') hist2.Draw() #add label label2 = getLabelCmsPrivateSimulation() label2.Draw() histGrey.DrawCopy('same') pText2 = pText.Clone("pText2") pText2.Draw() canvas.Update() self.storeCanvas(canvas,"bxWrongDetectorContributions") return canvas,hist,label,histGrey,pText,pText2,label2,hist2
def plotImprovementInDt(self): #Prepare canvas canvas = TCanvas("canvasDtImprovement","DT improvement",1200,1200) canvas.SetLogy() histDt = self.fileHandler.getHistogram("hoMuonAnalyzer/timingSupport_UnmatchedDtHo_BxId") histDtNoHo = self.fileHandler.getHistogram("hoMuonAnalyzer/timingSupport_UnmatchedDt_BxId") #print 'DtBxNoHo Integral: ', histDtNoHo.Integral() #Define variables for integrals histHoTime = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport_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:' 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.GetBinContent(5) dtBxP1 = histDt.GetBinContent(7) dtBxTotal = dtBx0 + dtBxM1 + dtBxP1 dtFractionWrongM1 = dtBxM1/float(dtBxTotal) dtFractionWrongP1 = dtBxP1/float(dtBxTotal) #Print some information heading = 'Bin contents for 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' % (dtBxTotal) 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("histNew","BX ID in 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 = getLabelCmsPrivateSimulation() label.Draw() #Add legend legend = TLegend(0.7,0.65,0.9,0.8) legend.AddEntry(histDt,"DT Only + HO","l") legend.AddEntry(histNew,"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 BX ID 0: %5.2f%% #pm %5.2f%%' % (dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)*100)) pText.AddText('Fraction in 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:' 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*'#' canvas.Update() self.storeCanvas(canvas, 'correctedDt') return canvas, histDt,histNew,label,legend,pText2,pText,histDtNoHo
def plotHoL1Correlation(): #Select whether matching to all HO should also be plotted plotBoth = True histAll = fileHandler.getHistogram('hoMuonAnalyzer/correlation/L1MuonPresentHoMatch_TimeCorrelation') histAboveThr = fileHandler.getHistogram('hoMuonAnalyzer/correlation/L1MuonAboveThr_TimeCorrelation') label = getLabelCmsPrivateSimulation() canvas = TCanvas("canvasHoL1Correlation","canvasHoL1Correlation",1600,1200) if(plotBoth): canvas.Divide(2,1) canvas.cd(1).SetLogz() histNew = getTH2D("histNew","Correlation between L1 BX ID and HO;HO time / ns;L1 / BX ID",5,-37.5,87.5#24,-56.25,93.75 ,5,-2.5,2.5) xAxis = histAll.GetXaxis() yAxis = histAll.GetYaxis() nBinsX = xAxis.GetNbins() nBinsY = yAxis.GetNbins() #Fill new histogram with fewer bins for i in range( 1 , nBinsX + 1 ): for j in range( 1 , nBinsY + 1 ): histNew.Fill(xAxis.GetBinCenter(i),yAxis.GetBinCenter(j)/25.,histAll.GetBinContent(i,j)) histNew.SetStats(0) histNew.Draw('colz') canvas.Update() pal = histNew.GetListOfFunctions().FindObject("palette") pal.SetX2NDC(0.92) #Calcualte fraction at (0,0) nCentral = histNew.GetBinContent(histNew.FindBin(0,0)) nTotal = histNew.Integral() fraction = nCentral/float(nTotal) fractionUncert = calcSigma(nCentral,nTotal) sliceFraction = 0 for i in range(0,5): sliceFraction += histNew.GetBinContent(histNew.FindBin(0,-2.5+i)) sliceFractionUncert = calcSigma(sliceFraction,nTotal) sliceFraction /= nTotal paveText = TPaveText(0.1,0.8,0.5,0.9,'NDC') paveText.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction*100, fractionUncert*100)) paveText.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction*100, sliceFractionUncert*100)) paveText.SetBorderSize(1) paveText.Draw() label.Draw() canvas.cd(2).SetLogz() histAboveThr.SetStats(0) xAxis = histAboveThr.GetXaxis() yAxis = histAboveThr.GetYaxis() nBinsX = xAxis.GetNbins() nBinsY = yAxis.GetNbins() histNewAboveThr = getTH2D("histNewAboveThr","Correlation between L1 BX ID and HO > E_{Thr};HO time / ns;L1 / BX ID",5,-37.5,87.5#,12,-56.25,93.75 ,5,-2.5,2.5) for i in range( 1 , nBinsX + 1 ): for j in range( 1 , nBinsY + 1 ): histNewAboveThr.Fill(xAxis.GetBinCenter(i),yAxis.GetBinCenter(j)/25.,histAboveThr.GetBinContent(i,j)) histNewAboveThr.SetStats(0) histNewAboveThr.Draw('colz') canvas.Update() pal = histNewAboveThr.GetListOfFunctions().FindObject("palette") pal.SetX2NDC(0.92) #Calcualte fraction at (0,0) nCentral = histNewAboveThr.GetBinContent(histNewAboveThr.FindBin(0,0)) nTotal = histNewAboveThr.Integral() fraction = nCentral/float(nTotal) fractionUncert = calcSigma(nCentral,nTotal) sliceFraction = 0 for i in range(0,5): sliceFraction += histNewAboveThr.GetBinContent(histNewAboveThr.FindBin(0,-2.5+i)) sliceFractionUncert = calcSigma(sliceFraction,nTotal) sliceFraction /= nTotal paveTextAboveThr = TPaveText(0.1,0.8,0.5,0.9,'NDC') paveTextAboveThr.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction*100, fractionUncert*100)) paveTextAboveThr.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction*100, sliceFractionUncert*100)) paveTextAboveThr.SetBorderSize(1) paveTextAboveThr.Draw() label.Draw() canvas.Update() canvas.SaveAs('plots/timeCorrelation/l1AndHoCorrelation.pdf') canvas.SaveAs('plots/timeCorrelation/l1AndHoCorrelation.png') return canvas,histAll,histAboveThr,label,histNewAboveThr, histNew,paveTextAboveThr