def plotEtaPhiForDeltaPhiOne(self): canvas = TCanvas("cEtaPhiDeltaPhiOne","Eta Phi For DPhi 1",1200,1200) graph = self.fileHandler.getGraph('graphs/averageEnergyDeltaPhi1') halfbinwidth = L1_PHI_BIN/2. hist = TH2D('hEtaPhiDeltaPhi1',"#eta#phi of #Delta#phi=1 evts.",30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 289, -math.pi - halfbinwidth,math.pi + halfbinwidth) x = Double(0) y = Double(0) for i in range(0,graph.GetN()): graph.GetPoint(i,x,y) hist.Fill(x,y) hist.SetStats(0) hist.GetXaxis().SetRangeUser(-1,1) hist.SetTitle(hist.GetTitle() + ';#eta;#phi;Entries') setupAxes(hist) hist.Draw('colz') canvas.Update() setupPalette(hist) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas, 'etaPhiForDeltaPhiOne') canvas.SaveAs('plots/etaPhiForDeltaPhiOne.pdf') return canvas,hist,label
def plotEMaxCounts(self): canvas = TCanvas('canvasEmaxcounts','E max counts',1200,1200) canvas.cd().SetLogz() hCounter = self.fileHandler.getHistogram('hoMuonAnalyzer/deltaEtaDeltaPhiEnergy/averageEMaxAroundPointL1MuonPresent_2dCounter') #hSum = setupEAvplot(hSum, hCounter,same=True,limitForAll=0.3) hCounter.SetTitle('# of E_{Max} in HO tiles around L1 direction;#Delta#eta;#Delta#phi;# Entries') hCounter.SetStats(0) hCounter.GetXaxis().SetRangeUser(-.5,.5) hCounter.GetYaxis().SetRangeUser(-.5,.5) hCounter.Draw('colz') label = self.drawLabel() canvas.Update() setupPalette(hCounter) canvas.Update() #boxes = drawHoBoxes(canvas) self.storeCanvas(canvas,'eMaxCounts') #Calculate fraction in 3x3 grid integralCentral = hCounter.Integral(hCounter.GetXaxis().FindBin(-.0435),hCounter.GetXaxis().FindBin(.0435), hCounter.GetYaxis().FindBin(-.0435),hCounter.GetYaxis().FindBin(.0435)) integral3x3 = hCounter.Integral(hCounter.GetXaxis().FindBin(-.1305),hCounter.GetXaxis().FindBin(.1305), hCounter.GetYaxis().FindBin(-.1305),hCounter.GetYaxis().FindBin(.1305)) integralTotal = hCounter.Integral() self.output(80*'#') self.output('%20s:%5.2f%% +/- %5.2f%%' % ('Central Fraction',calcPercent(integralCentral,integralTotal), calcSigma(integralCentral,integralTotal)*100)) self.output('%20s:%5.2f%% +/- %5.2f%%' % ('3x3 Fraction',calcPercent(integral3x3,integralTotal), calcSigma(integral3x3,integralTotal)*100)) self.output(80*'#') return canvas,label,hCounter
def makeEmaxPlot(self,source, title = ""): if title == "": title = '# of E_{Max} in HO tiles around L1 direction ' + source canvas = TCanvas('canvasEmaxcounts' + source,'E max counts' + source,900,900) canvas.cd().SetLogz() hCounter = self.fileHandler.getHistogram('deltaEtaDeltaPhiEnergy/averageEMaxAroundPoint' + source + '_2dCounter') hCounter.GetXaxis().SetRangeUser(-.6,.6) hCounter.GetYaxis().SetRangeUser(-.6,.6) hCounter.SetTitle(title + ';#Delta#eta;#Delta#phi;# Entries') hCounter.SetStats(0) hCounter.Draw('colz') canvas.Update() setupAxes(hCounter) setupPalette(hCounter) canvas.Update() label = self.drawLabel() #boxes = drawHoBoxes(canvas) self.storeCanvas(canvas,'eMaxCounts' + source) #Output fractions in grid self.debug('Emax fraction for ' + source) self.outputFractionsInTileGrid(hCounter) return canvas,label,hCounter
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 plotEtaPhiForDeltaPhiOne(self): canvas = TCanvas("cEtaPhiDeltaPhiOne", "Eta Phi For DPhi 1", 1200, 1200) graph = self.fileHandler.getGraph('graphs/averageEnergyDeltaPhi1') halfbinwidth = L1_PHI_BIN / 2. hist = TH2D('hEtaPhiDeltaPhi1', "#eta#phi of #Delta#phi=1 evts.", 30, -15 * L1_ETA_BIN, 15 * L1_ETA_BIN, 289, -math.pi - halfbinwidth, math.pi + halfbinwidth) x = Double(0) y = Double(0) for i in range(0, graph.GetN()): graph.GetPoint(i, x, y) hist.Fill(x, y) hist.SetStats(0) hist.GetXaxis().SetRangeUser(-1, 1) hist.SetTitle(hist.GetTitle() + ';#eta;#phi;Entries') setupAxes(hist) hist.Draw('colz') canvas.Update() setupPalette(hist) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas, 'etaPhiForDeltaPhiOne') canvas.SaveAs('plots/etaPhiForDeltaPhiOne.pdf') return canvas, hist, label
def plotAverageEnergyAroundL1(self): canvas = TCanvas('canvasAverageEnergy','Average energy',900,800) canvas.cd().SetLogz() canvas.cd().SetRightMargin(.15) hSum = self.fileHandler.getHistogram('averageEnergy/averageEnergyAroundPoint' + self.key + '_SummedEnergy') hCounter = self.fileHandler.getHistogram('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.GetZaxis().SetTitle('Reconstructed Energy / GeV') hSum.SetTitle(';#Delta#eta;#Delta#phi;Reconstructed Energy / GeV')#'Average Energy in HO tiles around L1 direction hSum.Draw('colz') canvas.Update() #Setup plot style setupAxes(hSum) setStatBoxOptions(hSum,1100) setStatBoxPosition(hSum,x1=.65,x2=.85) setupPalette(hSum,x2ndc=.87) canvas.Update() self.storeCanvas(canvas,'averageEnergy',marginRight=.15) return canvas,hSum,hCounter,drawHoBoxes(canvas)
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 plot3x3MatchQualityCodes(self): c = TCanvas('cMatchQC3x3','Match QC 3x3',0,0,900,700) c.SetLogz() hist = self.fileHandler.getHistogram('hoMuonAnalyzer/qualityCode/L1Muon3x3Match_QcVsPt') hist.SetStats(0) hist.Scale(1,'width') hist.Draw('colz') c.Update() setupPalette(hist) c.Update() label = None if self.data: label = drawLabelCmsPrivateData() else: label = drawLabelCmsPrivateSimulation() c.Update() box = TBox(0,6.5,180,7.5) box.SetLineColor(3) box.SetLineWidth(2) box.Draw() c.Update() return hist,c,label,box
def plotAverageEnergyAroundL1(self): canvas = TCanvas('canvasAverageEnergy','Average energy',900,900) canvas.cd().SetLogz() hSum = self.fileHandler.getHistogram('averageEnergy/averageEnergyAroundPoint' + self.key + '_SummedEnergy') hCounter = self.fileHandler.getHistogram('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;#Delta#eta;#Delta#phi;Reconstructed Energy / GeV') hSum.Draw('colz') # hCounter.Draw('same,text') label = self.drawLabel() 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,drawHoBoxes(canvas)
def plotDeltaPhiVsL1Phi(self): canvas = TCanvas('cDeltaPhiVsL1Phi','DeltaPhiVsL1Phi',1200,1200) hist = self.fileHandler.getHistogram('correlation/shiftCheckDeltaPhiVsPhi') hist.GetYaxis().SetRangeUser(-1,1) hist.GetXaxis().SetRangeUser(-.5,.5) hist.GetXaxis().SetTitle('L1 #phi') hist.GetZaxis().SetTitle('#') hist.SetStats(0) hist.SetTitle('#Delta#phi vs. L1#phi') setupAxes(hist) hist.Draw('colz') phiBorderLines = [] HO_BIN = math.pi/36. for i in range(-31,32): line = TLine(HO_BIN*i - HO_BIN/2.,-.6, HO_BIN*i - HO_BIN/2.,.6) line.SetLineWidth(2) # line.Draw() phiBorderLines.append(line) legend = TLegend(0.6,0.8,0.9,0.85) legend.AddEntry(phiBorderLines[0],"HO Tile center","e") #legend.Draw() label = self.drawLabel() canvas.Update() setupPalette(hist) canvas.Update() canvas.SaveAs('plots/deltaPhiVsL1Phi.pdf') return canvas,hist,label,phiBorderLines,legend
def plotEtaPhiForTightL1(self): canvas = TCanvas("cEtaPhi","Eta Phi",1200,900) graphAll = self.fileHandler.getGraph('graphs/patTightToL1Muons') graphWithHo = self.fileHandler.getGraph('graphs/patTightToL1Muons3x3') halfPhiBinwidth = L1_PHI_BIN/2. l1BinOffset = L1_PHI_BIN*3/4. histAll = TH2D('hEtaPhiAll',"",30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 144, -math.pi,math.pi) histWithHo = TH2D('hEtaPhiWithHO',"",30,-15*L1_ETA_BIN,15*L1_ETA_BIN, 144, -math.pi,math.pi) x = Double(0) y = Double(0) for i in range(0,graphAll.GetN()): graphAll.GetPoint(i,x,y) histAll.Fill(x,y) for i in range(0,graphWithHo.GetN()): graphWithHo.GetPoint(i,x,y) histWithHo.Fill(x,y) canvas.cd().SetRightMargin(.15) histAll.SetStats(0) histAll.GetXaxis().SetRangeUser(-1,1) histAll.SetTitle(histAll.GetTitle() + ';#eta_{L1};#phi_{L1};Entries') histAll.Draw('colz') canvas.Update() setupAxes(histAll) setupPalette(histAll,x2ndc=.87) #label1 = self.drawLabel(x1ndc=.55,x2ndc=.85) histAll.GetZaxis().SetTitleOffset(1.) histAll.GetZaxis().SetRangeUser(0,1250) canvas.Update() canvas2 = TCanvas("cEtaPhiAndHo","Eta Phi And HO",1200,900) canvas2.cd().SetRightMargin(.15) histWithHo.SetStats(0) histWithHo.GetXaxis().SetRangeUser(-1,1) histWithHo.SetTitle(histWithHo.GetTitle() + ';#eta_{L1};#phi_{L1};Entries') histWithHo.Draw('colz') #label2 = self.drawLabel(x1ndc=.55,x2ndc=.85) histWithHo.GetZaxis().SetRangeUser(0,1250) canvas2.Update() setupAxes(histWithHo) setupPalette(histWithHo,x2ndc=.87) histWithHo.GetZaxis().SetTitleOffset(1.) canvas2.Update() self.storeCanvas(canvas, 'etaPhiForTightL1',marginRight=.15) self.storeCanvas(canvas2, 'etaPhiForTightL1AndHo',marginRight=.15) return canvas,histAll,histWithHo,canvas2
def plotEtaPhiForAllL1(self): canvas = TCanvas("cEtaPhi", "Eta Phi", 1200, 1200) canvas.Divide(2, 1) graphAll = self.fileHandler.getGraph('graphs/L1MuonPresent') graphWithHo = self.fileHandler.getGraph('graphs/L1Muon3x3') halfPhiBinwidth = L1_PHI_BIN / 2. halfEtaBinwidth = L1_ETA_BIN / 2. histAll = TH2D('hEtaPhiAll', "#eta#phi for all L1", 30, -15 * L1_ETA_BIN, 15 * L1_ETA_BIN, 289, -math.pi - halfPhiBinwidth, math.pi + halfPhiBinwidth) histWithHo = TH2D('hEtaPhiWithHO', "#eta#phi L1 + HO (3x3)", 30, -15 * L1_ETA_BIN, 15 * L1_ETA_BIN, 289, -math.pi - halfPhiBinwidth, math.pi + halfPhiBinwidth) x = Double(0) y = Double(0) for i in range(0, graphAll.GetN()): graphAll.GetPoint(i, x, y) histAll.Fill(x, y) for i in range(0, graphWithHo.GetN()): graphWithHo.GetPoint(i, x, y) histWithHo.Fill(x, y) canvas.cd(1) histAll.SetStats(0) histAll.GetXaxis().SetRangeUser(-1, 1) histAll.SetTitle(histAll.GetTitle() + ';#eta;#phi;Entries') setupAxes(histAll) histAll.Draw('colz') label1 = self.drawLabel() canvas.Update() setupPalette(histAll) canvas.cd(2) histWithHo.SetStats(0) histWithHo.GetXaxis().SetRangeUser(-1, 1) histWithHo.SetTitle(histWithHo.GetTitle() + ';#eta;#phi;Entries') setupAxes(histWithHo) histWithHo.Draw('colz') label2 = self.drawLabel() canvas.Update() setupPalette(histWithHo) canvas.Update() canvas.SaveAs('plots/etaPhiForAllL1.pdf') return canvas, histAll, histWithHo, label1, label2
def plotEtaPhiForAllL1(self): canvas = TCanvas("cEtaPhi","Eta Phi",1200,1200) canvas.Divide(2,1) graphAll = self.fileHandler.getGraph('graphs/L1MuonPresent') graphWithHo = self.fileHandler.getGraph('graphs/L1Muon3x3') halfPhiBinwidth = L1_PHI_BIN/2. halfEtaBinwidth = L1_ETA_BIN/2. histAll = TH2D('hEtaPhiAll',"#eta#phi for all L1",30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 289, -math.pi - halfPhiBinwidth,math.pi + halfPhiBinwidth) histWithHo = TH2D('hEtaPhiWithHO',"#eta#phi L1 + HO (3x3)",30,-15*L1_ETA_BIN,15*L1_ETA_BIN, 289, -math.pi - halfPhiBinwidth,math.pi + halfPhiBinwidth) x = Double(0) y = Double(0) for i in range(0,graphAll.GetN()): graphAll.GetPoint(i,x,y) histAll.Fill(x,y) for i in range(0,graphWithHo.GetN()): graphWithHo.GetPoint(i,x,y) histWithHo.Fill(x,y) canvas.cd(1) histAll.SetStats(0) histAll.GetXaxis().SetRangeUser(-1,1) histAll.SetTitle(histAll.GetTitle() + ';#eta;#phi;Entries') setupAxes(histAll) histAll.Draw('colz') label1 = self.drawLabel() canvas.Update() setupPalette(histAll) canvas.cd(2) histWithHo.SetStats(0) histWithHo.GetXaxis().SetRangeUser(-1,1) histWithHo.SetTitle(histWithHo.GetTitle() + ';#eta;#phi;Entries') setupAxes(histWithHo) histWithHo.Draw('colz') label2 = self.drawLabel() canvas.Update() setupPalette(histWithHo) canvas.Update() canvas.SaveAs('plots/etaPhiForAllL1.pdf') return canvas,histAll,histWithHo,label1,label2
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 plotEtaPhiForTightL1(self): canvas = TCanvas("cEtaPhi","Eta Phi",1200,1200) canvas.Divide(2,1) graphAll = self.fileHandler.getGraph('graphs/patTightToL1Muons') graphWithHo = self.fileHandler.getGraph('graphs/patTightToL1Muons3x3') halfPhiBinwidth = L1_PHI_BIN/2. l1BinOffset = L1_PHI_BIN*3/4. histAll = TH2D('hEtaPhiAll',"#eta#phi for tight L1",30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 144, -math.pi,math.pi) histWithHo = TH2D('hEtaPhiWithHO',"#eta#phi tight L1 + HO (3x3)",30,-15*L1_ETA_BIN,15*L1_ETA_BIN, 144, -math.pi,math.pi) x = Double(0) y = Double(0) for i in range(0,graphAll.GetN()): graphAll.GetPoint(i,x,y) histAll.Fill(x,y) for i in range(0,graphWithHo.GetN()): graphWithHo.GetPoint(i,x,y) histWithHo.Fill(x,y) canvas.cd(1) histAll.SetStats(0) histAll.GetXaxis().SetRangeUser(-1,1) histAll.SetTitle(histAll.GetTitle() + ';#eta_{L1};#phi_{L1};Entries') histAll.Draw('colz') canvas.Update() setupAxes(histAll) setupPalette(histAll) label1 = self.drawLabel() canvas.Update() canvas.cd(2) histWithHo.SetStats(0) histWithHo.GetXaxis().SetRangeUser(-1,1) histWithHo.SetTitle(histWithHo.GetTitle() + ';#eta_{L1};#phi_{L1};Entries') histWithHo.Draw('colz') label2 = self.drawLabel() canvas.Update() setupAxes(histWithHo) setupPalette(histWithHo) canvas.Update() self.storeCanvas(canvas, 'etaPhiForTightL1') return canvas,histAll,histWithHo,label1,label2
def plotL1EtaVsPatEta(self): c, hist = self.plotL1EtaVsPatEtaFine() graph = self.fileHandler.getGraph('graphs/l1EtaVsPatEtaNotFine') fillGraphIn2DHist(graph, hist) hist.SetTitle('L1Muon #eta vs. pat #eta') c.Update() setupAxes(hist) setupPalette(hist) hist.SetStats(0) hist.GetXaxis().SetRangeUser(-.8, .8) hist.GetYaxis().SetRangeUser(-.8, .8) c.Update() return c, hist
def plotHoIEtaIPhi(self): canvas = TCanvas('cHoIEtaIPhi','HO iEta iPhi',0,50,600,500) hoEtaPhi = self.fileHandler.getHistogram('hoMuonAnalyzer/etaPhi/hoRecHitsAboveThr_iEtaIPhi') hoEtaPhi.SetTitle('HO RecHits > 0.2GeV;i#eta;i#phi;# entries') hoEtaPhi.Draw('colz') canvas.Update() hoEtaPhi.SetStats(0) setupAxes(hoEtaPhi) setupPalette(hoEtaPhi) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas,"hoEtaPhi") return label,canvas,hoEtaPhi
def plotL1EtaVsPatEta(self): c, hist = self.plotL1EtaVsPatEtaFine() graph = self.fileHandler.getGraph('graphs/l1EtaVsPatEtaNotFine') fillGraphIn2DHist(graph, hist) hist.SetTitle('L1Muon #eta vs. pat #eta') c.Update() setupAxes(hist) setupPalette(hist) hist.SetStats(0) hist.GetXaxis().SetRangeUser(-.8,.8) hist.GetYaxis().SetRangeUser(-.8,.8) c.Update() return c,hist
def plotHoIEtaIPhiMatchedToL1(self): canvas = TCanvas('cHoIEtaIPhiAndL1','HO iEta iPhi And L1',650,50,600,500) hoEtaPhi = self.fileHandler.getHistogram('etaPhi/L1Muon3x3_iEtaIPhi') hoEtaPhi.SetTitle('L1 matched to HO RecHits > 0.2GeV;i#eta;i#phi;# entries') hoEtaPhi.Draw('colz') canvas.Update() hoEtaPhi.SetStats(0) setupAxes(hoEtaPhi) setupPalette(hoEtaPhi) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas,"l1MatchedToHoIEtaIPhi") return label,canvas,hoEtaPhi
def plotEtaPhiForTightL1(self): canvas = TCanvas("cEtaPhi","Eta Phi",1200,1200) canvas.Divide(2,1) graphAll = self.fileHandler.getGraph('hoMuonAnalyzer/graphs/L1TightMuons') graphWithHo = self.fileHandler.getGraph('hoMuonAnalyzer/graphs/L1TightMuons3x3') halfPhiBinwidth = L1_PHI_BIN/2. l1BinOffset = L1_PHI_BIN*3/4. histAll = TH2D('hEtaPhiAll',"#eta#phi for tight L1",30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 144, -math.pi,math.pi) histWithHo = TH2D('hEtaPhiWithHO',"#eta#phi tight L1 + HO (3x3)",30,-15*L1_ETA_BIN,15*L1_ETA_BIN, 144, -math.pi,math.pi) x = Double(0) y = Double(0) for i in range(0,graphAll.GetN()): graphAll.GetPoint(i,x,y) histAll.Fill(x,y) for i in range(0,graphWithHo.GetN()): graphWithHo.GetPoint(i,x,y) histWithHo.Fill(x,y) canvas.cd(1) histAll.SetStats(0) histAll.GetXaxis().SetRangeUser(-1,1) histAll.SetTitle(histAll.GetTitle() + ';#eta_{L1};#phi_{L1};Entries') setupAxes(histAll) histAll.Draw('colz') label1 = self.drawLabel() canvas.Update() setupPalette(histAll) canvas.cd(2) histWithHo.SetStats(0) histWithHo.GetXaxis().SetRangeUser(-1,1) histWithHo.SetTitle(histWithHo.GetTitle() + ';#eta_{L1};#phi_{L1};Entries') setupAxes(histWithHo) histWithHo.Draw('colz') label2 = self.drawLabel() canvas.Update() setupPalette(histWithHo) canvas.Update() self.storeCanvas(canvas, 'etaPhiForTightL1') return canvas,histAll,histWithHo,label1,label2
def plotDeltaPhiVsGenPt(self): canvas = TCanvas('cDeltaPhiVsGenPt','DeltaPhiVsGenPt',1200,1200) hist = self.fileHandler.getHistogram('correlation/shiftCheckDeltaPhiVsGenPt') hist.GetYaxis().SetRangeUser(-0.6,0.6) hist.Draw('colz') canvas.Update() setupPalette(hist) setupAxes(hist) label = self.drawLabel() canvas.Update() return canvas,hist,label
def plotTightL1EtaPhiRatio(self): gL1Tight = self.fileHandler.getGraph('graphs/patTightToL1Muons') gL1Tight3x3 = self.fileHandler.getGraph('graphs/patTightToL1Muons3x3') halfPhiBinwidth = L1_PHI_BIN/2. hL1Tight = TH2D('hL1Tight','L1Tight',30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 144, -math.pi,math.pi) hL1Tight3x3 = TH2D('hL1Tight3x3','L1Tight3x3',30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 144, -math.pi,math.pi) hL1Tight = fillGraphIn2DHist(gL1Tight,hL1Tight) hL1Tight3x3 = fillGraphIn2DHist(gL1Tight3x3,hL1Tight3x3) c1 = TCanvas("available tight L1 for matching") hClone = hL1Tight.Clone('hClone') hClone.Draw('colz') hRatio = hL1Tight3x3.Clone('asdfasdf') hRatio.Divide(hL1Tight) c = TCanvas('2dMap',"",1200,900) #Local Efficiency per tight L1 coordinate (3x3 Matching) hRatio.SetTitle(';#eta_{L1};#phi_{L1} / rad;#epsilon') hRatio.GetXaxis().SetRangeUser(-0.8,.8) hRatio.Draw('colz') hRatio.SetStats(0) c.Update() setupAxes(hRatio) setupPalette(hRatio) c.Update() hRatio.GetYaxis().SetTitleOffset(.7) hRatio.GetZaxis().SetTitleOffset(.5) self.storeCanvas(c, 'localTightL1Efficiency') c2 = TCanvas('projections') c2.Divide(2,1) c2.cd(1) hEta = hRatio.ProjectionX() hEta.Scale(1/float(144))#72 phi bins hEta.Draw() c2.cd(2) hPhi = hRatio.ProjectionY() hPhi.Scale(1/float(16))#16 eta bins, cutoff due to |eta| < 0.8 hPhi.Draw() return c,hRatio,c2,hEta,hPhi,c1,hClone
def plotTightL1EtaPhiRatio(self): gL1Tight = self.fileHandler.getGraph('graphs/patTightToL1Muons') gL1Tight3x3 = self.fileHandler.getGraph('graphs/patTightToL1Muons3x3') halfPhiBinwidth = L1_PHI_BIN / 2. hL1Tight = TH2D('hL1Tight', 'L1Tight', 30, -15 * L1_ETA_BIN, 15 * L1_ETA_BIN, 144, -math.pi, math.pi) hL1Tight3x3 = TH2D('hL1Tight3x3', 'L1Tight3x3', 30, -15 * L1_ETA_BIN, 15 * L1_ETA_BIN, 144, -math.pi, math.pi) hL1Tight = fillGraphIn2DHist(gL1Tight, hL1Tight) hL1Tight3x3 = fillGraphIn2DHist(gL1Tight3x3, hL1Tight3x3) c1 = TCanvas("available tight L1 for matching") hClone = hL1Tight.Clone('hClone') hClone.Draw('colz') hRatio = hL1Tight3x3.Clone('asdfasdf') hRatio.Divide(hL1Tight) c = TCanvas('2dMap') hRatio.SetTitle( 'Local Efficiency per tight L1 coordinate (3x3 Matching);#eta_{L1};#phi_{L1};#epsilon' ) hRatio.GetXaxis().SetRangeUser(-0.8, .8) hRatio.Draw('colz') hRatio.SetStats(0) c.Update() setupAxes(hRatio) setupPalette(hRatio) label = self.drawLabel() c.Update() self.storeCanvas(c, 'localTightL1Efficiency') c2 = TCanvas('projections') c2.Divide(2, 1) c2.cd(1) hEta = hRatio.ProjectionX() hEta.Scale(1 / float(144)) #72 phi bins hEta.Draw() c2.cd(2) hPhi = hRatio.ProjectionY() hPhi.Scale(1 / float(16)) #16 eta bins, cutoff due to |eta| < 0.8 hPhi.Draw() return c, hRatio, label, c2, hEta, hPhi, c1, hClone
def plotHoEtaPhiMatchedToL1(self): canvas = TCanvas('cHoEtaPhiAndL1','HO Eta Phi And L1') hoEtaPhi = self.fileHandler.getHistogram('hoMuonAnalyzer/etaPhi/L1MuonWithHoMatchAboveThr_HO_EtaPhi') hoEtaPhi.SetTitle('L1 matched to HO RecHits > 0.2GeV;#eta_{HO};#phi_{HO};# entries') hoEtaPhi.Rebin2D(10,10) hoEtaPhi.GetXaxis().SetRangeUser(-1.5,1.5) hoEtaPhi.Draw('colz') canvas.Update() hoEtaPhi.SetStats(0) setupAxes(hoEtaPhi) setupPalette(hoEtaPhi) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas,"l1MatchedToHoEtaPhi") return label,canvas,hoEtaPhi
def plot3x3FailQualityCodesVsPt(self): c = TCanvas('cFailQC3x3','Fail QC 3x3',910,0,900,700) c.SetLogz() hist = self.fileHandler.getHistogram('qualityCode/L1Muon3x3Fail_QcVsPt') hist.SetStats(0) hist.Scale(1,'width') hist.Draw('colz') c.Update() setupPalette(hist) c.Update() label = self.drawLabel() c.Update() return hist,c,label
def plotHoIEtaIPhi(self): canvas = TCanvas('cHoIEtaIPhi','HO iEta iPhi',0,300,600,500) canvas.SetLogz() canvas.cd().SetRightMargin(.15) hoEtaPhi = self.fileHandler.getHistogram('etaPhi/hoRecHitsAboveThr_iEtaIPhi') hoEtaPhi.SetTitle(';i#eta;i#phi;Entries')#'HO RecHits > 0.2GeV;i#eta;i#phi;# entries') hoEtaPhi.Draw('colz') canvas.Update() hoEtaPhi.SetStats(0) setupAxes(hoEtaPhi) #hoEtaPhi.GetZaxis().SetTitleOffset(.9) setupPalette(hoEtaPhi,x2ndc=.87) canvas.Update() self.storeCanvas(canvas,"hoEtaPhi",marginRight=.15) return canvas,hoEtaPhi
def plotHoEtaPhiMatchedToTightL1(self): canvas = TCanvas('cHoEtaPhiAndTightL1','HO Eta Phi And Tight L1') hoEtaPhi = self.fileHandler.getHistogram('etaPhi/patMuonsTight_HO_EtaPhi') hoEtaPhi.SetTitle('Tight L1 matched to HO RecHits > 0.2GeV;#eta_{HO};#phi_{HO};# entries') hoEtaPhi.Rebin2D(10,10) hoEtaPhi.GetXaxis().SetRangeUser(-1.5,1.5) hoEtaPhi.Draw('colz') canvas.Update() hoEtaPhi.SetStats(0) setupAxes(hoEtaPhi) setupPalette(hoEtaPhi) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas,"tightPatToHoEtaPhi") return label,canvas,hoEtaPhi
def plotL1EtaVsPatEtaTight(self): c, hist = self.plotL1EtaVsPatEtaFineTight() graph = self.fileHandler.getGraph('graphs/l1EtaVsPatEtaNotFineTight') fillGraphIn2DHist(graph, hist) hist.SetTitle('')#tight L1Muon #eta vs. pat #eta') c.Update() setupAxes(hist) setupPalette(hist,shiftBy=.05) hist.SetStats(0) hist.GetXaxis().SetRangeUser(-.8,.8) hist.GetYaxis().SetRangeUser(-.8,.8) hist.GetZaxis().SetTitle('Entries') c.Update() self.storeCanvas(c,'l1EtaVsPatEtaTight',marginRight=.15) return c,hist
def plotL1EtaVsPatEtaTight(self): c, hist = self.plotL1EtaVsPatEtaFineTight() graph = self.fileHandler.getGraph('graphs/l1EtaVsPatEtaNotFineTight') fillGraphIn2DHist(graph, hist) hist.SetTitle('tight L1Muon #eta vs. pat #eta') c.Update() setupAxes(hist) setupPalette(hist) hist.SetStats(0) hist.GetXaxis().SetRangeUser(-.8, .8) hist.GetYaxis().SetRangeUser(-.8, .8) label = self.drawLabel() c.Update() self.storeCanvas(c, 'l1EtaVsPatEtaTight') return c, hist, label
def plotDeltaPhiVsGenPt(self): canvas = TCanvas('cDeltaPhiVsGenPt', 'DeltaPhiVsGenPt', 1200, 1200) hist = self.fileHandler.getHistogram( 'correlation/shiftCheckDeltaPhiVsGenPt') hist.GetYaxis().SetRangeUser(-0.6, 0.6) hist.Draw('colz') canvas.Update() setupPalette(hist) setupAxes(hist) label = self.drawLabel() canvas.Update() return canvas, hist, label
def plotHoIEtaIPhi(self): canvas = TCanvas('cHoIEtaIPhi', 'HO iEta iPhi', 0, 50, 600, 500) canvas.SetLogz() hoEtaPhi = self.fileHandler.getHistogram( 'etaPhi/hoRecHitsAboveThr_iEtaIPhi') hoEtaPhi.SetTitle('HO RecHits > 0.2GeV;i#eta;i#phi;# entries') hoEtaPhi.Draw('colz') canvas.Update() hoEtaPhi.SetStats(0) setupAxes(hoEtaPhi) setupPalette(hoEtaPhi) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas, "hoEtaPhi") return label, canvas, hoEtaPhi
def plotHoIEtaIPhiMatchedToL1(self): canvas = TCanvas('cHoIEtaIPhiAndL1', 'HO iEta iPhi And L1', 650, 50, 600, 500) hoEtaPhi = self.fileHandler.getHistogram('etaPhi/L1Muon3x3_iEtaIPhi') hoEtaPhi.SetTitle( 'L1 matched to HO RecHits > 0.2GeV;i#eta;i#phi;# entries') hoEtaPhi.Draw('colz') canvas.Update() hoEtaPhi.SetStats(0) setupAxes(hoEtaPhi) setupPalette(hoEtaPhi) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas, "l1MatchedToHoIEtaIPhi") return label, canvas, hoEtaPhi
def plot3x3FailQualityCodesVsPt(self): c = TCanvas('cFailQC3x3', 'Fail QC 3x3', 910, 0, 900, 700) c.SetLogz() hist = self.fileHandler.getHistogram( 'qualityCode/L1Muon3x3Fail_QcVsPt') hist.SetStats(0) hist.Scale(1, 'width') hist.Draw('colz') c.Update() setupPalette(hist) c.Update() label = self.drawLabel() c.Update() return hist, c, label
def plotDeltaPhiVsL1Pt(self): canvas = TCanvas('cDeltaPhiVsL1Pt','DeltaPhiVsL1Pt',1200,1200) canvas.cd().SetLogz() hist = self.fileHandler.getHistogram('correlation/shiftCheckDeltaPhiVsL1PtL1MuonPresent') hist.Scale(1,'width') hist.SetStats(0) hist.GetYaxis().SetRangeUser(-0.6,.6) hist.GetZaxis().SetTitle('# entries') hist.Draw('colz') label = self.drawLabel() setupAxes(hist) canvas.Update() setupPalette(hist) canvas.Update() self.storeCanvas(canvas,'deltaPhiVsPt') return canvas,hist,label
def plotHoEtaPhiMatchedToL1(self): canvas = TCanvas('cHoEtaPhiAndL1', 'HO Eta Phi And L1') hoEtaPhi = self.fileHandler.getHistogram( 'etaPhi/L1MuonWithHoMatchAboveThr_HO_EtaPhi') hoEtaPhi.SetTitle( 'L1 matched to HO RecHits > 0.2GeV;#eta_{HO};#phi_{HO};# entries') hoEtaPhi.Rebin2D(10, 10) hoEtaPhi.GetXaxis().SetRangeUser(-1.5, 1.5) hoEtaPhi.Draw('colz') canvas.Update() hoEtaPhi.SetStats(0) setupAxes(hoEtaPhi) setupPalette(hoEtaPhi) label = self.drawLabel() canvas.Update() self.storeCanvas(canvas, "l1MatchedToHoEtaPhi") return label, canvas, hoEtaPhi
def plotDeltaPhiVsL1Pt(self): canvas = TCanvas('cDeltaPhiVsL1Pt', 'DeltaPhiVsL1Pt', 1200, 1200) canvas.cd().SetLogz() hist = self.fileHandler.getHistogram( 'correlation/shiftCheckDeltaPhiVsL1PtL1MuonPresent') hist.Scale(1, 'width') hist.SetStats(0) hist.GetYaxis().SetRangeUser(-0.6, .6) hist.GetZaxis().SetTitle('# entries') hist.Draw('colz') label = self.drawLabel() setupAxes(hist) canvas.Update() setupPalette(hist) canvas.Update() self.storeCanvas(canvas, 'deltaPhiVsPt') return canvas, hist, label
def createPlotPtVsQualityCode(gridSize): sourceHistogramsForGrid = { 1:'hoMuonAnalyzer/correlation/L1MuonpTvsQCCentralFail', 2:'hoMuonAnalyzer/correlation/L1MuonpTvsQC3x3Fail', 3:'hoMuonAnalyzer/correlation/L1MuonpTvsQC5x5Fail' } histogramTitleDict = { 1:'Central', 2:'3x3', 3:'5x5' } histogram = fileHandler.getHistogram(sourceHistogramsForGrid.get(gridSize)) title = 'p_{T} vs. rejected QC (' + histogramTitleDict.get(gridSize) + ')' canvasTitle = 'cPtVsQualityCodes' + histogramTitleDict.get(gridSize) canvas = TCanvas(canvasTitle,'cPtVsQualityCodes' + histogramTitleDict.get(gridSize),800,0,800,600) canvas.SetLogz() histogram.GetXaxis().SetRangeUser(0,8) histogram.GetYaxis().SetRangeUser(-1,160) histogram.SetStats(0) histogram.SetTitle(title) histogram.Scale(1,'width') histogram.Draw('colz') label = drawLabelCmsPrivateSimulation() canvas.Update() setupPalette(histogram) canvas.Update() fileNameTrunk = 'plots/efficiency/ptVsQualityCode' + histogramTitleDict.get(gridSize) + 'Fail' canvas.SaveAs(fileNameTrunk + '.png') canvas.SaveAs(fileNameTrunk + '.pdf') histogram.Draw('lego2') canvas.Update() canvas.SaveAs(fileNameTrunk + '3D.png') canvas.SaveAs(fileNameTrunk + '3D.pdf') return canvas,label,histogram
def plotEMaxCountsForTightMuons(self): canvas = TCanvas('canvasEmaxcountsTightMuons','E max counts Tight muons',1200,1200) canvas.cd().SetLogz() hCounter = self.fileHandler.getHistogram('hoMuonAnalyzer/deltaEtaDeltaPhiEnergy/averageEMaxAroundPointL1TightMuons_2dCounter') #hSum = setupEAvplot(hSum, hCounter,same=True,limitForAll=0.3) hCounter.SetTitle('Average E_{Rec} in HO tiles around tight L1 direction') #hCounter.SetMaximum(1.2) #hCounter.SetMinimum(5e-3) hCounter.Draw('colz') label = self.drawLabel() canvas.Update() setupPalette(hCounter) canvas.Update() #boxes = drawHoBoxes(canvas) self.storeCanvas(canvas,'eMaxCountsTightMuons') return canvas,label,hCounter
def createPlotPtVsQualityCode(gridSize): sourceHistogramsForGrid = { 1: 'correlation/L1MuonpTvsQCCentralFail', 2: 'correlation/L1MuonpTvsQC3x3Fail', 3: 'correlation/L1MuonpTvsQC5x5Fail' } histogramTitleDict = {1: 'Central', 2: '3x3', 3: '5x5'} histogram = fileHandler.getHistogram(sourceHistogramsForGrid.get(gridSize)) title = 'p_{T} vs. rejected QC (' + histogramTitleDict.get(gridSize) + ')' canvasTitle = 'cPtVsQualityCodes' + histogramTitleDict.get(gridSize) canvas = TCanvas(canvasTitle, 'cPtVsQualityCodes' + histogramTitleDict.get(gridSize), 800, 0, 800, 600) canvas.SetLogz() histogram.GetXaxis().SetRangeUser(0, 8) histogram.GetYaxis().SetRangeUser(-1, 160) histogram.SetStats(0) histogram.SetTitle(title) histogram.Scale(1, 'width') histogram.Draw('colz') label = drawLabelCmsPrivateSimulation() canvas.Update() setupPalette(histogram) canvas.Update() fileNameTrunk = 'plots/efficiency/ptVsQualityCode' + histogramTitleDict.get( gridSize) + 'Fail' canvas.SaveAs(fileNameTrunk + '.png') canvas.SaveAs(fileNameTrunk + '.pdf') histogram.Draw('lego2') canvas.Update() canvas.SaveAs(fileNameTrunk + '3D.png') canvas.SaveAs(fileNameTrunk + '3D.pdf') return canvas, label, histogram
def plotEavForTightMuons(self): canvas = TCanvas('canvasEavTightMuons','EAv Tight muons',800,800) canvas.cd().SetLogz() hSum = self.fileHandler.getHistogram('averageEnergy/averageEnergyAroundPointpatTightToL1Muons_SummedEnergy') hCounter = self.fileHandler.getHistogram('averageEnergy/averageEnergyAroundPointpatTightToL1Muons_Counter') hSum = setupEAvplot(hSum, hCounter,same=True,limitForAll=0.3) hSum.SetTitle('Average E_{Rec} in HO tiles around tight L1 direction') hSum.SetMaximum(1.2) hSum.SetMinimum(5e-3) hSum.Draw('colz') label = self.drawLabel() canvas.Update() setupPalette(hSum) canvas.Update() #boxes = drawHoBoxes(canvas) self.storeCanvas(canvas,'eAverageTightMuons') return canvas,hSum,label#,boxes
def plotEavForTightMuons(self): canvas = TCanvas('canvasEavTightMuons','EAv Tight muons',1200,1200) canvas.cd().SetLogz() hSum = self.fileHandler.getHistogram('averageEnergy/averageEnergyAroundPointpatTightToL1Muons_SummedEnergy') hCounter = self.fileHandler.getHistogram('averageEnergy/averageEnergyAroundPointpatTightToL1Muons_Counter') hSum = setupEAvplot(hSum, hCounter,same=True,limitForAll=0.3) hSum.SetTitle('Average E_{Rec} in HO tiles around tight L1 direction') hSum.SetMaximum(1.2) hSum.SetMinimum(5e-3) hSum.Draw('colz') label = self.drawLabel() canvas.Update() setupPalette(hSum) canvas.Update() #boxes = drawHoBoxes(canvas) self.storeCanvas(canvas,'eAverageTightMuons') return canvas,hSum,label#,boxes
def plotTightL1EtaPhiRatio(self): gL1Tight = self.fileHandler.getGraph('hoMuonAnalyzer/graphs/L1TightMuons') gL1Tight3x3 = self.fileHandler.getGraph('hoMuonAnalyzer/graphs/L1TightMuons3x3') halfPhiBinwidth = L1_PHI_BIN/2. hL1Tight = TH2D('hL1Tight','L1Tight',30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 144, -math.pi,math.pi) hL1Tight3x3 = TH2D('hL1Tight3x3','L1Tight3x3',30,-15*L1_ETA_BIN ,15*L1_ETA_BIN, 144, -math.pi,math.pi) hL1Tight = fillGraphIn2DHist(gL1Tight,hL1Tight) hL1Tight3x3 = fillGraphIn2DHist(gL1Tight3x3,hL1Tight3x3) hRatio = hL1Tight3x3.Clone('asdfasdf') hRatio.Divide(hL1Tight) c = TCanvas('2dMap') hRatio.SetTitle('Local Efficiency per tight L1 coordinate (3x3 Matching);#eta_{L1};#phi_{L1};#epsilon') hRatio.GetXaxis().SetRangeUser(-0.8,.8) hRatio.Draw('colz') hRatio.SetStats(0) c.Update() setupAxes(hRatio) setupPalette(hRatio) label = self.drawLabel() c.Update() self.storeCanvas(c, 'localTightL1Efficiency') c2 = TCanvas('projections') c2.Divide(2,1) c2.cd(1) hEta = hRatio.ProjectionX() hEta.Scale(1/float(144))#72 phi bins hEta.Draw() c2.cd(2) hPhi = hRatio.ProjectionY() hPhi.Scale(1/float(16))#16 eta bins, cutoff due to |eta| < 0.8 hPhi.Draw() return c,hRatio,label,c2,hEta,hPhi
def makeTimeVsEtaPlot(self,source,title = ""): canvas = TCanvas(source) canvas.SetRightMargin(.15) if title == "": title = source hist = TH2D(source,";i#eta;Time / ns;Entries",33,-16.5,16.5, 201,-100.5,100.5) graph = self.fileHandler.getGraph('graphs/timingSupport_' + source) fillGraphIn2DHist(graph, hist) hist.SetStats(0) hist.GetXaxis().SetRangeUser(-11,11) hist.GetYaxis().SetRangeUser(-60,60) hist.Draw('colz') canvas.Update() setupAxes(hist) setupPalette(hist,shiftBy=.05) canvas.Update() fractionGraph,counterDict = self.printFractionsPerIEta(graph) self.debug('Integral of plot %20s: %d' % (source,hist.Integral())) medianTofZero = (counterDict[9]['median'] + counterDict[11]['median'])/2. tofFunction = TF1('f','4*sqrt(1+ 1/(tan(2*atan(exp(-x*0.087/2.)))**2))/300000000.*1e9 - 13.3 + [0]',-10,10) tofFunction.SetParameter(0,medianTofZero) tofFunction.Draw('same') ### # Draw Boxes for the Intervals ### intervalBoxes = [] for index,item in enumerate(counterDict): iEta = index - 10 # Skip iEta 0 if iEta == 0: continue box = TBox(iEta - 0.5, item['median'] - 12.5, iEta + 0.5, item['median'] + 12.5) box.SetFillStyle(0) box.SetLineColor(colorRwthMagenta) box.SetLineWidth(2) box.Draw() intervalBoxes.append(box) return canvas,hist,fractionGraph,intervalBoxes,tofFunction
def plot3x3FailQualityCodes(self): c = TCanvas('cFailQC3x3','Fail QC 3x3',910,0,900,700) c.SetLogz() hist = self.fileHandler.getHistogram('hoMuonAnalyzer/qualityCode/L1Muon3x3Fail_QcVsPt') hist.SetStats(0) hist.Scale(1,'width') hist.Draw('colz') c.Update() setupPalette(hist) c.Update() label = None if self.data: label = drawLabelCmsPrivateData() else: label = drawLabelCmsPrivateSimulation() c.Update() return hist,c,label
def plotDeltaPhiVsL1Eta(self): canvas = TCanvas('cDeltaPhiVsL1Eta','DeltaPhiVsL1Eta',1200,1200) hist = self.fileHandler.getHistogram('correlation/shiftCheckDeltaPhiVsL1Eta' + self.key) hist.GetYaxis().SetRangeUser(-1,1) # hist.GetXaxis().SetRangeUser(-.5,.5) hist.GetXaxis().SetTitle('L1 #eta') hist.GetZaxis().SetTitle('#') hist.SetStats(0) hist.SetTitle('#Delta#phi vs. L1#eta') hist.Draw('colz') label = self.drawLabel() canvas.Update() setupAxes(hist) setupPalette(hist) canvas.Update() canvas.SaveAs('plots/deltaPhiVsL1Eta.pdf') return canvas,hist,label#,phiBorderLines,legend
def plotIEtaIPhiOnSameScales(self): canvas = TCanvas('cSameScales', 'same scales', 1900, 500) canvas.Divide(3, 1) canvas.cd(1).SetLogz() res1 = self.getIEtaIPhiPlot('hoRecHitsAboveThr') canvas.cd(2).SetLogz() res2 = self.getIEtaIPhiPlot('patToL1Muons3x3') res2.SetMaximum(res1.GetMaximum()) canvas.cd(3).SetLogz() res3 = self.getIEtaIPhiPlot('patTightToL1Muons3x3') res3.SetMaximum(res1.GetMaximum()) canvas.Update() res2.SetTitle('L1 #Rightarrow ' + res2.GetTitle()) res3.SetTitle('L1 Tight #Rightarrow ' + res3.GetTitle()) canvas.cd(1) setupPalette(res1) label1 = self.drawLabel() canvas.cd(1).Update() canvas.cd(2) setupPalette(res2) label2 = self.drawLabel() canvas.Update() canvas.cd(3) setupPalette(res3) label3 = self.drawLabel() canvas.Update() self.storeCanvas(canvas, "hoIEtaIPhiSameScales") return res1, res2, res3, canvas, label1, label2, label3
def plotBxidVsPtMatch(self): c = TCanvas('cBxidVsPtMatch','BxidVsPtMatch',800,1200) c.Divide(1,2) c.cd(1).SetLogz() hist = self.fileHandler.getHistogram('time/L1Muon3x3Match_BxIdVsPt') hist.SetStats(0) setupAxes(hist) hist.SetTitle('Successful matching in 3x3;p_{T} / GeV;BX ID;# entries') hist.GetYaxis().SetRangeUser(-3,3) histCopy = hist.DrawCopy('colz') c.Update() setupPalette(histCopy) c.Update() label = None if self.data: label = drawLabelCmsPrivateData() else: label = drawLabelCmsPrivateSimulation() c.cd(2).SetLogz() hist.Scale(1,'width') hist.SetTitle(hist.GetTitle() + ', by bin width') hist.GetZaxis().SetTitle('# entries / GeV') hist.Draw('colz') c.Update() setupPalette(hist) c.Update() labelBottom = None if self.data: labelBottom = drawLabelCmsPrivateData() else: labelBottom = drawLabelCmsPrivateSimulation() c.Update() c.SaveAs('plots/efficiencyWithTime/bxIdVsPt3x3Match.gif') return c, hist,label,labelBottom
def plotBxidVsPtMatch(self): c = TCanvas('cBxidVsPtMatch','BxidVsPtMatch',800,1200) c.Divide(1,2) c.cd(1).SetLogz() hist = self.fileHandler.getHistogram('hoMuonAnalyzer/time/L1Muon3x3Match_BxIdVsPt') hist.SetStats(0) setupAxes(hist) hist.SetTitle('Successful matching in 3x3;p_{T} / GeV;BX ID;# entries') hist.GetYaxis().SetRangeUser(-3,3) histCopy = hist.DrawCopy('colz') c.Update() setupPalette(histCopy) c.Update() label = None if self.data: label = drawLabelCmsPrivateData() else: label = drawLabelCmsPrivateSimulation() c.cd(2).SetLogz() hist.Scale(1,'width') hist.SetTitle(hist.GetTitle() + ', by bin width') hist.GetZaxis().SetTitle('# entries / GeV') hist.Draw('colz') c.Update() setupPalette(hist) c.Update() labelBottom = None if self.data: labelBottom = drawLabelCmsPrivateData() else: labelBottom = drawLabelCmsPrivateSimulation() c.Update() c.SaveAs('plots/efficiencyWithTime/bxIdVsPt3x3Match.gif') return c, hist,label,labelBottom
def plotIEtaIPhiOnSameScales(self): canvas = TCanvas('cSameScales','same scales',1900,500) canvas.Divide(3,1) canvas.cd(1).SetLogz() res1 = self.getIEtaIPhiPlot('hoRecHitsAboveThr') canvas.cd(2).SetLogz() res2 = self.getIEtaIPhiPlot('patToL1Muons3x3') res2.SetMaximum(res1.GetMaximum()) canvas.cd(3).SetLogz() res3 = self.getIEtaIPhiPlot('patTightToL1Muons3x3') res3.SetMaximum(res1.GetMaximum()) canvas.Update() res2.SetTitle('L1 #Rightarrow ' + res2.GetTitle()) res3.SetTitle('L1 Tight #Rightarrow ' + res3.GetTitle()) canvas.cd(1) setupPalette(res1) label1 = self.drawLabel() canvas.cd(1).Update() canvas.cd(2) setupPalette(res2) label2 = self.drawLabel() canvas.Update() canvas.cd(3) setupPalette(res3) label3 = self.drawLabel() canvas.Update() self.storeCanvas(canvas,"hoIEtaIPhiSameScales") return res1,res2,res3,canvas,label1,label2,label3
def plotDeltaPhiVsL1Eta(self): canvas = TCanvas('cDeltaPhiVsL1Eta', 'DeltaPhiVsL1Eta', 1200, 1200) hist = self.fileHandler.getHistogram( 'correlation/shiftCheckDeltaPhiVsL1Eta' + self.key) hist.GetYaxis().SetRangeUser(-1, 1) # hist.GetXaxis().SetRangeUser(-.5,.5) hist.GetXaxis().SetTitle('L1 #eta') hist.GetZaxis().SetTitle('#') hist.SetStats(0) hist.SetTitle('#Delta#phi vs. L1#eta') hist.Draw('colz') label = self.drawLabel() canvas.Update() setupAxes(hist) setupPalette(hist) canvas.Update() canvas.SaveAs('plots/deltaPhiVsL1Eta.pdf') return canvas, hist, label #,phiBorderLines,legend
def plotL1PhiVsHoPhi(self): canvas = TCanvas('cL1PhiVsHoPhi', 'L1PhiVsHoPhi', 1200, 1200) canvas.Divide(1, 2) canvas.cd(1) graph = self.fileHandler.getGraph('correlation/l1PhiVsHoPhi') graph.SetTitle('L1 #phi vs. HO #phi;HO #phi;L1 #phi') graph.SetMarkerStyle(2) setupAxes(graph) graph.Draw('AP') canvas.Update() canvas.cd(2) halfbinwidth = L1_PHI_BIN / 2. hist = TH2D('hL1PhiVsHoPhi', 'L1 Phi vs. iPhi', 289, -math.pi - halfbinwidth, math.pi + halfbinwidth, 289, -math.pi - halfbinwidth, math.pi + halfbinwidth) hist = fillGraphIn2DHist(graph, hist) hist.Draw('colz') canvas.Update() setupPalette(hist) canvas.Update() return canvas, graph, hist
def plot3x3MatchQualityCodesVsPt(self): c = TCanvas('cMatchQC3x3', 'Match QC 3x3', 0, 0, 900, 700) c.SetLogz() hist = self.fileHandler.getHistogram( 'qualityCode/L1Muon3x3Match_QcVsPt') hist.SetStats(0) hist.Scale(1, 'width') hist.Draw('colz') c.Update() setupPalette(hist) c.Update() label = self.drawLabel() c.Update() box = TBox(0, 6.5, 180, 7.5) box.SetLineColor(3) box.SetLineWidth(2) box.Draw() c.Update() return hist, c, label, box
def plotDeltaPhiVsL1Phi(self): canvas = TCanvas('cDeltaPhiVsL1Phi', 'DeltaPhiVsL1Phi', 1200, 1200) hist = self.fileHandler.getHistogram( 'correlation/shiftCheckDeltaPhiVsPhi') hist.GetYaxis().SetRangeUser(-1, 1) hist.GetXaxis().SetRangeUser(-.5, .5) hist.GetXaxis().SetTitle('L1 #phi') hist.GetZaxis().SetTitle('#') hist.SetStats(0) hist.SetTitle('#Delta#phi vs. L1#phi') setupAxes(hist) hist.Draw('colz') phiBorderLines = [] HO_BIN = math.pi / 36. for i in range(-31, 32): line = TLine(HO_BIN * i - HO_BIN / 2., -.6, HO_BIN * i - HO_BIN / 2., .6) line.SetLineWidth(2) # line.Draw() phiBorderLines.append(line) legend = TLegend(0.6, 0.8, 0.9, 0.85) legend.AddEntry(phiBorderLines[0], "HO Tile center", "e") #legend.Draw() label = self.drawLabel() canvas.Update() setupPalette(hist) canvas.Update() canvas.SaveAs('plots/deltaPhiVsL1Phi.pdf') return canvas, hist, label, phiBorderLines, legend
def plotEAveragePerWheel(self): canvas = TCanvas('cEAvPerWheel',"E Average per Wheel",1800,800) canvas.Divide(3,1) hM1Energy = self.fileHandler.getHistogram('averageEnergy/wh1m/averageEnergyAroundPoint' + self.key + '_wh-1SummedEnergy') hM1Counter = self.fileHandler.getHistogram('averageEnergy/wh1m/averageEnergyAroundPoint' + self.key + '_wh-1Counter') hM1Energy = setupEAvplot(hM1Energy, hM1Counter) hM1Energy.SetStats(0) h0Energy = self.fileHandler.getHistogram('averageEnergy/wh0/averageEnergyAroundPoint' + self.key + '_wh0SummedEnergy') h0Counter = self.fileHandler.getHistogram('averageEnergy/wh0/averageEnergyAroundPoint' + self.key + '_wh0Counter') h0Energy = setupEAvplot(h0Energy, h0Counter) h0Energy.SetStats(0) hP1Energy = self.fileHandler.getHistogram('averageEnergy/wh1p/averageEnergyAroundPoint' + self.key + '_wh1SummedEnergy') hP1Counter = self.fileHandler.getHistogram('averageEnergy/wh1p/averageEnergyAroundPoint' + self.key + '_wh1Counter') hP1Energy = setupEAvplot(hP1Energy, hP1Counter) hP1Energy.SetStats(0) canvas.cd(1).SetLogz() setupAxes(hM1Energy) hM1Energy.SetMaximum(1.2) hM1Energy.SetMinimum(5e-3) hM1Energy.Draw('colz') canvas.Update() setupPalette(hM1Energy) label1 = self.drawLabel() canvas.cd(2).SetLogz() setupAxes(h0Energy) h0Energy.SetMaximum(1.2) h0Energy.SetMinimum(5e-3) h0Energy.Draw('colz') #h0Counter.Draw('same,text') canvas.Update() setupPalette(h0Energy) label2 = self.drawLabel() canvas.cd(3).SetLogz() setupAxes(hP1Energy) hP1Energy.SetMaximum(1.2) hP1Energy.SetMinimum(5e-3) hP1Energy.Draw('colz') canvas.Update() setupPalette(hP1Energy) label3 = self.drawLabel() canvas.Update() self.storeCanvas(canvas,'eAveragePerWheel') return hM1Energy,canvas,h0Energy,hP1Energy,h0Counter,label1,label2,label3
def plotEavPerWheelForTightMuons(self): canvas = TCanvas('canvasEavPerWheelTightMuons','EAv Per Wheel Tight muons',1800,800) canvas.Divide(3,1) hM1Energy = self.fileHandler.getHistogram('averageEnergy/wh1m/averageEnergyAroundPointpatTightToL1Muons_wh-1SummedEnergy') hM1Counter = self.fileHandler.getHistogram('averageEnergy/wh1m/averageEnergyAroundPointpatTightToL1Muons_wh-1Counter') hM1Energy = setupEAvplot(hM1Energy, hM1Counter) hM1Energy.SetStats(0) h0Energy = self.fileHandler.getHistogram('averageEnergy/wh0/averageEnergyAroundPointpatTightToL1Muons_wh0SummedEnergy') h0Counter = self.fileHandler.getHistogram('averageEnergy/wh0/averageEnergyAroundPointpatTightToL1Muons_wh0Counter') h0Energy = setupEAvplot(h0Energy, h0Counter) h0Energy.SetStats(0) hP1Energy = self.fileHandler.getHistogram('averageEnergy/wh1p/averageEnergyAroundPointpatTightToL1Muons_wh1SummedEnergy') hP1Counter = self.fileHandler.getHistogram('averageEnergy/wh1p/averageEnergyAroundPointpatTightToL1Muons_wh1Counter') hP1Energy = setupEAvplot(hP1Energy, hP1Counter) hP1Energy.SetStats(0) canvas.cd(1).SetLogz() setupAxes(hM1Energy) hM1Energy.SetMaximum(1.2) hM1Energy.SetMinimum(5e-3) hM1Energy.Draw('colz') canvas.Update() setupPalette(hM1Energy) label1 = self.drawLabel() canvas.cd(2).SetLogz() setupAxes(h0Energy) h0Energy.SetMaximum(1.2) h0Energy.SetMinimum(5e-3) h0Energy.Draw('colz') canvas.Update() setupPalette(h0Energy) label2 = self.drawLabel() canvas.cd(3).SetLogz() setupAxes(hP1Energy) hP1Energy.SetMaximum(1.2) hP1Energy.SetMinimum(5e-3) hP1Energy.Draw('colz') canvas.Update() setupPalette(hP1Energy) label3 = self.drawLabel() canvas.Update() self.storeCanvas(canvas,'eAveragePerWheelTightMuons') return hM1Energy,canvas,h0Energy,hP1Energy,h0Counter,label1,label2,label3