def drawSave(h, updatePaletteStyle=False): h.draw() if updatePaletteStyle: histograms.updatePaletteStyle(h.histoMgr.getHistos()[0].getRootHisto()) histograms.addCmsPreliminaryText() histograms.addEnergyText() h.save()
def drawPlot(plot, xlabel, ylabel="Trigger and ID efficiency", cutLine=None, updatePaletteStyle=False, addText=True): if cutLine != None: lst = cutLine if not isinstance(lst, list): lst = [lst] for line in lst: p.addCutBoxAndLine(line, box=False, line=True) plot.frame.GetXaxis().SetTitle(xlabel) plot.frame.GetYaxis().SetTitle(ylabel) plot.draw() if updatePaletteStyle: histograms.updatePaletteStyle( p.histoMgr.getHistos()[0].getRootHisto()) if lumi != None: plot.setLuminosity(lumi) plot.addStandardTexts() if addText: l.DrawLatex(0.2, 0.4, trig) l.DrawLatex(0.2, 0.35, runs) plot.save()
def plot(self, datasets, an, t="Met", q="Et", log=False): rebin = self.rebin[q] xlabel = self.xlabels[q] h = Plot(datasets, an, [t+"_"+q, t+"Original_"+q]) h.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(rebin)) ylabel = self.ylabel % h.binWidth() if q != "Phi": ylabel += "GeV" h.histoMgr.setHistoLegendLabelMany({t+"_"+q: "Embedded", t+"Original_"+q: "Original"}) h.createFrame(t+"_"+q) h.frame.GetXaxis().SetTitle(xlabel) h.frame.GetYaxis().SetTitle(ylabel) h.setLegend(createLegend2()) drawSave(h) if log: h.createFrame(t+"_"+q+"_log", ymin=0.1, ymaxfactor=2) ROOT.gPad.SetLogy(True) h.frame.GetXaxis().SetTitle(xlabel) h.frame.GetYaxis().SetTitle(ylabel) h.setLegend(createLegend2()) drawSave(h) if t == "Met" and q == "Et": name = t+"Original_"+q+"_AfterCut" h = Plot(datasets, an, [name]) h.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(rebin)) h.createFrame(name) h.frame.GetXaxis().SetTitle("Original "+xlabel) h.frame.GetYaxis().SetTitle(ylabel) drawSave(h) xmin, ymin = [0]*2 xmax, ymax = [200]*2 #ymin = 60 if q in ["X", "Y"]: ymin = -ymax/2 ymax = ymax/2 xmin = -xmax/2 xmax = xmax/2 elif q == "Phi": xmin, ymin = [-3.5]*2 xmax, ymax = [3.5]*2 low = max(xmin, ymin) high = min(xmax, ymax) line = ROOT.TGraph(2, array("d", [low, high]), array("d", [low, high])) line.SetLineStyle(2) line.SetLineWidth(2) if q == "Phi": rebin = rebin*5 style.setWide(True) name = t+"Original_"+t+"_"+q h = Plot(datasets, an, [name]) h.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin2D(rebin, rebin)) #h.histoMgr.forEachHisto(lambda h: h.getRootHisto().SetAxisRange(ymin, ymax, "Y")) h.createFrame(name, xmin=xmin, ymin=ymin, xmax=xmax, ymax=ymax) h.frame.GetXaxis().SetTitle("Original "+xlabel) h.frame.GetYaxis().SetTitle("Embedded "+xlabel) h.histoMgr.setHistoDrawStyleAll("COLZ") h.draw() line.Draw("L") histograms.updatePaletteStyle(h.histoMgr.getHistos()[0].getRootHisto()) histograms.addCmsPreliminaryText() histograms.addEnergyText() h.save() h.createFrame(name+"_log", xmin=xmin, ymin=ymin, xmax=xmax, ymax=ymax) h.frame.GetXaxis().SetTitle("Original "+xlabel) h.frame.GetYaxis().SetTitle("Embedded "+xlabel) h.histoMgr.setHistoDrawStyleAll("COLZ") ROOT.gPad.SetLogz(True) h.draw() line.Draw("L") histograms.updatePaletteStyle(h.histoMgr.getHistos()[0].getRootHisto()) histograms.addCmsPreliminaryText() histograms.addEnergyText() h.save() style.setWide(False)
def drawSave(h, updatePaletteStyle=False): h.draw() if updatePaletteStyle: histograms.updatePaletteStyle(h.histoMgr.getHistos()[0].getRootHisto()) h,addStandardTexts() h.save()
def plot(self, datasets, an, t="Met", q="Et", log=False): rebin = self.rebin[q] xlabel = self.xlabels[q] h = Plot(datasets, an, [t + "_" + q, t + "Original_" + q]) h.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(rebin)) ylabel = self.ylabel % h.binWidth() if q != "Phi": ylabel += "GeV" h.histoMgr.setHistoLegendLabelMany({ t + "_" + q: "Embedded", t + "Original_" + q: "Original" }) h.createFrame(t + "_" + q) h.frame.GetXaxis().SetTitle(xlabel) h.frame.GetYaxis().SetTitle(ylabel) h.setLegend(createLegend2()) drawSave(h) if log: h.createFrame(t + "_" + q + "_log", ymin=0.1, ymaxfactor=2) ROOT.gPad.SetLogy(True) h.frame.GetXaxis().SetTitle(xlabel) h.frame.GetYaxis().SetTitle(ylabel) h.setLegend(createLegend2()) drawSave(h) if t == "Met" and q == "Et": name = t + "Original_" + q + "_AfterCut" h = Plot(datasets, an, [name]) h.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(rebin)) h.createFrame(name) h.frame.GetXaxis().SetTitle("Original " + xlabel) h.frame.GetYaxis().SetTitle(ylabel) drawSave(h) xmin, ymin = [0] * 2 xmax, ymax = [200] * 2 #ymin = 60 if q in ["X", "Y"]: ymin = -ymax / 2 ymax = ymax / 2 xmin = -xmax / 2 xmax = xmax / 2 elif q == "Phi": xmin, ymin = [-3.5] * 2 xmax, ymax = [3.5] * 2 low = max(xmin, ymin) high = min(xmax, ymax) line = ROOT.TGraph(2, array("d", [low, high]), array("d", [low, high])) line.SetLineStyle(2) line.SetLineWidth(2) if q == "Phi": rebin = rebin * 5 style.setWide(True) name = t + "Original_" + t + "_" + q h = Plot(datasets, an, [name]) h.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin2D(rebin, rebin)) #h.histoMgr.forEachHisto(lambda h: h.getRootHisto().SetAxisRange(ymin, ymax, "Y")) h.createFrame(name, xmin=xmin, ymin=ymin, xmax=xmax, ymax=ymax) h.frame.GetXaxis().SetTitle("Original " + xlabel) h.frame.GetYaxis().SetTitle("Embedded " + xlabel) h.histoMgr.setHistoDrawStyleAll("COLZ") h.draw() line.Draw("L") histograms.updatePaletteStyle(h.histoMgr.getHistos()[0].getRootHisto()) h.addStandardTexts() h.save() h.createFrame(name + "_log", xmin=xmin, ymin=ymin, xmax=xmax, ymax=ymax) h.frame.GetXaxis().SetTitle("Original " + xlabel) h.frame.GetYaxis().SetTitle("Embedded " + xlabel) h.histoMgr.setHistoDrawStyleAll("COLZ") ROOT.gPad.SetLogz(True) h.draw() line.Draw("L") histograms.updatePaletteStyle(h.histoMgr.getHistos()[0].getRootHisto()) h.addStandardTexts() h.save() style.setWide(False)
def drawSave(h, updatePaletteStyle=False): h.draw() if updatePaletteStyle: histograms.updatePaletteStyle(h.histoMgr.getHistos()[0].getRootHisto()) h, addStandardTexts() h.save()