def createMuon2Plot(dset, name, postfix): datasetName = dset.getName() treeDraw = dataset.TreeDraw("tree", selection="Obj2Type == 3 && LeptonVetoStatus == 0 && (TauIDStatus == 1 || TauIDStatus == 2 || TauIDStatus == 3)") # nothing passes lepton veto tdFullIsolation = treeDraw.clone(varexp="(muon2_f_chargedHadronIso + max(muon2_f_photonIso+muon2_f_neutralHadronIso-0.5*muon2_f_puChargedHadronIso, 0))/muon2_p4.Pt() >>tmp(50, 0, 0.5)") tdChargedIsolation = treeDraw.clone(varexp="(muon2_f_chargedHadronIso)/muon2_p4.Pt() >>tmp(50, 0, 0.5)") tdNeutralIsolation = treeDraw.clone(varexp="(max(muon2_f_photonIso+muon2_f_neutralHadronIso-0.5*muon2_f_puChargedHadronIso, 0))/muon2_p4.Pt() >>tmp(50, 0, 0.5)") h = dset.getDatasetRootHisto(tdFullIsolation).getHistogram() p = plots.PlotBase([histograms.Histo(h, "histo")]) p.createFrame("muon2fullIsolation_"+datasetName+"_"+name+"_"+postfix) p.draw() p.save() h = dset.getDatasetRootHisto(tdChargedIsolation).getHistogram() integralAll = h.Integral(0, h.GetNbinsX()+1) integral = h.Integral(0, h.FindBin(0.1)+1) p = plots.PlotBase([histograms.Histo(h, "histo")]) p.appendPlotObject(histograms.PlotText(0.5, 0.55, "%d events in total" % int(integralAll))) p.appendPlotObject(histograms.PlotText(0.5, 0.5, "%d events in <= 0.1" % int(integral))) p.createFrame("muon2chargedIsolation_"+datasetName+"_"+name+"_"+postfix) p.draw() p.save() h = dset.getDatasetRootHisto(tdNeutralIsolation).getHistogram() p = plots.PlotBase([histograms.Histo(h, "histo")]) p.createFrame("muon2neutralIsolation_"+datasetName+"_"+name+"_"+postfix) p.draw() p.save()
def createPlot(graph_, **kwargs): if isinstance(graph_, ROOT.TH1): defaults = {"legendStyle": "l"} defaults.update(kwargs) graph_.GetZaxis().SetTitle("") #### return plots.PlotBase([histograms.HistoBase(graph_, "efficiency", **defaults)]) return plots.PlotBase( [histograms.Histo(graph_, "efficiency", **defaults)]) else: defaults = {"drawStyle": "EP"} defaults.update(kwargs) return plots.PlotBase( [histograms.HistoGraph(graph_, "efficiency", **defaults)])
def plotInRanges(th1, optMode): xaxis = th1.GetXaxis() xaxis.SetBinLabel(1, "41-50") xaxis.SetBinLabel(2, "50-60") xaxis.SetBinLabel(3, "60-70") xaxis.SetBinLabel(4, "70-80") xaxis.SetBinLabel(5, "80-100") xaxis.SetBinLabel(6, "100-120") xaxis.SetBinLabel(7, "> 120") def foo(p): xaxis = p.getFrame().GetXaxis() xaxis.LabelsOption("u") xaxis.SetTitleOffset(xaxis.GetTitleOffset() * 1.4) p.getPad().SetBottomMargin(0.16) p = plots.PlotBase([th1]) p.setLuminosity("19.7") h = p.histoMgr.getHisto("weights") h.setDrawStyle("PE") drawPlot1(p, "weights_" + optMode.replace("OptQCDTailKiller", ""), xlabel="p_{T}^{#tau_{h}} bin (GeV)", customizeBeforeDraw=foo)
def plotHisto(self, histo, canvasName): plot = plots.PlotBase() plot.histoMgr.appendHisto(histograms.Histo(histo, histo.GetName())) plot.createFrame(canvasName + self.label, opts={ "ymin": 0.1, "ymaxfactor": 2. }) histograms.addCmsPreliminaryText() histograms.addEnergyText() histograms.addLuminosityText(x=None, y=None, lumi=self.lumi) plot.getPad().SetLogy(True) integralValue = int(0.5 + histo.Integral(0, histo.GetNbinsX(), "width")) print histo.GetName(), "Integral", histo.Integral( 0, histo.GetNbinsX(), "width") histograms.addText(0.4, 0.7, "Integral = %s ev" % integralValue) match = re.search("aseline", histo.GetName()) if match: self.nBaseQCD = integralValue match = re.search("nverted", histo.GetName()) if match: self.nInvQCD = integralValue self.plotIntegral(plot, histo.GetName())
def createTH2Plot(name, datasetName, normalizeToOne=False): # Obtain the Dataset object for the given dataset dset = datasets.getDataset(datasetName) # Pick the luminosity of data if not in MC-only mode lumi = mcOnlyLumi if datasets.hasDataset("Data") and not mcOnly: lumi = datasets.getDataset("Data").getLuminosity() # Obtain a DatasetRootHisto wrapper object for the TH2 # histogram, create a plot object, and if the Dataset is MC, # normalize it to the luminosity drh = dset.getDatasetRootHisto(name) p = plots.PlotBase([drh]) if normalizeToOne: p.histoMgr.normalizeToOne() p.setDrawOptions(addLuminosityText=False) else: if dset.isMC(): p.histoMgr.normalizeMCToLuminosity(lumi) p.histoMgr.setHistoDrawStyleAll("COLZ") # Example how to set drawing options on the plot object # itself. These override the default, and the options given in # drawPlot() override these p.setDrawOptions( ratio=False, stackMCHistograms=False, addMCUncertainty=False, #canvasOpts={"addWidth": None} # example of how do disable automatic canvas size modification in the presence of COLZ ) return p
def plotVariableWidth(th1Inp): bins = [0, 41, 50, 60, 70, 80, 100, 120, 200] th1 = ROOT.TH1F("factors2", "factors2", len(bins) - 1, array.array("d", bins)) aux.copyStyle(th1Inp, th1) for i in xrange(2, len(bins)): th1.SetBinContent(i, th1Inp.GetBinContent(i - 1)) th1.SetBinError(i, th1Inp.GetBinError(i - 1)) def foo(p): xaxis = p.getFrame().GetXaxis() xaxis.LabelsOption("u") xaxis.SetTitleOffset(xaxis.GetTitleOffset() * 1.4) p.getPad().SetBottomMargin(0.16) p = plots.PlotBase([th1]) p.setLuminosity("19.7") h = p.histoMgr.getHisto("factors2") h.setDrawStyle("PE") drawPlot(p, "qcd_normalization_varwidth", xlabel="#tau_{h} ^{}p_{T} (GeV)", errorBarsX=True)
def doSinglePlot(histograms, myDir, histoName, luminosity, suffix): plot = plots.PlotBase(histograms) plot.setLuminosity(luminosity) plot.histoMgr.forEachHisto(lambda h: h.getRootHisto().SetLineWidth(3)) mySplit = histoName.split("/") histoNameShort = mySplit[len(mySplit) - 1] myPlotName = "%s/signalShapes_%s_%s" % (myDir, suffix, histoNameShort) print myPlotName myParams = {} myParams["ylabel"] = "Events" if histoName.startswith("shape"): myParams["log"] = False else: myParams["log"] = True #myParams["opts2"] = {"ymin": 0.0, "ymax":2.0} #myParams["opts"] = {"ymin": 0.0, "ymax":1.0} #myParams["ratio"] = True #myParams["ratioType"] = "errorScale" #myParams["ratioYlabel"] = "Var./Nom." myParams["cmsText"] = "CMS simulation" myParams["addLuminosityText"] = True myParams["moveLegend"] = {"dx": -0.05, "dy": 0.0} #myParams["createLegend"] = None #myParams["divideByBinWidth"] = True plots.drawPlot(plot, myPlotName, **myParams)
def doSinglePlot(histograms, myDir, histoName, luminosity): plot = plots.PlotBase(histograms) plot.setLuminosity(luminosity) plot.histoMgr.forEachHisto(lambda h: h.getRootHisto().SetLineWidth(3)) mySplit = histoName.split("/") histoName = mySplit[len(mySplit) - 1] myPlotName = "%s/QCDInv_Purity_%s" % (myDir, histoName) print myPlotName myParams = {} if "EWKGenuineTaus" in histoName: myParams["ylabel"] = "Fake #tau purity" myParams["moveLegend"] = {"dx": -0.05, "dy": -0.46} else: myParams["ylabel"] = "QCD purity" myParams["moveLegend"] = {"dx": -0.05, "dy": 0.0} myParams["xlabel"] = "m_{T}(tau,MET), GeV" myParams["log"] = False #myParams["opts2"] = {"ymin": 0.0, "ymax":2.0} myParams["opts"] = {"ymin": 0.0, "ymax": 1.2} #myParams["ratio"] = True #myParams["ratioType"] = "errorScale" #myParams["ratioYlabel"] = "Var./Nom." #myParams["cmsText"] = "CMS" myParams["addLuminosityText"] = True #myParams["createLegend"] = None #myParams["divideByBinWidth"] = True myParams["errorBarsX"] = True plots.drawPlot(plot, myPlotName, **myParams)
def doPlotsWTauMuRatio(dsetMgr, selectionName, ratios, unweighted, fitFunction): prefix = era + "_" + selectionName + "_fitFunction%d" % fitFunction + unweighted + "_" st = [s.clone() for s in styles.getStyles()] st[0].marker = 33 st[1].marker = 26 st[2].marker = 32 st = [ styles.StyleCompound(styles=[s, styles.StyleMarker(markerSize=1.5)]) for s in st ] # Do clone to get rid of statistics box p = plots.PlotBase([x[0].Clone() for x in ratios]) p.setEnergy(dsetMgr.getEnergies()) p.histoMgr.setHistoDrawStyleAll("P") p.histoMgr.setHistoLegendStyleAll("P") p.histoMgr.forEachHisto(styles.Generator(st)) for i, x in enumerate(ratios): fitLine = x[1] st[i].apply(fitLine) p.appendPlotObject(fitLine) def customize(plot): xmin = plot.frame.GetXaxis().GetXmin() xmax = plot.frame.GetXaxis().GetXmax() val = 1 l = ROOT.TLine(xmin, val, xmax, val) l.SetLineWidth(2) l.SetLineColor(ROOT.kRed) l.SetLineStyle(2) plot.prependPlotObject(l) val = 1 - 0.038479 l = ROOT.TLine(xmin, val, xmax, val) l.SetLineWidth(2) l.SetLineColor(ROOT.kBlue) l.SetLineStyle(4) plot.prependPlotObject(l) plot.appendPlotObject( histograms.PlotText(0.18, 0.57, "0.038", size=18, color=ROOT.kBlue)) plots.drawPlot(p, prefix + "WMuFraction", "Muon p_{T} (GeV/c)", ylabel="W#rightarrow#mu fraction", opts={ "ymin": 0.9, "ymax": 1.02 }, moveLegend={ "dh": -0.15, "dx": -0.5 }, customizeBeforeDraw=customize)
def sumHistoBins(datasets,histonames,newname="",newtitle="",rebin = 1): if len(histonames) == 0: print "No histograms to sum, exiting.." sys.exit() histos = [] for histoname in histonames: histo_tmp = plots.PlotBase([datasets.getDataset("Data").getDatasetRootHisto(histoname)]) histo_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(rebin)) histo = histo_tmp.histoMgr.getHisto("Data").getRootHisto().Clone() ptbin = binFromTitle(histo.GetTitle()) if not ptbin in QCDInvertedNormalization.keys(): print "Key",ptbin,"not found in QCDInvertedNormalization." print "Available keys:",QCDInvertedNormalization.keys() continue histo.Scale(QCDInvertedNormalization[ptbin]) histoEWK_tmp = plots.PlotBase([datasets.getDataset("EWK").getDatasetRootHisto(histoname)]) histoEWK_tmp.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) histoEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(rebin)) histoEWK = histoEWK_tmp.histoMgr.getHisto("EWK").getRootHisto().Clone() histoEWK.Scale(QCDInvertedNormalization[ptbin+"EWK"]) histo.Add(histoEWK, -1) histos.append(histo) sum = histos[0].Clone("sum") if len(newname)>0: sum.SetName(newname) if len(newtitle)>0: sum.SetTitle(newtitle) sum.Reset() for histo in histos: sum.Add(histo) return sum
def createDrawPlot(name, h): h.SetMarkerSize(800) p = plots.PlotBase([histograms.Histo(h, "histo", drawStyle="TEXT")]) p.createFrame(name, opts={"ymaxfactor": 1, "nbinsx": h.GetNbinsX(), "nbinsy": h.GetNbinsY(), }) for bin in xrange(1, h.GetNbinsX()+1): p.frame.GetXaxis().SetBinLabel(bin, h.GetXaxis().GetBinLabel(bin)) for bin in xrange(1, h.GetNbinsY()+1): p.frame.GetYaxis().SetBinLabel(bin, h.GetYaxis().GetBinLabel(bin)) p.draw() p.save()
def foo(p): xaxis = p.getFrame().GetXaxis() xaxis.LabelsOption("u") xaxis.SetTitleOffset(xaxis.GetTitleOffset() * 1.4) p.getPad().SetBottomMargin(0.16) p = plots.PlotBase([th1]) p.setLuminosity("19.7") h = p.histoMgr.getHisto("factors2") h.setDrawStyle("PE") drawPlot(p, "qcd_normalization_varwidth", xlabel="#tau_{h} ^{}p_{T} (GeV)", errorBarsX=True)
def plotDataEwkDiff(mT, name): data = dataEwkDiff(mT, name) data.SetName("Data-EWK") # Draw the subtracted plot plot = plots.PlotBase([data]) plot.createFrame(name, opts={"ymin": 1e-1, "ymaxfactor": 10}) plot.frame.GetXaxis().SetTitle("MET (GeV)") plot.frame.GetYaxis().SetTitle("Data - EWK") # Set Y axis to logarithmic plot.getPad().SetLogy(True) plot.draw() # Add the various texts to plot.addStandardTexts() plot.save()
def plot(datasets): # datasetName = "TTJets_TuneZ2_Summer11" # datasetName = "TTToHplusBWB_M120_Summer11" datasetName = "WJets_TuneZ2_Summer11" den_selection = "jets_p4.Pt()>30 && ( abs(jets_flavour) < 4 || jets_flavour > 20)" # den_selection = "jets_p4.Pt()>30" num_selection = den_selection + "&&jets_btag>1.7" ds = datasets.getDataset(datasetName) den = ds.getDatasetRootHisto( treeDraw.clone(varexp="jets_p4.Pt()>>dist1(100,0.,500.)", selection=den_selection)).getHistogram() num = ds.getDatasetRootHisto( treeDraw.clone(varexp="jets_p4.Pt()>>dist2(100,0.,500.)", selection=num_selection)).getHistogram() canvas = ROOT.TCanvas("canvas", "", 500, 700) canvas.Divide(1, 3) canvas.cd(1) den.Draw() canvas.cd(2) num.Draw() canvas.cd(3) # eff = ROOT.TEfficiency(num,den) eff = num.Clone() eff.Divide(den) eff.Draw() canvas.Print("canvas.C") plot = plots.PlotBase() plot.histoMgr.appendHisto(histograms.Histo(eff, eff.GetName())) plot.createFrame("BtaggingEff", opts={"ymin": 0.1, "ymaxfactor": 2.}) plot.frame.GetXaxis().SetTitle("jet E_{T} (GeV)") plot.frame.GetYaxis().SetTitle("B-tagging eff.") histograms.addText(0.2, 0.8, "MC: " + datasetName, 25) plot.addStandardTexts() plot.draw() plot.save()
def dataEwkDiff(mT): # Get the normalized TH1 histograms # Clone the data one, because we subtract the EWK from it data = mT.histoMgr.getHisto("Data").getRootHisto().Clone("Data") ewk = mT.histoMgr.getHisto("EWK").getRootHisto() # Subtract ewk from data data.Add(ewk, -1) data.SetName("Data-EWK") # Draw the subtracted plot plot = plots.PlotBase([data]) plot.createFrame("transverseMass_data-ewk") plot.frame.GetXaxis().SetTitle("m_{T}(#tau, MET) (GeV)") plot.frame.GetYaxis().SetTitle("Data - EWK") plot.draw() plot.save()
def main(): if len(sys.argv) < 2: usage() dirs = [] dirs.append(sys.argv[1]) datasets = dataset.getDatasetsFromMulticrabDirs(dirs, dataEra=dataEra, searchMode=searchMode, analysisName=analysis) datasets.loadLuminosities() datasets.updateNAllEventsToPUWeighted() plots.mergeRenameReorderForDataMC(datasets) datasets.merge("EWK", ["TTJets", "WJets", "DYJetsToLL", "SingleTop", "Diboson"]) style = tdrstyle.TDRStyle() plot = plots.PlotBase() legends = {} name_re = re.compile("SelectedTau_pT_(?P<name>\S+)") for i, histo in enumerate(HISTONAMES): plot.histoMgr.appendHisto(purityGraph(i, datasets, histo)) name = histo match = name_re.search(histo) if match: name = match.group("name") legends["Purity%s" % i] = name plot.createFrame("purity", opts={"xmin": 40, "ymin": 0., "ymax": 1.2}) plot.frame.GetXaxis().SetTitle("tau p_{T} (GeV/c)") plot.frame.GetYaxis().SetTitle("Purity") plot.setEnergy(datasets.getEnergies()) plot.setLuminosity(datasets.getDataset("Data").getLuminosity()) plot.histoMgr.setHistoLegendLabelMany(legends) plot.setLegend(histograms.createLegend(0.6, 0.3, 0.8, 0.4)) plot.addStandardTexts() plot.draw() plot.save()
def plotDataEwkDiff(mT, name): data = dataEwkDiff(mT, name) # Draw the subtracted plot plot = plots.PlotBase() plot.histoMgr.appendHisto(histograms.Histo(data, "Data-EWK")) plot.createFrame(name, opts={"ymin": 1e-1, "ymaxfactor": 10}) plot.frame.GetXaxis().SetTitle("MET (GeV)") plot.frame.GetYaxis().SetTitle("Data - EWK") # Set Y axis to logarithmic plot.getPad().SetLogy(True) plot.draw() # Add the various texts to histograms.addCmsPreliminaryText() histograms.addEnergyText() # plot.addLuminosityText() plot.save()
def doPlotRecoMu2(quantity, step, **kwargs): if step != "": step = step + "_" drh = muonDataset.getDatasetRootHisto( ntupleCacheMuon.histogram("recomuon_" + step + quantity)) p = plots.PlotBase([drh]) p.histoMgr.normalizeMCToLuminosity(mcLumi) p.histoMgr.setHistoDrawStyleAll("COLZ") args = {"opts": {"ymin": -1, "ymax": 1}} args.update(kwargs) global pc pc += 1 plots.drawPlot(p, ("%02d_recogenmuon_" % pc) + step + quantity, addLuminosityText=True, createLegend=None, backgroundColor=ROOT.kGray, **args)
def mtComparison(datasets): mt = plots.PlotBase([ datasets.getDataset("TTToHplus_M80").getDatasetRootHisto( analysis + "/transverseMass"), # datasets.getDataset("TTToHplus_M90").getDatasetRootHisto(analysis+"/transverseMass"), # datasets.getDataset("TTToHplus_M100").getDatasetRootHisto(analysis+"/transverseMass"), datasets.getDataset("TTToHplus_M120").getDatasetRootHisto( analysis + "/transverseMass"), # datasets.getDataset("TTToHplus_M140").getDatasetRootHisto(analysis+"/transverseMass"), # datasets.getDataset("TTToHplus_M150").getDatasetRootHisto(analysis+"/transverseMass"), # datasets.getDataset("TTToHplus_M155").getDatasetRootHisto(analysis+"/transverseMass"), datasets.getDataset("TTToHplus_M160").getDatasetRootHisto( analysis + "/transverseMass"), ]) mt.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mt._setLegendStyles() mt._setLegendLabels() # mt.histoMgr.setHistoDrawStyleAll("P") rtauGen(mt, "transverseMass_vs_mH", rebin=20)
def plotEfficiency(datasets, datasetNames, allPath, passedPath, name, xlabel, rebinBins=None, **kwargs): if mcOnly: return def rebin(h): return h.Rebin( len(rebinBins) - 1, h.GetName(), array.array("d", rebinBins)) for dname in datasetNames: dset = datasets.getDataset(dname) allHisto = dset.getDatasetRootHisto(allPath).getHistogram() passedHisto = dset.getDatasetRootHisto(passedPath).getHistogram() if allHisto.Integral() < 1: continue if rebinBins != None: allHisto = rebin(allHisto) passedHisto = rebin(passedHisto) eff = ROOT.TGraphAsymmErrors(passedHisto, allHisto, "cp") # 0.683 cl is default p = plots.PlotBase([histograms.HistoGraph(eff, dname, "p", "P")]) if dset.isData(): p.setLuminosity(dset.getLuminosity()) opts = {"ymin": 0.0, "ymax": 1.1} plots.drawPlot(p, name + "_" + dname, xlabel, addLuminosityText=dset.isData(), opts=opts, **kwargs)
def MetComparison(datasets): mt = plots.PlotBase(getHistos(datasets,"MetNoJetInHole", "MetJetInHole")) # mt.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) mt._setLegendStyles() st1 = styles.StyleCompound([styles.styles[2]]) st2 = styles.StyleCompound([styles.styles[1]]) st1.append(styles.StyleLine(lineWidth=3)) st2.append(styles.StyleLine(lineStyle=2, lineWidth=3)) mt.histoMgr.forHisto("MetNoJetInHole", st1) mt.histoMgr.forHisto("MetJetInHole", st2) mt.histoMgr.setHistoLegendLabelMany({ "MetNoJetInHole": "Jets outside dead cells", "MetJetInHole": "Jets within dead cells" }) # mt.histoMgr.setHistoDrawStyleAll("P") mt.appendPlotObject(histograms.PlotText(300, 300, "p_{T}^{jet} > 50 GeV/c", size=20)) xlabel = "PF E_{T}^{miss} (GeV)" ylabel = "Events / %.2f" plots.drawPlot(mt, "MetComparison", xlabel=xlabel, ylabel=ylabel, rebinX=2, log=True, createLegend={"x1": 0.6, "y1": 0.75, "x2": 0.8, "y2": 0.9}, ratio=False, opts2={"ymin": 0.5, "ymax": 1.5})
def plotInRanges2(th1_list, optMode): xaxis = th1_list[0].GetXaxis() xaxis.SetBinLabel(1, "41-50") xaxis.SetBinLabel(2, "50-60") xaxis.SetBinLabel(3, "60-70") xaxis.SetBinLabel(4, "70-80") xaxis.SetBinLabel(5, "80-100") xaxis.SetBinLabel(6, "100-120") xaxis.SetBinLabel(7, "> 120") def foo(p): xaxis = p.getFrame().GetXaxis() xaxis.LabelsOption("u") xaxis.SetTitleOffset(xaxis.GetTitleOffset() * 1.4) p.getPad().SetBottomMargin(0.16) p = plots.PlotBase(th1_list) p.setLuminosity("19.7") p.histoMgr.setHistoLegendStyleAll("F") hewk = p.histoMgr.getHisto("EWK+t#bar{t} no #tau_{h}") hewk.setDrawStyle("PE") hewk.setLegendStyle("P") hqcd = p.histoMgr.getHisto("Multijet") hqcd.setDrawStyle("PE") hqcd.setLegendStyle("P") hfake = p.histoMgr.getHisto("Mis-ID. #tau_{h}") hfake.setDrawStyle("PE") hfake.setLegendStyle("P") drawPlot2(p, "frp_" + optMode.replace("OptQCDTailKiller", ""), xlabel="p_{T}^{#tau_{h}} bin (GeV)", customizeBeforeDraw=foo)
def plotInRanges(th1): xaxis = th1.GetXaxis() xaxis.SetBinLabel(1, "41-50") xaxis.SetBinLabel(2, "50-60") xaxis.SetBinLabel(3, "60-70") xaxis.SetBinLabel(4, "70-80") xaxis.SetBinLabel(5, "80-100") xaxis.SetBinLabel(6, "100-120") xaxis.SetBinLabel(7, "> 120") def foo(p): xaxis = p.getFrame().GetXaxis() xaxis.LabelsOption("u") xaxis.SetTitleOffset(xaxis.GetTitleOffset() * 1.4) p.getPad().SetBottomMargin(0.16) p = plots.PlotBase([th1]) p.setLuminosity("19.7") h = p.histoMgr.getHisto("factors") h.setDrawStyle("PE") drawPlot(p, "qcd_normalization", xlabel="p_{T}^{#tau_{h}} bin (GeV)", customizeBeforeDraw=foo)
def plot(datasets): ptBtagged = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjet17_pt") ]) ptB = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjetNotag_pt") ]) etaBtagged = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjet17_eta") ]) etaB = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjetNotag_eta") ]) ptQtagged = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjet17_pt") ]) ptQ = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjetNotag_pt") ]) etaQtagged = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjet17_eta") ]) etaQ = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjetNotag_eta") ]) ptBtagged.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptB.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaBtagged.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaB.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptQtagged.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptQ.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaQtagged.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaQ.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptBtagged33 = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjet33_pt") ]) etaBtagged33 = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjet33_eta") ]) ptQtagged33 = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjet33_pt") ]) etaQtagged33 = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjet33_eta") ]) ptBtagged33.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaBtagged33.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptQtagged33.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaQtagged33.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptBtagged._setLegendStyles() ptBtagged._setLegendLabels() ptBtagged.histoMgr.setHistoDrawStyleAll("P") ptBtagged.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hptBtagged = ptBtagged.histoMgr.getHisto("TTJets").getRootHisto().Clone( analysis + "/Btagging/realbjet_pt") ptB._setLegendStyles() ptB._setLegendLabels() ptB.histoMgr.setHistoDrawStyleAll("P") ptB.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hptB = ptB.histoMgr.getHisto("TTJets").getRootHisto().Clone( analysis + "/Btagging/realbjetNotag_pt") ptQtagged._setLegendStyles() ptQtagged._setLegendLabels() ptQtagged.histoMgr.setHistoDrawStyleAll("P") ptQtagged.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hptQtagged = ptQtagged.histoMgr.getHisto("QCD").getRootHisto().Clone( analysis + "/Btagging/realqjet_pt") ptQ._setLegendStyles() ptQ._setLegendLabels() ptQ.histoMgr.setHistoDrawStyleAll("P") ptQ.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hptQ = ptQ.histoMgr.getHisto("QCD").getRootHisto().Clone( analysis + "/Btagging/realqjetNotag_pt") hptBEff = hptBtagged.Clone("hptBEff") hptBEff.SetName("hptBEff") hptBEff.SetTitle("Efficiency B jet") hptBEff.Divide(hptB) hptQEff = hptQtagged.Clone("hptQEff") hptQEff.SetName("hptQEff") hptQEff.SetTitle("Efficiency Q jet") hptQEff.Divide(hptQ) canvas3 = ROOT.TCanvas("canvas3", "", 500, 500) canvas3.SetLogy() hptBEff.SetMinimum(0.01) hptBEff.SetMarkerColor(2) hptBEff.SetMarkerSize(1) hptBEff.SetMarkerStyle(22) hptBEff.Draw("EP") hptQEff.SetMarkerColor(4) hptQEff.SetMarkerSize(1) hptQEff.SetMarkerStyle(24) hptQEff.Draw("same") hptBEff.GetYaxis().SetTitle("B-tagging efficiency") hptBEff.GetYaxis().SetTitleOffset(1.5) hptBEff.GetXaxis().SetTitle("E_{T}^{jet} (GeV)") tex1 = ROOT.TLatex(0.45, 0.35, "b jets in tt events") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.42, 0.36, hptBEff.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hptBEff.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hptBEff.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.45, 0.25, "q or g jets in QCD events") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.42, 0.26, hptQEff.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptQEff.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hptQEff.GetMarkerSize()) marker2.Draw() tex5 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.2, 0.85, "Discriminator > 1.7") tex6.SetNDC() tex6.SetTextSize(18) tex6.Draw() canvas3.Print("ptBEff_disc17.png") canvas3.Print("ptBEff_disc17.C") ptBtagged33._setLegendStyles() ptBtagged33._setLegendLabels() ptBtagged33.histoMgr.setHistoDrawStyleAll("P") ptBtagged33.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hptBtagged33 = ptBtagged33.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/Btagging/realbjet33_pt") ptQtagged33._setLegendStyles() ptQtagged33._setLegendLabels() ptQtagged33.histoMgr.setHistoDrawStyleAll("P") ptQtagged33.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hptQtagged33 = ptQtagged33.histoMgr.getHisto("QCD").getRootHisto().Clone( analysis + "/Btagging/realqjet33_pt") hptBEff33 = hptBtagged33.Clone("hptBEff33") hptBEff33.SetName("hptBEff33") hptBEff33.SetTitle("Efficiency33 B jet") hptBEff33.Divide(hptB) hptQEff33 = hptQtagged33.Clone("hptQEff33") hptQEff33.SetName("hptQEff33") hptQEff33.SetTitle("Efficiency33 Q jet") hptQEff33.Divide(hptQ) canvas4 = ROOT.TCanvas("canvas4", "", 500, 500) canvas4.SetLogy() hptBEff33.SetMinimum(0.01) hptBEff33.SetMarkerColor(2) hptBEff33.SetMarkerSize(1) hptBEff33.SetMarkerStyle(22) hptBEff33.Draw("EP") hptQEff33.SetMarkerColor(4) hptQEff33.SetMarkerSize(1) hptQEff33.SetMarkerStyle(24) hptQEff33.Draw("same") hptBEff33.GetYaxis().SetTitle("B-tagging efficiency") hptBEff33.GetYaxis().SetTitleOffset(1.5) hptBEff33.GetXaxis().SetTitle("E_{T}^{jet} (GeV)") tex1 = ROOT.TLatex(0.45, 0.35, "b jets in tt events") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.42, 0.36, hptBEff.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hptBEff.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hptBEff.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.45, 0.25, "q or g jets in QCD events") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.42, 0.26, hptQEff.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptQEff.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hptQEff.GetMarkerSize()) marker2.Draw() tex5 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.2, 0.85, "Discriminator > 3.3") tex6.SetNDC() tex6.SetTextSize(18) tex6.Draw() canvas4.Print("ptBEff_disc33.png") canvas4.Print("ptBEff_disc33.C") ################################################# etaBtagged._setLegendStyles() etaBtagged._setLegendLabels() etaBtagged.histoMgr.setHistoDrawStyleAll("P") etaBtagged.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hetaBtagged = etaBtagged.histoMgr.getHisto("TTJets").getRootHisto().Clone( analysis + "/Btagging/realbjet_eta") etaB._setLegendStyles() etaB._setLegendLabels() etaB.histoMgr.setHistoDrawStyleAll("P") etaB.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hetaB = etaB.histoMgr.getHisto("TTJets").getRootHisto().Clone( analysis + "/Btagging/realbjetNotag_eta") etaQtagged._setLegendStyles() etaQtagged._setLegendLabels() etaQtagged.histoMgr.setHistoDrawStyleAll("P") etaQtagged.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hetaQtagged = etaQtagged.histoMgr.getHisto("QCD").getRootHisto().Clone( analysis + "/Btagging/realqjet_eta") etaQ._setLegendStyles() etaQ._setLegendLabels() etaQ.histoMgr.setHistoDrawStyleAll("P") etaQ.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hetaQ = etaQ.histoMgr.getHisto("QCD").getRootHisto().Clone( analysis + "/Btagging/realqjetNotag_eta") hetaBEff = hetaBtagged.Clone("hetaBEff") hetaBEff.SetName("hetaBEff") hetaBEff.SetTitle("Efficiency B jet") hetaBEff.Divide(hetaB) hetaQEff = hetaQtagged.Clone("hptQEff") hetaQEff.SetName("hetaQEff") hetaQEff.SetTitle("Efficiency Q jet") hetaQEff.Divide(hetaQ) canvas5 = ROOT.TCanvas("canvas5", "", 500, 500) canvas5.SetLogy() hetaBEff.SetMinimum(0.01) hetaBEff.SetMarkerColor(2) hetaBEff.SetMarkerSize(1) hetaBEff.SetMarkerStyle(22) hetaBEff.Draw("EP") hetaQEff.SetMarkerColor(4) hetaQEff.SetMarkerSize(1) hetaQEff.SetMarkerStyle(24) hetaQEff.Draw("same") hetaBEff.GetYaxis().SetTitle("B-tagging efficiency") hetaBEff.GetYaxis().SetTitleOffset(1.5) hetaBEff.GetXaxis().SetTitle("#eta^{jet}") tex1 = ROOT.TLatex(0.45, 0.35, "b jets in tt events") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.42, 0.36, hptBEff.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hptBEff.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hptBEff.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.45, 0.25, "q or g jets in QCD events") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.42, 0.26, hptQEff.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptQEff.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hptQEff.GetMarkerSize()) marker2.Draw() tex5 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.2, 0.85, "Discriminator > 1.7") tex6.SetNDC() tex6.SetTextSize(18) tex6.Draw() canvas5.Print("etaBEff_disc17.png") canvas5.Print("etaBEff_disc17.C") etaBtagged33._setLegendStyles() etaBtagged33._setLegendLabels() etaBtagged33.histoMgr.setHistoDrawStyleAll("P") etaBtagged33.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hetaBtagged33 = etaBtagged33.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/Btagging/realbjet33_eta") etaQtagged33._setLegendStyles() etaQtagged33._setLegendLabels() etaQtagged33.histoMgr.setHistoDrawStyleAll("P") etaQtagged33.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hetaQtagged33 = etaQtagged33.histoMgr.getHisto("QCD").getRootHisto().Clone( analysis + "/Btagging/realqjet33_eta") hetaBEff33 = hetaBtagged33.Clone("hetaBEff33") hetaBEff33.SetName("hptBEff33") hetaBEff33.SetTitle("Efficiency33 B jet") hetaBEff33.Divide(hetaB) hetaQEff33 = hetaQtagged33.Clone("hetaQEff33") hetaQEff33.SetName("hetaQEff33") hetaQEff33.SetTitle("Efficiency33 Q jet") hetaQEff33.Divide(hetaQ) canvas6 = ROOT.TCanvas("canvas6", "", 500, 500) canvas6.SetLogy() hetaBEff33.SetMinimum(0.01) hetaBEff33.SetMarkerColor(2) hetaBEff33.SetMarkerSize(1) hetaBEff33.SetMarkerStyle(22) hetaBEff33.Draw("EP") hetaQEff33.SetMarkerColor(4) hetaQEff33.SetMarkerSize(1) hetaQEff33.SetMarkerStyle(24) hetaQEff33.Draw("same") hetaBEff33.GetYaxis().SetTitle("B-tagging efficiency") hetaBEff33.GetYaxis().SetTitleOffset(1.5) hetaBEff33.GetXaxis().SetTitle("#eta^{jet}") tex1 = ROOT.TLatex(0.45, 0.55, "b jets in tt events") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.42, 0.56, hptBEff.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hptBEff.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hptBEff.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.25, 0.18, "q or g jets in QCD events") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.22, 0.19, hptQEff.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptQEff.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hptQEff.GetMarkerSize()) marker2.Draw() tex5 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.2, 0.85, "Discriminator > 3.3") tex6.SetNDC() tex6.SetTextSize(18) tex6.Draw() canvas6.Print("etaBEff_disc33.png") canvas6.Print("etaBEff_disc33.C")
def plot(datasets): ptSelected = plots.PlotBase([datasets.getDataset("TTJets").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_selected_taus_pt")]) ptAll = plots.PlotBase([datasets.getDataset("TTJets").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_all_tau_candidates_pt")]) ptClean = plots.PlotBase([datasets.getDataset("TTJets").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_cleaned_tau_candidates_pt")]) ptSelected.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) ptAll.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) ptClean.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) ptSelected._setLegendStyles() ptSelected._setLegendLabels() ptSelected.histoMgr.setHistoDrawStyleAll("P") ptSelected.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptSelected = ptSelected.histoMgr.getHisto("TTJets").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_selected_taus_pt") ptAll._setLegendStyles() ptAll._setLegendLabels() ptAll.histoMgr.setHistoDrawStyleAll("P") ptAll.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptAll = ptAll.histoMgr.getHisto("TTJets").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_all_tau_candidates_pt") ptClean._setLegendStyles() ptClean._setLegendLabels() ptClean.histoMgr.setHistoDrawStyleAll("P") ptClean.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptClean = ptClean.histoMgr.getHisto("TTJets").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_cleaned_tau_candidates_pt") hptEff = hptSelected.Clone("hptSelected") hptEff.SetName("hptEff") hptEff.SetTitle("TauVetoEff") hptEff.Divide(hptAll) hptIsolEff = hptSelected.Clone("hptSelected") hptIsolEff.SetName("hptIsolEff") hptIsolEff.SetTitle("TauVetoIsolEff") hptIsolEff.Divide(hptClean) canvas3 = ROOT.TCanvas("canvas3","",500,500) canvas3.SetLogy() hptIsolEff.SetMaximum(0.08) hptIsolEff.SetMinimum(0.001) hptIsolEff.SetMarkerColor(4) hptIsolEff.SetMarkerSize(1) hptIsolEff.SetMarkerStyle(24) hptIsolEff.Draw("EP") hptEff.SetMarkerColor(2) hptEff.SetMarkerSize(1) hptEff.SetMarkerStyle(25) hptEff.Draw("same") hptIsolEff.GetYaxis().SetTitle("#tau selection efficiency") hptIsolEff.GetYaxis().SetTitleOffset(1.5) hptIsolEff.GetXaxis().SetTitle("p_{T}^{#tau jet} (GeV)") tex1 = ROOT.TLatex(0.35,0.3,"Total selection") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.3,0.31,hptEff.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hptEff.GetMarkerColor()) marker1.SetMarkerSize(0.9*hptEff.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.35,0.25,"Isolation") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.3,0.251,hptIsolEff.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptIsolEff.GetMarkerColor()) marker2.SetMarkerSize(0.9*hptIsolEff.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2,0.95,"7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() # tex5 = ROOT.TLatex(0.55,0.9,"Signal, m_{H^{#pm}} = 120 GeV/c^{2}") tex5 = ROOT.TLatex(0.65,0.85,"tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() canvas3.Print("TauVetoEff_pt_tt.png") canvas3.Print("TauVetoEff_pt_tt.C") ############## signal pt ptSelected2 = plots.PlotBase([datasets.getDataset("TTToHplusBWB_M120").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_selected_taus_pt")]) ptAll2 = plots.PlotBase([datasets.getDataset("TTToHplusBWB_M120").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_all_tau_candidates_pt")]) ptClean2 = plots.PlotBase([datasets.getDataset("TTToHplusBWB_M120").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_cleaned_tau_candidates_pt")]) ptSelected2.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) ptAll2.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) ptClean2.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) ptSelected2._setLegendStyles() ptSelected2._setLegendLabels() ptSelected2.histoMgr.setHistoDrawStyleAll("P") ptSelected2.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptSelected2 = ptSelected2.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_selected_taus_pt") ptAll2._setLegendStyles() ptAll2._setLegendLabels() ptAll2.histoMgr.setHistoDrawStyleAll("P") ptAll2.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptAll2 = ptAll2.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_all_tau_candidates_pt") ptClean2._setLegendStyles() ptClean2._setLegendLabels() ptClean2.histoMgr.setHistoDrawStyleAll("P") ptClean2.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptClean2 = ptClean2.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_cleaned_tau_candidates_pt") hptEff2 = hptSelected.Clone("hptSelected2") hptEff2.SetName("hptEff2") hptEff2.SetTitle("TauVetoEff2") hptEff2.Divide(hptAll2) hptIsolEff2 = hptSelected.Clone("hptSelected2") hptIsolEff2.SetName("hptIsolEff2") hptIsolEff2.SetTitle("TauVetoIsolEff2") hptIsolEff2.Divide(hptClean2) canvas5 = ROOT.TCanvas("canvas5","",500,500) canvas5.SetLogy() # hptIsolEff2.SetMaximum(0.08) hptIsolEff2.SetMinimum(0.0001) hptIsolEff2.SetMarkerColor(4) hptIsolEff2.SetMarkerSize(1) hptIsolEff2.SetMarkerStyle(24) hptIsolEff2.Draw("EP") hptEff2.SetMarkerColor(2) hptEff2.SetMarkerSize(1) hptEff2.SetMarkerStyle(25) hptEff2.Draw("same") hptIsolEff2.GetYaxis().SetTitle("#tau selection efficiency") hptIsolEff2.GetYaxis().SetTitleOffset(1.5) hptIsolEff2.GetXaxis().SetTitle("p_{T}^{#tau jet} (GeV)") tex1 = ROOT.TLatex(0.35,0.3,"Total selection") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.3,0.31,hptEff.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hptEff.GetMarkerColor()) marker1.SetMarkerSize(0.9*hptEff.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.35,0.25,"Isolation") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.3,0.251,hptIsolEff.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptIsolEff.GetMarkerColor()) marker2.SetMarkerSize(0.9*hptIsolEff.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2,0.95,"7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex5 = ROOT.TLatex(0.45,0.85,"Signal, m_{H^{#pm}} = 120 GeV/c^{2}") # tex5 = ROOT.TLatex(0.55,0.9,"tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() canvas5.Print("TauVetoEff_pt_h120.png") canvas5.Print("TauVetoEff_pt_h120.C") ############################### etaSelected = plots.PlotBase([datasets.getDataset("TTJets").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_selected_taus_eta")]) etaAll = plots.PlotBase([datasets.getDataset("TTJets").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_all_tau_candidates_eta")]) etaClean = plots.PlotBase([datasets.getDataset("TTJets").getDatasetRootHisto(analysis+"/TauVeto/TauSelection_cleaned_tau_candidates_eta")]) etaSelected.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) etaAll.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) etaClean.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity()) etaSelected._setLegendStyles() etaSelected._setLegendLabels() etaSelected.histoMgr.setHistoDrawStyleAll("P") etaSelected.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hetaSelected = etaSelected.histoMgr.getHisto("TTJets").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_selected_taus_eta") etaAll._setLegendStyles() etaAll._setLegendLabels() etaAll.histoMgr.setHistoDrawStyleAll("P") etaAll.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hetaAll = etaAll.histoMgr.getHisto("TTJets").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_all_tau_candidates_eta") etaClean._setLegendStyles() etaClean._setLegendLabels() etaClean.histoMgr.setHistoDrawStyleAll("P") etaClean.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hetaClean = etaClean.histoMgr.getHisto("TTJets").getRootHisto().Clone(analysis+"/TauVeto/TauSelection_cleaned_tau_candidates_eta") hetaEff = hetaSelected.Clone("hetaSelected") hetaEff.SetName("hetaEff") hetaEff.SetTitle("TauVetoEff") hetaEff.Divide(hetaAll) hetaIsolEff = hetaSelected.Clone("hetaSelected") hetaIsolEff.SetName("hetaIsolEff") hetaIsolEff.SetTitle("TauVetoIsolEff") hetaIsolEff.Divide(hetaClean) canvas2 = ROOT.TCanvas("canvas2","",500,500) # canvas3.SetLogy() hetaEff.SetMaximum(0.12) hetaEff.SetMarkerColor(2) hetaEff.SetMarkerSize(1) hetaEff.SetMarkerStyle(20) hetaEff.Draw("EP") hetaIsolEff.SetMarkerColor(4) hetaIsolEff.SetMarkerSize(1) hetaIsolEff.SetMarkerStyle(26) hetaIsolEff.Draw("same") hetaEff.GetYaxis().SetTitle("#tau selection efficiency") hetaEff.GetYaxis().SetTitleOffset(1.5) hetaEff.GetXaxis().SetTitle("#eta_{#tau jet}") # tex5 = ROOT.TLatex(0.55,0.9,"Signal, m_{H^{#pm}} = 120 GeV/c^{2}") tex5 = ROOT.TLatex(0.55,0.9,"tt+jets") tex5.SetNDC() tex5.SetTextSize(18) tex5.Draw() tex1 = ROOT.TLatex(0.55,0.8,"Total selection") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.5,0.715,hetaEff.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hetaEff.GetMarkerColor()) marker1.SetMarkerSize(0.9*hetaEff.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.55,0.7,"Isolation") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.5,0.715,hetaIsolEff.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hetaIsolEff.GetMarkerColor()) marker2.SetMarkerSize(0.9*hetaIsolEff.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2,0.95,"7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() canvas2.Print("TauVetoEff_eta.png") canvas2.Print("TauVetoEff_eta.C")
def plot(datasets): ptBtagged = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjet17_pt") ]) ptB = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjetNotag_pt") ]) etaBtagged = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjet17_eta") ]) etaB = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/Btagging/realbjetNotag_eta") ]) ptQtagged = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjet17_pt") ]) ptQ = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjetNotag_pt") ]) etaQtagged = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjet17_eta") ]) etaQ = plots.PlotBase([ datasets.getDataset("QCD").getDatasetRootHisto( analysis + "/Btagging/realqjetNotag_eta") ]) ptBtagged.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptB.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaBtagged.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaB.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptQtagged.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptQ.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaQtagged.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaQ.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptBtagged._setLegendStyles() ptBtagged._setLegendLabels() ptBtagged.histoMgr.setHistoDrawStyleAll("P") ptBtagged.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hptBtagged = ptBtagged.histoMgr.getHisto("TTJets").getRootHisto().Clone( analysis + "/Btagging/realbjet_pt") ptB._setLegendStyles() ptB._setLegendLabels() ptB.histoMgr.setHistoDrawStyleAll("P") ptB.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) hptB = ptB.histoMgr.getHisto("TTJets").getRootHisto().Clone( analysis + "/Btagging/realbjetNotag_pt") hptBEff = hptBtagged.Clone("hptBEff") hptBEff.SetName("hptBEff") hptBEff.SetTitle("Efficiency B jet") hptBEff.Divide(hptB) canvas3 = ROOT.TCanvas("canvas3", "", 500, 500) # canvas3.SetLogy() # hmt.SetMaximum(3.0) hptBEff.SetMarkerColor(2) hptBEff.SetMarkerSize(1) hptBEff.SetMarkerStyle(21) hptBEff.Draw("EP") hptBEff.GetYaxis().SetTitle("Events / 10 GeV/c^{2}") hptBEff.GetYaxis().SetTitleOffset(1.5) hptBEff.GetXaxis().SetTitle("m_{T}(#tau jet, MET) (GeV/c^{2})") canvas3.Print("ptBEff.png") canvas3.Print("ptBEff.C") metCut = "met_p4.Et() > 50" tauPtCut = "tau_p4.Pt() > 40" jetNumCut = "Sum$(jets_p4.Pt() > 30) >= 3" tauLeadingCandPtCut = "tau_leadPFChargedHadrCand_p4.Pt() > 20" rtauCut = "tau_leadPFChargedHadrCand_p4.P()/tau_p4.P() > 0.7" btag = "jets_btag > 1.7" bjet = "abs(jets_flavour) == 5" qjet = "abs(jets_flavour) < 4 || jets_flavour > 20" deltaPhiCut = "acos((tau_p4.Px()*met_p4.Px()+tau_p4.Py()*met_p4.Py())/tau_p4.Pt()/met_p4.Et())*57.2958 < 160" tauSelCut = "tau_p4.Pt() > 40 && tau_leadPFChargedHadrCand_p4.Pt() > 20 && tau_leadPFChargedHadrCand_p4.P()/tau_p4.P() > 0.7" tauJetsCut = "tau_p4.Pt() > 40 && tau_leadPFChargedHadrCand_p4.Pt() > 20 && tau_leadPFChargedHadrCand_p4.P()/tau_p4.P() > 0.7 && Sum$(jets_p4.Pt() > 30) >= 3 " tauJetsMetCut = "tau_p4.Pt() > 40 && tau_leadPFChargedHadrCand_p4.Pt() > 20 && tau_leadPFChargedHadrCand_p4.P()/tau_p4.P() > 0.7 && Sum$(jets_p4.Pt() > 30) >= 3 && met_p4.Et() > 50" noTagging = jetNumCut + "&&abs(jets_flavour)==5" btagging = noTagging + "&&jets_btag > 3.3" noTaggingLight = jetNumCut + "&&(abs(jets_flavour) < 4 || jets_flavour > 20)" # noTaggingLight = jetNumCut + "&&abs(jets_flavour) == 1" # noTaggingLight = jetNumCut + "&&abs(jets_flavour) != 5" btaggingLight = noTaggingLight + "&&jets_btag > 3.3" noTaggingMet = jetNumCut + "&&met_p4.Et() > 50" + "&&abs(jets_flavour)==5" btaggingMet = noTaggingMet + "&&jets_btag > 3.3" ########################################### hpt = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Et()>>dist(25,0,500)", selection=noTagging)) hptb = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Et()>>dist(25,0,500)", selection=btagging)) hptQ = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Et()>>dist(25,0,500)", selection=noTaggingLight)) hptbQ = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Et()>>dist(25,0,500)", selection=btaggingLight)) ################################################## # MET cut comparison b jets # Clone the data one hpt120 = hpt.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto().Clone( "TTToHplusBWB_M120") hpt120_btag = hptb.histoMgr.getHisto( "TTToHplusBWB_M120").getRootHisto().Clone("TTToHplusBWB_M120") # hpt120_btag = hptb.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto() canvas9 = ROOT.TCanvas("canvas9", "", 500, 500) canvas9.SetLogy() # hmt.SetMaximum(3.0) hpt120.SetMarkerColor(2) hpt120.SetMarkerSize(1) hpt120.SetMarkerStyle(21) hpt120.SetLineStyle(1) hpt120.SetLineWidth(1) hpt120.Draw("EP") hpt120_btag.SetMarkerColor(4) hpt120_btag.SetMarkerSize(1) hpt120_btag.SetMarkerStyle(25) hpt120_btag.SetLineStyle(1) hpt120_btag.SetLineWidth(1) hpt120_btag.Draw("same") canvas9.Print("test_pt.png") hptt = hpt.histoMgr.getHisto("TTJets").getRootHisto().Clone("TTJets") hptt_btag = hptb.histoMgr.getHisto("TTJets").getRootHisto() # tagged et / et hpt120_btag.Divide(hpt120) hpt120_btag.SetName("btagEff_pt") # jet Et with b tagging and tau Et cut hptmetb = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Et()>>dist(25,0,500)", selection=btaggingMet)) hptmet = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Et()>>dist(25,0,500)", selection=noTaggingMet)) # Clone the data one hptmet120 = hptmet.histoMgr.getHisto( "TTToHplusBWB_M120").getRootHisto().Clone("TTToHplusBWB_M120") hptmet120_btag = hptmetb.histoMgr.getHisto( "TTToHplusBWB_M120").getRootHisto() # tagged et / et hptmet120_btag.Divide(hptmet120) hptmet120_btag.SetName("btagEff_pt_metcut") canvas3 = ROOT.TCanvas("canvas3", "", 500, 500) canvas3.SetLogy() # hmt.SetMaximum(3.0) hpt120_btag.SetMarkerColor(2) hpt120_btag.SetMarkerSize(1) hpt120_btag.SetMarkerStyle(21) hpt120_btag.SetLineStyle(1) hpt120_btag.SetLineWidth(1) hpt120_btag.Draw("EP") hptmet120_btag.SetMarkerColor(4) hptmet120_btag.SetMarkerSize(1) hptmet120_btag.SetMarkerStyle(22) hptmet120_btag.SetLineStyle(1) hptmet120_btag.SetLineColor(4) hptmet120_btag.SetLineWidth(1) hptmet120_btag.Draw("same") hpt120_btag.GetYaxis().SetTitle("B-tagging efficiency") # hmt.GetYaxis().SetTitleSize(20.0) # data_btag.GetYaxis().SetTitleOffset(1.5) hpt120_btag.GetXaxis().SetTitle("E_{T}^{jet} (GeV)") tex1 = ROOT.TLatex(0.35, 0.8, "No MET cut") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.3, 0.815, hpt120_btag.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hpt120_btag.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hpt120_btag.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.35, 0.7, "MET > 50 GeV") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.3, 0.715, hptmet120_btag.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptmet120_btag.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hptmet120_btag.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() canvas3.Print("btagEff_pt.png") ################################################## # Higgs mass comparison b jets hpt80 = hpt.histoMgr.getHisto("TTToHplusBWB_M80").getRootHisto().Clone( "TTToHplusBWB_M80") hpt80_btag = hptb.histoMgr.getHisto("TTToHplusBWB_M80").getRootHisto() # tagged et / et hpt80_btag.Divide(hpt80) hpt80_btag.SetName("btagEff80_pt") hpt160 = hpt.histoMgr.getHisto("TTToHplusBWB_M160").getRootHisto().Clone( "TTToHplusBWB_M160") hpt160_btag = hptb.histoMgr.getHisto("TTToHplusBWB_M160").getRootHisto() # tagged et / et hpt160_btag.Divide(hpt160) hpt160_btag.SetName("btagEff160_pt") hpttt = hpt.histoMgr.getHisto("TTJets").getRootHisto().Clone("TTJets") hpttt_btag = hptb.histoMgr.getHisto("TTJets").getRootHisto() # tagged et / et hpttt_btag.Divide(hpttt) hpttt_btag.SetName("btagEfftt_pt") canvas5 = ROOT.TCanvas("canvas5", "", 500, 500) canvas5.SetLogy() hpt120_btag.SetMaximum(2.0) hpt120_btag.SetMinimum(0.1) hpt120_btag.SetMarkerColor(2) hpt120_btag.SetMarkerSize(1) hpt120_btag.SetMarkerStyle(21) hpt120_btag.SetLineStyle(1) hpt120_btag.SetLineWidth(1) hpt120_btag.Draw("P") hpt80_btag.SetMarkerColor(4) hpt80_btag.SetMarkerSize(1) hpt80_btag.SetMarkerStyle(22) hpt80_btag.SetLineStyle(1) hpt80_btag.SetLineColor(4) hpt80_btag.SetLineWidth(1) hpt80_btag.Draw("same") hpt160_btag.SetMarkerColor(7) hpt160_btag.SetMarkerSize(1) hpt160_btag.SetMarkerStyle(25) hpt160_btag.SetLineStyle(1) hpt160_btag.SetLineColor(7) hpt160_btag.SetLineWidth(1) hpt160_btag.Draw("same") hpttt_btag.SetMarkerColor(6) hpttt_btag.SetMarkerSize(1) hpttt_btag.SetMarkerStyle(24) hpttt_btag.SetLineStyle(1) hpttt_btag.SetLineColor(6) hpttt_btag.SetLineWidth(1) hpttt_btag.Draw("same") hpt120_btag.GetYaxis().SetTitle("B-tagging efficiency") # hmt.GetYaxis().SetTitleSize(20.0) # data_btag.GetYaxis().SetTitleOffset(1.5) hpt120_btag.GetXaxis().SetTitle("E_{T}^{jet} (GeV)") tex1 = ROOT.TLatex(0.25, 0.5, "m_{H^{#pm}} = 120 GeV/c^{2}") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.22, 0.515, hpt120_btag.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hpt120_btag.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hpt120_btag.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.25, 0.45, "m_{H^{#pm}} = 80 GeV/c^{2}") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.22, 0.455, hpt80_btag.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hpt80_btag.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hpt80_btag.GetMarkerSize()) marker2.Draw() tex3 = ROOT.TLatex(0.25, 0.4, "m_{H^{#pm}} = 160 GeV/c^{2}") tex3.SetNDC() tex3.SetTextSize(20) tex3.Draw() marker3 = ROOT.TMarker(0.22, 0.415, hpt160_btag.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hpt160_btag.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hpt160_btag.GetMarkerSize()) marker3.Draw() tex4 = ROOT.TLatex(0.25, 0.35, "tt") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() marker4 = ROOT.TMarker(0.22, 0.355, hpttt_btag.GetMarkerStyle()) marker4.SetNDC() marker4.SetMarkerColor(hpttt_btag.GetMarkerColor()) marker4.SetMarkerSize(0.9 * hpttt_btag.GetMarkerSize()) marker4.Draw() tex9 = ROOT.TLatex(0.2, 0.85, "Discriminator > 3.3 ") tex9.SetNDC() tex9.SetTextSize(20) tex9.Draw() tex5 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() canvas5.Print("btagEff33_pt_mH.png") ################################################## # Higgs mass comparison Q jets hpt120Q = hptQ.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto().Clone( "TTToHplusBWB_M120") hpt120Q_btag = hptbQ.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto() canvas9b = ROOT.TCanvas("canvas9b", "", 500, 500) canvas9b.SetLogy() # hmt.SetMaximum(3.0) hpt120Q.SetMarkerColor(2) hpt120Q.SetMarkerSize(1) hpt120Q.SetMarkerStyle(21) hpt120Q.SetLineStyle(1) hpt120Q.SetLineWidth(1) hpt120Q.Draw("EP") hpt120Q_btag.SetMarkerColor(4) hpt120Q_btag.SetMarkerSize(1) hpt120Q_btag.SetMarkerStyle(25) hpt120Q_btag.SetLineStyle(1) hpt120Q_btag.SetLineWidth(1) hpt120Q_btag.Draw("same") canvas9b.Print("testQ_pt.png") # tagged et / et hpt120Q_btag.Divide(hpt120Q) hpt120Q_btag.SetName("btagEff120Q_pt") hpt80Q = hptQ.histoMgr.getHisto("TTToHplusBWB_M80").getRootHisto().Clone( "TTToHplusBWB_M80") hpt80Q_btag = hptbQ.histoMgr.getHisto("TTToHplusBWB_M80").getRootHisto() # tagged et / et hpt80Q_btag.Divide(hpt80Q) hpt80Q_btag.SetName("btagEff80Q_pt") hpt160Q = hptQ.histoMgr.getHisto("TTToHplusBWB_M160").getRootHisto().Clone( "TTToHplusBWB_M160") hpt160Q_btag = hptbQ.histoMgr.getHisto("TTToHplusBWB_M160").getRootHisto() # tagged et / et hpt160Q_btag.Divide(hpt160Q) hpt160Q_btag.SetName("btagEff160Q_pt") hptttQ = hptQ.histoMgr.getHisto("TTJets").getRootHisto().Clone("TTJets") hptttQ_btag = hptbQ.histoMgr.getHisto("TTJets").getRootHisto() # tagged et / et hptttQ_btag.Divide(hptttQ) hptttQ_btag.SetName("btagEffttQ_pt") hptWjetQ = hptQ.histoMgr.getHisto("WJets").getRootHisto().Clone("WJets") hptWjetQ_btag = hptbQ.histoMgr.getHisto("WJets").getRootHisto() # tagged et / et hptWjetQ_btag.Divide(hptWjetQ) hptWjetQ_btag.SetName("btagEffWjetQ_pt") hptqcdQ = hptQ.histoMgr.getHisto("QCD").getRootHisto().Clone("QCD") hptqcdQ_btag = hptbQ.histoMgr.getHisto("QCD").getRootHisto() # tagged et / et hptqcdQ_btag.Divide(hptqcdQ) hptqcdQ_btag.SetName("btagEffqcdQ_pt") canvas5q = ROOT.TCanvas("canvas5q", "", 500, 500) canvas5q.SetLogy() hpt120Q_btag.SetMaximum(0.5) hpt120Q_btag.SetMinimum(0.001) hpt120Q_btag.SetMarkerColor(2) hpt120Q_btag.SetMarkerSize(1) hpt120Q_btag.SetMarkerStyle(21) hpt120Q_btag.SetLineStyle(1) hpt120Q_btag.SetLineWidth(1) hpt120Q_btag.Draw("P") hpt80Q_btag.SetMarkerColor(4) hpt80Q_btag.SetMarkerSize(1) hpt80Q_btag.SetMarkerStyle(22) hpt80Q_btag.SetLineStyle(1) hpt80Q_btag.SetLineColor(4) hpt80Q_btag.SetLineWidth(1) # hpt80Q_btag.Draw("same") hpt160Q_btag.SetMarkerColor(7) hpt160Q_btag.SetMarkerSize(1) hpt160Q_btag.SetMarkerStyle(25) hpt160Q_btag.SetLineStyle(1) hpt160Q_btag.SetLineColor(7) hpt160Q_btag.SetLineWidth(1) # hpt160Q_btag.Draw("same") hptttQ_btag.SetMarkerColor(6) hptttQ_btag.SetMarkerSize(1) hptttQ_btag.SetMarkerStyle(24) hptttQ_btag.SetLineStyle(1) hptttQ_btag.SetLineColor(6) hptttQ_btag.SetLineWidth(1) hptttQ_btag.Draw("same") hptWjetQ_btag.SetMarkerColor(4) hptWjetQ_btag.SetMarkerSize(1) hptWjetQ_btag.SetMarkerStyle(22) hptWjetQ_btag.SetLineStyle(1) hptWjetQ_btag.SetLineColor(4) hptWjetQ_btag.SetLineWidth(1) hptWjetQ_btag.Draw("same") hptqcdQ_btag.SetMarkerColor(1) hptqcdQ_btag.SetMarkerSize(1) hptqcdQ_btag.SetMarkerStyle(25) hptqcdQ_btag.SetLineStyle(1) hptqcdQ_btag.SetLineColor(1) hptqcdQ_btag.SetLineWidth(1) hptqcdQ_btag.Draw("same") hpt120Q_btag.GetYaxis().SetTitle("B-tagging efficiency") # hmt.GetYaxis().SetTitleSize(20.0) # data_btag.GetYaxis().SetTitleOffset(1.5) hpt120Q_btag.GetXaxis().SetTitle("E_{T}^{jet} (GeV)") tex1 = ROOT.TLatex(0.25, 0.9, "m_{H^{#pm}} = 120 GeV/c^{2}") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.22, 0.915, hpt120Q_btag.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hpt120Q_btag.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hpt120Q_btag.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.25, 0.55, "m_{H^{#pm}} = 80 GeV/c^{2}") tex2.SetNDC() tex2.SetTextSize(20) # tex2.Draw() marker2 = ROOT.TMarker(0.22, 0.555, hpt80Q_btag.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hpt80Q_btag.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hpt80Q_btag.GetMarkerSize()) # marker2.Draw() tex3 = ROOT.TLatex(0.25, 0.8, "m_{H^{#pm}} = 160 GeV/c^{2}") tex3.SetNDC() tex3.SetTextSize(20) # tex3.Draw() marker3 = ROOT.TMarker(0.22, 0.815, hpt160Q_btag.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hpt160Q_btag.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hpt160Q_btag.GetMarkerSize()) # marker3.Draw() tex4 = ROOT.TLatex(0.25, 0.85, "tt") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() marker4 = ROOT.TMarker(0.22, 0.855, hptttQ_btag.GetMarkerStyle()) marker4.SetNDC() marker4.SetMarkerColor(hptttQ_btag.GetMarkerColor()) marker4.SetMarkerSize(0.9 * hptttQ_btag.GetMarkerSize()) marker4.Draw() tex5 = ROOT.TLatex(0.25, 0.8, "Wjets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() marker5 = ROOT.TMarker(0.22, 0.815, hptWjetQ_btag.GetMarkerStyle()) marker5.SetNDC() marker5.SetMarkerColor(hptWjetQ_btag.GetMarkerColor()) marker5.SetMarkerSize(0.9 * hptWjetQ_btag.GetMarkerSize()) marker5.Draw() tex8 = ROOT.TLatex(0.25, 0.75, "QCD") tex8.SetNDC() tex8.SetTextSize(20) tex8.Draw() marker8 = ROOT.TMarker(0.22, 0.757, hptqcdQ_btag.GetMarkerStyle()) marker8.SetNDC() marker8.SetMarkerColor(hptqcdQ_btag.GetMarkerColor()) marker8.SetMarkerSize(0.9 * hptqcdQ_btag.GetMarkerSize()) marker8.Draw() tex7 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex7.SetNDC() tex7.SetTextSize(20) tex7.Draw() tex9 = ROOT.TLatex(0.3, 0.3, "Discriminator > 3.3 ") tex9.SetNDC() tex9.SetTextSize(20) tex9.Draw() canvas5q.Print("QtagEff33_pt_mH.png") ######################################################## heta = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Eta()>>dist(30,-3,3)", selection=noTagging)) hetab = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Eta()>>dist(30,-3,3)", selection=btagging)) hetaQ = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Eta()>>dist(30,-3,3)", selection=noTaggingLight)) hetabQ = plots.DataMCPlot( datasets, treeDraw.clone(varexp="jets_p4.Eta()>>dist(30,-3,3)", selection=btaggingLight)) ################################################## # Higgs mass comparison b jets heta120 = heta.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto().Clone( "TTToHplusBWB_M120") heta120_btag = hetab.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto() # tagged et / et heta120_btag.Divide(heta120) heta120_btag.SetName("btagEff120_eta") heta80 = heta.histoMgr.getHisto("TTToHplusBWB_M80").getRootHisto().Clone( "TTToHplusBWB_M80") heta80_btag = hetab.histoMgr.getHisto("TTToHplusBWB_M80").getRootHisto() # tagged et / et heta80_btag.Divide(heta80) heta80_btag.SetName("btagEff80_eta") heta160 = heta.histoMgr.getHisto("TTToHplusBWB_M160").getRootHisto().Clone( "TTToHplusBWB_M160") heta160_btag = hetab.histoMgr.getHisto("TTToHplusBWB_M160").getRootHisto() # tagged et / et heta160_btag.Divide(heta160) heta160_btag.SetName("btagEff160_eta") hetatt = heta.histoMgr.getHisto("TTJets").getRootHisto().Clone("TTJets") hetatt_btag = hetab.histoMgr.getHisto("TTJets").getRootHisto() # tagged et / et hetatt_btag.Divide(hetatt) hetatt_btag.SetName("btagEfftt_eta") hetaWjet = heta.histoMgr.getHisto("WJets").getRootHisto().Clone("WJets") hetaWjet_btag = hetab.histoMgr.getHisto("WJets").getRootHisto() # tagged et / et hetaWjet_btag.Divide(hetaWjet) hetaWjet_btag.SetName("btagEffWjet_eta") hetaqcd = heta.histoMgr.getHisto("QCD").getRootHisto().Clone("QCD") hetaqcd_btag = hetab.histoMgr.getHisto("QCD").getRootHisto() # tagged et / et hetaqcd_btag.Divide(hetaqcd) hetaqcd_btag.SetName("btagEffqcd_eta") canvas5a = ROOT.TCanvas("canvas5a", "", 500, 500) canvas5a.SetLogy() heta120_btag.SetMaximum(2.0) heta120_btag.SetMinimum(0.1) heta120_btag.SetMarkerColor(2) heta120_btag.SetMarkerSize(1) heta120_btag.SetMarkerStyle(21) heta120_btag.SetLineStyle(1) heta120_btag.SetLineWidth(1) heta120_btag.Draw("P") heta80_btag.SetMarkerColor(4) heta80_btag.SetMarkerSize(1) heta80_btag.SetMarkerStyle(22) heta80_btag.SetLineStyle(1) heta80_btag.SetLineColor(4) heta80_btag.SetLineWidth(1) heta80_btag.Draw("same") heta160_btag.SetMarkerColor(7) heta160_btag.SetMarkerSize(1) heta160_btag.SetMarkerStyle(25) heta160_btag.SetLineStyle(1) heta160_btag.SetLineColor(7) heta160_btag.SetLineWidth(1) heta160_btag.Draw("same") hetatt_btag.SetMarkerColor(6) hetatt_btag.SetMarkerSize(1) hetatt_btag.SetMarkerStyle(24) hetatt_btag.SetLineStyle(1) hetatt_btag.SetLineColor(6) hetatt_btag.SetLineWidth(1) hetatt_btag.Draw("same") hetaWjet_btag.SetMarkerColor(4) hetaWjet_btag.SetMarkerSize(1) hetaWjet_btag.SetMarkerStyle(22) hetaWjet_btag.SetLineStyle(1) hetaWjet_btag.SetLineColor(4) hetaWjet_btag.SetLineWidth(1) # hetaWjet_btag.Draw("same") hetaqcd_btag.SetMarkerColor(1) hetaqcd_btag.SetMarkerSize(1) hetaqcd_btag.SetMarkerStyle(25) hetaqcd_btag.SetLineStyle(1) hetaqcd_btag.SetLineColor(1) hetaqcd_btag.SetLineWidth(1) # hetaqcd_btag.Draw("same") heta120_btag.GetYaxis().SetTitle("B-tagging efficiency") # hmt.GetYaxis().SetTitleSize(20.0) # data_btag.GetYaxis().SetTitleOffset(1.5) heta120_btag.GetXaxis().SetTitle("#eta^{jet}") tex1 = ROOT.TLatex(0.25, 0.9, "m_{H^{#pm}} = 120 GeV/c^{2}") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.22, 0.915, heta120_btag.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(heta120_btag.GetMarkerColor()) marker1.SetMarkerSize(0.9 * heta120_btag.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.25, 0.85, "m_{H^{#pm}} = 80 GeV/c^{2}") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.22, 0.855, heta80_btag.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(heta80_btag.GetMarkerColor()) marker2.SetMarkerSize(0.9 * heta80_btag.GetMarkerSize()) marker2.Draw() tex3 = ROOT.TLatex(0.25, 0.8, "m_{H^{#pm}} = 160 GeV/c^{2}") tex3.SetNDC() tex3.SetTextSize(20) tex3.Draw() marker3 = ROOT.TMarker(0.22, 0.815, heta160_btag.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(heta160_btag.GetMarkerColor()) marker3.SetMarkerSize(0.9 * heta160_btag.GetMarkerSize()) marker3.Draw() tex4 = ROOT.TLatex(0.25, 0.75, "tt") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() marker4 = ROOT.TMarker(0.22, 0.755, hetatt_btag.GetMarkerStyle()) marker4.SetNDC() marker4.SetMarkerColor(hetatt_btag.GetMarkerColor()) marker4.SetMarkerSize(0.9 * hetatt_btag.GetMarkerSize()) marker4.Draw() tex7 = ROOT.TLatex(0.25, 0.8, "Wjet") tex7.SetNDC() tex7.SetTextSize(20) # tex7.Draw() marker7 = ROOT.TMarker(0.22, 0.815, hetaWjet_btag.GetMarkerStyle()) marker7.SetNDC() marker7.SetMarkerColor(hetaWjet_btag.GetMarkerColor()) marker7.SetMarkerSize(0.9 * hetaWjet_btag.GetMarkerSize()) # marker7.Draw() tex8 = ROOT.TLatex(0.25, 0.75, "QCD") tex8.SetNDC() tex8.SetTextSize(20) # tex8.Draw() marker8 = ROOT.TMarker(0.22, 0.755, hetaqcd_btag.GetMarkerStyle()) marker8.SetNDC() marker8.SetMarkerColor(hetaqcd_btag.GetMarkerColor()) marker8.SetMarkerSize(0.9 * hetaqcd_btag.GetMarkerSize()) # marker8.Draw() tex9 = ROOT.TLatex(0.4, 0.3, "Discriminator > 3.3 ") tex9.SetNDC() tex9.SetTextSize(20) tex9.Draw() tex5 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() canvas5a.Print("btagEff33_eta_mH.png") ####################################################################### # Higgs mass comparison light jets heta120Q = hetaQ.histoMgr.getHisto( "TTToHplusBWB_M120").getRootHisto().Clone("TTToHplusBWB_M120") heta120Q_btag = hetabQ.histoMgr.getHisto( "TTToHplusBWB_M120").getRootHisto() heta120Q_btag.Divide(heta120Q) heta120Q_btag.SetName("btagEff120Q_eta") heta80Q = hetaQ.histoMgr.getHisto("TTToHplusBWB_M80").getRootHisto().Clone( "TTToHplusBWB_M80") heta80Q_btag = hetabQ.histoMgr.getHisto("TTToHplusBWB_M80").getRootHisto() # tagged et / et heta80Q_btag.Divide(heta80Q) heta80Q_btag.SetName("btagEff80Q_eta") heta160Q = hetaQ.histoMgr.getHisto( "TTToHplusBWB_M160").getRootHisto().Clone("TTToHplusBWB_M160") heta160Q_btag = hetabQ.histoMgr.getHisto( "TTToHplusBWB_M160").getRootHisto() # tagged et / et heta160Q_btag.Divide(heta160Q) heta160Q_btag.SetName("btagEff160Q_eta") hetattQ = hetaQ.histoMgr.getHisto("TTJets").getRootHisto().Clone("TTJets") hetattQ_btag = hetabQ.histoMgr.getHisto("TTJets").getRootHisto() # tagged et / et hetattQ_btag.Divide(hetattQ) hetattQ_btag.SetName("btagEffttQ_eta") hetawjetQ = hetaQ.histoMgr.getHisto("WJets").getRootHisto().Clone("WJets") hetawjetQ_btag = hetabQ.histoMgr.getHisto("WJets").getRootHisto() # tagged et / et hetawjetQ_btag.Divide(hetawjetQ) hetawjetQ_btag.SetName("btagEffwjet_eta") hetaqcdQ = hetaQ.histoMgr.getHisto("QCD").getRootHisto().Clone("QCD") hetaqcdQ_btag = hetabQ.histoMgr.getHisto("QCD").getRootHisto() # tagged et / et hetaqcdQ_btag.Divide(hetaqcdQ) hetaqcdQ_btag.SetName("btagEffqcd_eta") canvas5aq = ROOT.TCanvas("canvas5aq", "", 500, 500) canvas5aq.SetLogy() heta120Q_btag.SetMinimum(0.001) heta120Q_btag.SetMarkerColor(2) heta120Q_btag.SetMarkerSize(1) heta120Q_btag.SetMarkerStyle(21) heta120Q_btag.SetLineStyle(1) heta120Q_btag.SetLineWidth(1) heta120Q_btag.Draw("P") heta80Q_btag.SetMarkerColor(4) heta80Q_btag.SetMarkerSize(1) heta80Q_btag.SetMarkerStyle(22) heta80Q_btag.SetLineStyle(1) heta80Q_btag.SetLineColor(4) heta80Q_btag.SetLineWidth(1) # heta80Q_btag.Draw("same") heta160Q_btag.SetMarkerColor(7) heta160Q_btag.SetMarkerSize(1) heta160Q_btag.SetMarkerStyle(25) heta160Q_btag.SetLineStyle(1) heta160Q_btag.SetLineColor(7) heta160Q_btag.SetLineWidth(1) # heta160Q_btag.Draw("same") hetattQ_btag.SetMarkerColor(6) hetattQ_btag.SetMarkerSize(1) hetattQ_btag.SetMarkerStyle(24) hetattQ_btag.SetLineStyle(1) hetattQ_btag.SetLineColor(6) hetattQ_btag.SetLineWidth(1) hetattQ_btag.Draw("same") hetawjetQ_btag.SetMarkerColor(4) hetawjetQ_btag.SetMarkerSize(1) hetawjetQ_btag.SetMarkerStyle(22) hetawjetQ_btag.SetLineStyle(1) hetawjetQ_btag.SetLineColor(4) hetawjetQ_btag.SetLineWidth(1) hetawjetQ_btag.Draw("same") hetaqcdQ_btag.SetMarkerColor(1) hetaqcdQ_btag.SetMarkerSize(1) hetaqcdQ_btag.SetMarkerStyle(25) hetaqcdQ_btag.SetLineStyle(1) hetaqcdQ_btag.SetLineColor(1) hetaqcdQ_btag.SetLineWidth(1) hetaqcdQ_btag.Draw("same") heta120Q_btag.GetYaxis().SetTitle("B-tagging efficiency") # hmt.GetYaxis().SetTitleSize(20.0) # data_btag.GetYaxis().SetTitleOffset(1.5) heta120Q_btag.GetXaxis().SetTitle("#eta^{jet}") tex1 = ROOT.TLatex(0.25, 0.9, "m_{H^{#pm}} = 120 GeV/c^{2}") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.22, 0.915, heta120Q_btag.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(heta120Q_btag.GetMarkerColor()) marker1.SetMarkerSize(0.9 * heta120Q_btag.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.25, 0.85, "m_{H^{#pm}} = 80 GeV/c^{2}") tex2.SetNDC() tex2.SetTextSize(20) # tex2.Draw() marker2 = ROOT.TMarker(0.22, 0.855, heta80Q_btag.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(heta80Q_btag.GetMarkerColor()) marker2.SetMarkerSize(0.9 * heta80Q_btag.GetMarkerSize()) # marker2.Draw() tex3 = ROOT.TLatex(0.25, 0.8, "m_{H^{#pm}} = 160 GeV/c^{2}") tex3.SetNDC() tex3.SetTextSize(20) # tex3.Draw() marker3 = ROOT.TMarker(0.22, 0.815, heta160Q_btag.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(heta160Q_btag.GetMarkerColor()) marker3.SetMarkerSize(0.9 * heta160Q_btag.GetMarkerSize()) # marker3.Draw() tex4 = ROOT.TLatex(0.25, 0.85, "tt") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() marker4 = ROOT.TMarker(0.22, 0.855, hetattQ_btag.GetMarkerStyle()) marker4.SetNDC() marker4.SetMarkerColor(hetattQ_btag.GetMarkerColor()) marker4.SetMarkerSize(0.9 * hetattQ_btag.GetMarkerSize()) marker4.Draw() tex6 = ROOT.TLatex(0.25, 0.8, "Wjets") tex6.SetNDC() tex6.SetTextSize(20) tex6.Draw() marker6 = ROOT.TMarker(0.22, 0.815, hetawjetQ_btag.GetMarkerStyle()) marker6.SetNDC() marker6.SetMarkerColor(hetawjetQ_btag.GetMarkerColor()) marker6.SetMarkerSize(0.9 * hetawjetQ_btag.GetMarkerSize()) marker6.Draw() tex7 = ROOT.TLatex(0.25, 0.75, "QCD") tex7.SetNDC() tex7.SetTextSize(20) tex7.Draw() marker7 = ROOT.TMarker(0.22, 0.755, hetaqcdQ_btag.GetMarkerStyle()) marker7.SetNDC() marker7.SetMarkerColor(hetaqcdQ_btag.GetMarkerColor()) marker7.SetMarkerSize(0.9 * hetaqcdQ_btag.GetMarkerSize()) marker7.Draw() tex5 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex9 = ROOT.TLatex(0.4, 0.3, "Discriminator > 3.3 ") tex9.SetNDC() tex9.SetTextSize(20) tex9.Draw() canvas5aq.Print("QtagEff33_eta_mH.png") ####################################################################### canvas = ROOT.TCanvas("canvas", "", 500, 500) hpt120_btag.GetYaxis().SetTitle("B-tagging efficiency") hpt120_btag.GetXaxis().SetTitle("p_{T}^{jet} (GeV)") hpt120_btag.Draw() histo = hpt120_btag.Clone("histo") # rangeMin = htopmass.GetXaxis().GetXmin() # rangeMax = htopmass.GetXaxis().GetXmax() rangeMin = 30 rangeMax = 500 numberOfParameters = 3 # print "Fit range ",rangeMin, " - ",rangeMax class FitFunction: def __call__(self, x, par): # return exp(par[0] + par[1]*x[0]) return par[0] + par[1] * x[0] + par[2] * x[0] * x[0] # return par[0] + par[1]*x[0] + par[2]*x[0]*x[0] + par[3]*x[0]*x[0]*x[0] theFit = TF1('theFit', FitFunction(), rangeMin, rangeMax, numberOfParameters) theFit.SetParLimits(0, -20000, 20000) theFit.SetParLimits(1, -20000, 20000) theFit.SetParLimits(2, -20000, 20000) theFit.SetParLimits(3, -20000, 20000) # gStyle.SetOptFit(0) hpt120_btag.Fit(theFit, "LR") theFit.SetRange(rangeMin, rangeMax) theFit.SetLineStyle(1) theFit.SetLineWidth(2) theFit.Draw("same") tex4 = ROOT.TLatex(0.2, 0.95, "CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex2 = ROOT.TLatex(0.6, 0.7, "tt->tbH^{#pm}") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() tex3 = ROOT.TLatex(0.6, 0.6, "m_{H^{#pm}} = 120 GeV/c^{2}") tex3.SetNDC() tex3.SetTextSize(20) tex3.Draw() tex5 = ROOT.TLatex(0.6, 0.5, "No MET cut") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() print "Fit range ", rangeMin, " - ", rangeMax canvas.Print("jetEtFit.png") ########################################### canvas4 = ROOT.TCanvas("canvas4", "", 500, 500) canvas4.SetLogy() # hmt.SetMaximum(3.0) heta120_btag.SetMarkerColor(4) heta120_btag.SetMarkerSize(1) heta120_btag.SetMarkerStyle(24) heta120_btag.SetLineStyle(1) heta120_btag.SetLineColor(4) heta120_btag.SetLineWidth(1) heta120_btag.Draw("EP") heta120_btag.GetYaxis().SetTitle("B-tagging efficiency") # hmt.GetYaxis().SetTitleSize(20.0) # data_btag.GetYaxis().SetTitleOffset(1.5) heta120_btag.GetXaxis().SetTitle("#eta^{jet} ") tex4 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() canvas4.Print("btagEff_eta.png")
def invertedPurities(datasets): normData, normEWK, normFactorisedData, normFactorisedEWK = normalisation() norm_inc, normEWK_inc = normalisationInclusive() noDphi = [] noDphiEWK = [] Dphi160 = [] DphiEWK160 = [] DphiAll = [] DphiEWKAll = [] DphiAllremovett = [] DphiEWKAllremovett = [] DphiJet1 = [] DphiEWKJet1 = [] DphiJet2 = [] DphiEWKJet2 = [] hmt = [] hmtb = [] hmtv = [] hmtPhiv = [] hmet = [] hmetQCD = [] hmetEWK = [] hjetmet = [] hjetmetphi = [] hMHTJet1phi = [] hmtph = [] hmtphj1 = [] hmtphj2 = [] hmtremovett = [] DphiEWKAllbveto = [] DphiAllbveto = [] purityMet = [] purityErrMet = [] purityMtRemovett = [] purityErrMtRemovett = [] purityMtFirstDeltaPhiCut = [] purityErrMtFirstDeltaPhiCut = [] purityMtThirdDeltaPhiCut = [] purityErrMtThirdDeltaPhiCut = [] purityMtSecondDeltaPhiCut = [] purityErrMtSecondDeltaPhiCut = [] purityMtDeltaPhiCut = [] purityErrMtDeltaPhiCut = [] purityMtAfterBtagging = [] purityErrMtAfterBtagging = [] purityMTInvertedTauIdBvetoDphi = [] purityErrMTInvertedTauIdBvetoDphi = [] ## histograms in bins, normalisation and substraction of EWK contribution ## mt with 2dim deltaPhi cut for ptbin in ptbins: mt_tmp = plots.PlotBase([ datasets.getDataset("Data").getDatasetRootHisto( "Inverted/MTInvertedSecondDeltaPhiCut" + ptbin) ]) mt_tmp._setLegendStyles() mt_tmp._setLegendLabels() mt_tmp.histoMgr.setHistoDrawStyleAll("P") mt_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mt = mt_tmp.histoMgr.getHisto("Data").getRootHisto().Clone() # mt.Scale(normData[ptbin]) DphiJet2.append(mt) mtEWK_tmp = plots.PlotBase([ datasets.getDataset("EWK").getDatasetRootHisto( "Inverted/MTInvertedSecondDeltaPhiCut" + ptbin) ]) mtEWK_tmp.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtEWK_tmp._setLegendStyles() mtEWK_tmp._setLegendLabels() mtEWK_tmp.histoMgr.setHistoDrawStyleAll("P") mtEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mtEWK = mtEWK_tmp.histoMgr.getHisto("EWK").getRootHisto().Clone() # mtEWK.Scale(normEWK[ptbin]) # mt.Add(mtEWK, -1) # hmt.append(mt) DphiEWKJet2.append(mtEWK) purity = -999 error = -999 if mt.Integral() > 0: purity = (mt.Integral() - mtEWK.Integral()) / mt.Integral() error = sqrt(purity * (1 - purity) / mt.Integral()) purityMtSecondDeltaPhiCut.append(purity) purityErrMtSecondDeltaPhiCut.append(error) # print " pt bin ", ptbin, " purity Mt Second Delta Phi Cut = ",purity, " error ",error ############################################ # mt after b tagging mtb_tmp = plots.PlotBase([ datasets.getDataset("Data").getDatasetRootHisto( "Inverted/MTInvertedTauIdBtag" + ptbin) ]) mtb_tmp._setLegendStyles() mtb_tmp._setLegendLabels() mtb_tmp.histoMgr.setHistoDrawStyleAll("P") mtb_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mtb = mtb_tmp.histoMgr.getHisto("Data").getRootHisto().Clone() # mtb.Scale(normData[ptbin]) hmt.append(mtb) noDphi.append(mtb) mtbEWK_tmp = plots.PlotBase([ datasets.getDataset("EWK").getDatasetRootHisto( "Inverted/MTInvertedTauIdBtag" + ptbin) ]) mtbEWK_tmp.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtbEWK_tmp._setLegendStyles() mtbEWK_tmp._setLegendLabels() mtbEWK_tmp.histoMgr.setHistoDrawStyleAll("P") mtbEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mtbEWK = mtbEWK_tmp.histoMgr.getHisto("EWK").getRootHisto().Clone() # mtbEWK.Scale(normEWK[ptbin]) mtb.Add(mtbEWK, -1) hmtb.append(mtb) noDphiEWK.append(mtbEWK) purity = -999 error = -999 if mtb.Integral() > 0: purity = (mtb.Integral() - mtbEWK.Integral()) / mtb.Integral() error = sqrt(purity * (1 - purity) / mtb.Integral()) purityMtAfterBtagging.append(purity) purityErrMtAfterBtagging.append(error) # print " pt bin ", ptbin, " purity Mt After Btagging = ",purity, " error ",error ############################################ # mt after deltaPhi cut mtph_tmp = plots.PlotBase([ datasets.getDataset("Data").getDatasetRootHisto( "Inverted/MTInvertedTauIdJetDphi" + ptbin) ]) mtph_tmp._setLegendStyles() mtph_tmp._setLegendLabels() mtph_tmp.histoMgr.setHistoDrawStyleAll("P") mtph_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mtph = mtph_tmp.histoMgr.getHisto("Data").getRootHisto().Clone() # mtph.Scale(normData[ptbin]) # hmt.append(mt) Dphi160.append(mtph) mtphEWK_tmp = plots.PlotBase([ datasets.getDataset("EWK").getDatasetRootHisto( "Inverted/MTInvertedTauIdJetDphi" + ptbin) ]) mtphEWK_tmp.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtphEWK_tmp._setLegendStyles() mtphEWK_tmp._setLegendLabels() mtphEWK_tmp.histoMgr.setHistoDrawStyleAll("P") mtphEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mtphEWK = mtphEWK_tmp.histoMgr.getHisto("EWK").getRootHisto().Clone() # mtphEWK.Scale(normEWK[ptbin]) # mtph.Add(mtphEWK, -1) # hmtph.append(mtph) DphiEWK160.append(mtphEWK) purity = -999 error = -999 if mtph.Integral() > 0: purity = (mtph.Integral() - mtphEWK.Integral()) / mtph.Integral() error = sqrt(purity * (1 - purity) / mtph.Integral()) purityMtDeltaPhiCut.append(purity) purityErrMtDeltaPhiCut.append(error) # print " pt bin ", ptbin, " purity Mt DeltaPhi Cut = ",purity, " error ",error ############################################ # mt after deltaphi vs MHTjet1 cut mtphj1_tmp = plots.PlotBase([ datasets.getDataset("Data").getDatasetRootHisto( "Inverted/MTInvertedFirstDeltaPhiCut" + ptbin) ]) #mtphj1_tmp = plots.PlotBase([datasets.getDataset("Data").getDatasetRootHisto("MTInvertedTauIdMet"+ptbin)]) mtphj1_tmp._setLegendStyles() mtphj1_tmp._setLegendLabels() mtphj1_tmp.histoMgr.setHistoDrawStyleAll("P") mtphj1_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mtphj1 = mtphj1_tmp.histoMgr.getHisto("Data").getRootHisto().Clone() # mtphj1.Scale(normData[ptbin]) DphiJet1.append(mtphj1) mtphj1EWK_tmp = plots.PlotBase([ datasets.getDataset("EWK").getDatasetRootHisto( "Inverted/MTInvertedFirstDeltaPhiCut" + ptbin) ]) #mtphj1EWK_tmp = plots.PlotBase([datasets.getDataset("EWK").getDatasetRootHisto("MTInvertedTauIdMet"+ptbin)]) mtphj1EWK_tmp.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtphj1EWK_tmp._setLegendStyles() mtphj1EWK_tmp._setLegendLabels() mtphj1EWK_tmp.histoMgr.setHistoDrawStyleAll("P") mtphj1EWK_tmp.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(20)) mtphj1EWK = mtphj1EWK_tmp.histoMgr.getHisto( "EWK").getRootHisto().Clone() # mtphj1EWK.Scale(normEWK[ptbin]) # mtphj1.Add(mtphj1EWK, -1) # hmtphj1.append(mtphj1) DphiEWKJet1.append(mtphj1EWK) purity = -999 error = -999 if mtphj1.Integral() > 0: purity = (mtphj1.Integral() - mtphj1EWK.Integral()) / mtphj1.Integral() error = sqrt(purity * (1 - purity) / mtphj1.Integral()) purityMtFirstDeltaPhiCut.append(purity) purityErrMtFirstDeltaPhiCut.append(error) # print " pt bin ", ptbin, " purity Mt First Delta Phi Cut = ",purity, " error ",error ############################################ # mt after all cuts mtphj2_tmp = plots.PlotBase([ datasets.getDataset("Data").getDatasetRootHisto( "Inverted/MTInvertedThirdDeltaPhiCut" + ptbin) ]) mtphj2_tmp._setLegendStyles() mtphj2_tmp._setLegendLabels() mtphj2_tmp.histoMgr.setHistoDrawStyleAll("P") mtphj2_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mtphj2 = mtphj2_tmp.histoMgr.getHisto("Data").getRootHisto().Clone() # mtphj2.Scale(normData[ptbin]) # hmt.append(mt) DphiAll.append(mtphj2) mtphj2EWK_tmp = plots.PlotBase([ datasets.getDataset("EWK").getDatasetRootHisto( "Inverted/MTInvertedThirdDeltaPhiCut" + ptbin) ]) mtphj2EWK_tmp.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtphj2EWK_tmp._setLegendStyles() mtphj2EWK_tmp._setLegendLabels() mtphj2EWK_tmp.histoMgr.setHistoDrawStyleAll("P") mtphj2EWK_tmp.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(20)) mtphj2EWK = mtphj2EWK_tmp.histoMgr.getHisto( "EWK").getRootHisto().Clone() # mtphj2EWK.Scale(normEWK[ptbin]) # mtphj2.Add(mtphj2EWK, -1) # hmtphj2.append(mtphj2) DphiEWKAll.append(mtphj2EWK) purity = -999 error = -999 if mtphj2.Integral() > 0: purity = (mtphj2.Integral() - mtphj2EWK.Integral()) / mtphj2.Integral() error = sqrt(purity * (1 - purity) / mtphj2.Integral()) purityMtThirdDeltaPhiCut.append(purity) purityErrMtThirdDeltaPhiCut.append(error) # print " pt bin ", ptbin, " purity Mt Third Delta Phi Cut = ",purity, " error ",error ####################### # mt with cut against tt mtremovett_tmp = plots.PlotBase([ datasets.getDataset("Data").getDatasetRootHisto( "Inverted/MTInvertedAgainstTTCut" + ptbin) ]) mtremovett_tmp._setLegendStyles() mtremovett_tmp._setLegendLabels() mtremovett_tmp.histoMgr.setHistoDrawStyleAll("P") mtremovett_tmp.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(20)) mtremovett = mtremovett_tmp.histoMgr.getHisto( "Data").getRootHisto().Clone() # mtremovett.Scale(normData[ptbin]) DphiAllremovett.append(mtremovett) mtremovettEWK_tmp = plots.PlotBase([ datasets.getDataset("EWK").getDatasetRootHisto( "Inverted/MTInvertedAgainstTTCut" + ptbin) ]) mtremovettEWK_tmp.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtremovettEWK_tmp._setLegendStyles() mtremovettEWK_tmp._setLegendLabels() mtremovettEWK_tmp.histoMgr.setHistoDrawStyleAll("P") mtremovettEWK_tmp.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(20)) mtremovettEWK = mtremovettEWK_tmp.histoMgr.getHisto( "EWK").getRootHisto().Clone() # mtremovettEWK.Scale(normEWK[ptbin]) # mtremovett.Add(mtremovettEWK, -1) # hmtremovett.append(mtremovett) DphiEWKAllremovett.append(mtremovettEWK) purity = -999 error = -999 if mtremovett.Integral() > 0: purity = (mtremovett.Integral() - mtremovettEWK.Integral()) / mtremovett.Integral() error = sqrt(purity * (1 - purity) / mtremovett.Integral()) purityMtRemovett.append(purity) purityErrMtRemovett.append(error) print "mtremovett.Integral() ", mtremovett.Integral( ), " mmtEWK.Integral() ", mtremovettEWK.Integral() ####################### ### MET mmt_tmp = plots.PlotBase([ datasets.getDataset("Data").getDatasetRootHisto( "Inverted/MET_InvertedTauIdJets" + ptbin) ]) mmt_tmp._setLegendStyles() mmt_tmp._setLegendLabels() mmt_tmp.histoMgr.setHistoDrawStyleAll("P") mmt_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mmt = mmt_tmp.histoMgr.getHisto("Data").getRootHisto().Clone() ## mmt.Scale(normData[ptbin]) hmet.append(mmt) mmtEWK_tmp = plots.PlotBase([ datasets.getDataset("EWK").getDatasetRootHisto( "Inverted/MET_InvertedTauIdJets" + ptbin) ]) mmtEWK_tmp.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mmtEWK_tmp._setLegendStyles() mmtEWK_tmp._setLegendLabels() mmtEWK_tmp.histoMgr.setHistoDrawStyleAll("P") mmtEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mmtEWK = mmtEWK_tmp.histoMgr.getHisto("EWK").getRootHisto().Clone() ## mmtEWK.Scale(normEWK[ptbin]) mmt.Add(mmtEWK, -1) hmetQCD.append(mmt) hmetEWK.append(mmtEWK) purity = -999 error = -999 if mmt.Integral() > 0: purity = (mmt.Integral() - mmtEWK.Integral()) / mmt.Integral() error = sqrt(purity * (1 - purity) / mmt.Integral()) purityMet.append(purity) purityErrMet.append(error) ## print "mmt.Integral() ",mmt.Integral(), " mmtEWK.Integral() ", mmtEWK.Integral() ############################################ # mt after all cuts mtphj2_tmp = plots.PlotBase([ datasets.getDataset("Data").getDatasetRootHisto( "Inverted/MTInvertedTauIdBvetoDphi" + ptbin) ]) mtphj2_tmp._setLegendStyles() mtphj2_tmp._setLegendLabels() mtphj2_tmp.histoMgr.setHistoDrawStyleAll("P") mtphj2_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20)) mtphj2 = mtphj2_tmp.histoMgr.getHisto("Data").getRootHisto().Clone() # mtphj2.Scale(normData[ptbin]) # hmt.append(mt) DphiAllbveto.append(mtphj2) mtphj2EWK_tmp = plots.PlotBase([ datasets.getDataset("EWK").getDatasetRootHisto( "Inverted/MTInvertedTauIdBvetoDphi" + ptbin) ]) mtphj2EWK_tmp.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtphj2EWK_tmp._setLegendStyles() mtphj2EWK_tmp._setLegendLabels() mtphj2EWK_tmp.histoMgr.setHistoDrawStyleAll("P") mtphj2EWK_tmp.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(20)) mtphj2EWK = mtphj2EWK_tmp.histoMgr.getHisto( "EWK").getRootHisto().Clone() # mtphj2EWK.Scale(normEWK[ptbin]) # mtphj2.Add(mtphj2EWK, -1) # hmtphj2.append(mtphj2) DphiEWKAllbveto.append(mtphj2EWK) purity = -999 error = -999 if mtphj2.Integral() > 0: purity = (mtphj2.Integral() - mtphj2EWK.Integral()) / mtphj2.Integral() error = sqrt(purity * (1 - purity) / mtphj2.Integral()) purityMTInvertedTauIdBvetoDphi.append(purity) purityErrMTInvertedTauIdBvetoDphi.append(error) # print " pt bin ", ptbin, " purity Mt Third Delta Phi Cut = ",purity, " error ",error print " " print " purity met = ", purityMet, " error ", purityErrMet print " purity Mt no DeltaPhi Cuts = ", purityMtAfterBtagging, " error ", purityErrMtAfterBtagging print " purity Mt DeltaPhi160 Cut = ", purityMtDeltaPhiCut, " error ", purityErrMtDeltaPhiCut print " purity Mt First DeltaPhi Cut = ", purityMtFirstDeltaPhiCut, " error ", purityErrMtFirstDeltaPhiCut print " purity Mt Second DeltaPhi Cut = ", purityMtSecondDeltaPhiCut, " error ", purityErrMtSecondDeltaPhiCut print " purity Mt Third Delta Phi Cut = ", purityMtThirdDeltaPhiCut, " error ", purityErrMtThirdDeltaPhiCut print " purity Mt b veto deltaPhi Cuts = ", purityMTInvertedTauIdBvetoDphi, " error ", purityErrMTInvertedTauIdBvetoDphi print " purity Mt Remove tt = ", purityMtRemovett, " error ", purityErrMtRemovett invertedQCD = InvertedTauID() invertedQCD.setLumi(datasets.getDataset("Data").getLuminosity()) ### Met met = hmet[0].Clone("met") met.SetName("MET") met.SetTitle("Inverted tau Met") met.Reset() for histo in hmet: met.Add(histo) metQCD = hmetQCD[0].Clone("met") metQCD.SetName("MET") metQCD.SetTitle("Inverted tau Met") metQCD.Reset() for histo in hmetQCD: metQCD.Add(histo) metEWK = hmetEWK[0].Clone("metewk") metEWK.SetName("METewk") metEWK.SetTitle("Inverted tau Met") metEWK.Reset() for histo in hmetEWK: metEWK.Add(histo) ### Mt no DeltaPhi Cuts mtNoDphi = noDphi[0].Clone("mt") mtNoDphi.SetName("mt") mtNoDphi.SetTitle("Inverted tau Mt") mtNoDphi.Reset() for histo in noDphi: mtNoDphi.Add(histo) mtNoDphiEWK = noDphiEWK[0].Clone("mtewk") mtNoDphiEWK.SetName("MTewk") mtNoDphiEWK.SetTitle("Inverted tau Met") mtNoDphiEWK.Reset() for histo in noDphiEWK: mtNoDphiEWK.Add(histo) ### Mt DeltaPhi < 160 Cut mtDphi160 = Dphi160[0].Clone("mt") mtDphi160.SetName("mt") mtDphi160.SetTitle("Inverted tau Mt") mtDphi160.Reset() for histo in Dphi160: mtDphi160.Add(histo) mtDphi160EWK = DphiEWK160[0].Clone("mtewk") mtDphi160EWK.SetName("MTewk") mtDphi160EWK.SetTitle("Inverted tau Met") mtDphi160EWK.Reset() for histo in DphiEWK160: mtDphi160EWK.Add(histo) ### Mt Mt all dphi cuts mtDphiAll = DphiAll[0].Clone("mt") mtDphiAll.SetName("mt") mtDphiAll.SetTitle("Inverted tau Mt") mtDphiAll.Reset() for histo in DphiAll: mtDphiAll.Add(histo) mtDphiAllEWK = DphiEWKAll[0].Clone("mtewk") mtDphiAllEWK.SetName("MTewk") mtDphiAllEWK.SetTitle("Inverted tau Met") mtDphiAllEWK.Reset() for histo in DphiEWKAll: mtDphiAllEWK.Add(histo) ### Mt bveto all dphi cuts mtDphiAllbveto = DphiAllbveto[0].Clone("mt") mtDphiAllbveto.SetName("mt") mtDphiAllbveto.SetTitle("Inverted tau Mt") mtDphiAllbveto.Reset() for histo in DphiAllbveto: mtDphiAllbveto.Add(histo) mtDphiAllEWKbveto = DphiEWKAllbveto[0].Clone("mtewk") mtDphiAllEWKbveto.SetName("MTewk") mtDphiAllEWKbveto.SetTitle("Inverted tau Met") mtDphiAllEWKbveto.Reset() for histo in DphiEWKAllbveto: mtDphiAllEWKbveto.Add(histo) ### Mt Mt dphi jet1 mtDphiJet1 = DphiJet1[0].Clone("mt") mtDphiJet1.SetName("mt") mtDphiJet1.SetTitle("Inverted tau Mt") mtDphiJet1.Reset() for histo in DphiJet1: mtDphiJet1.Add(histo) mtDphiEWKJet1 = DphiEWKJet1[0].Clone("mtewk") mtDphiEWKJet1.SetName("MTewk") mtDphiEWKJet1.SetTitle("Inverted tau Met") mtDphiEWKJet1.Reset() for histo in DphiEWKJet1: mtDphiEWKJet1.Add(histo) ### Mt Mt dphi jet2 mtDphiJet2 = DphiJet2[0].Clone("mt") mtDphiJet2.SetName("mt") mtDphiJet2.SetTitle("Inverted tau Mt") mtDphiJet2.Reset() for histo in DphiJet2: mtDphiJet2.Add(histo) mtDphiEWKJet2 = DphiEWKJet2[0].Clone("mtewk") mtDphiEWKJet2.SetName("MTewk") mtDphiEWKJet2.SetTitle("Inverted tau Met") mtDphiEWKJet2.Reset() for histo in DphiEWKJet2: mtDphiEWKJet2.Add(histo) ### Mt all dphi + tt cuts mtDphiAllremovett = DphiAllremovett[0].Clone("mt") mtDphiAllremovett.SetName("mt") mtDphiAllremovett.SetTitle("Inverted tau Mt") mtDphiAllremovett.Reset() for histo in DphiAllremovett: mtDphiAllremovett.Add(histo) mtDphiAllremovettEWK = DphiEWKAllremovett[0].Clone("mtewk") mtDphiAllremovettEWK.SetName("MTewk") mtDphiAllremovettEWK.SetTitle("Inverted tau Met") mtDphiAllremovettEWK.Reset() for histo in DphiEWKAllremovett: mtDphiAllremovettEWK.Add(histo) ########################################## # met purity metqcd = metQCD.Clone("metqcd") metinv = met.Clone("met") invertedQCD.setLabel("MetPurity") # invertedQCD.mtComparison(metqcd, metqcd,"MetPurity") ########################################## # mt purity no deltaPhi mtQCD = mtNoDphi.Clone("QCD") mtQCD.Add(mtNoDphiEWK, -1) mtQCD.Divide(mtNoDphi) mtqcd = mtQCD.Clone("mtqcd") invertedQCD.setLabel("MtNoDeltaPhiCuts") invertedQCD.mtComparison(mtQCD, mtQCD, "MtNoDeltaPhiCuts") ########################################## # mt purity deltaPhi 160 mtQCD = mtDphi160.Clone("QCD") mtQCD.Add(mtDphi160EWK, -1) mtQCD.Divide(mtDphi160) mtqcd = mtQCD.Clone("mtqcd") invertedQCD.setLabel("MtDeltaPhi160") invertedQCD.mtComparison(mtQCD, mtQCD, "MtDeltaPhi160") ########################################## # mt purity all deltaPhi cuts mtQCD = mtDphiAll.Clone("QCD") mtQCD.Add(mtDphiAllEWK, -1) mtQCD.Divide(mtDphiAll) mtqcd = mtQCD.Clone("mtqcd") invertedQCD.setLabel("MtAllDeltaPhiCuts") invertedQCD.mtComparison(mtQCD, mtQCD, "MtAllDeltaPhiCuts") ########################################## # mt bveto purity all deltaPhi cuts ## test invertedQCD.setLabel("testMtbveto") # invertedQCD.mtComparison(mtDphiAllbveto, mtDphiAllbveto,"testMtbveto") invertedQCD.setLabel("testEWKMtbveto") # invertedQCD.mtComparison(mtDphiAllEWKbveto, mtDphiAllEWKbveto,"testEWKMtbveto") mtQCD = mtDphiAllbveto.Clone("QCD") mtQCD.Add(mtDphiAllEWKbveto, -1) mtQCD.Divide(mtDphiAllbveto) mtqcd = mtQCD.Clone("mtqcd") invertedQCD.setLabel("MtbvetoAllDeltaPhiCuts") invertedQCD.mtComparison(mtQCD, mtQCD, "MtbvetoAllDeltaPhiCuts") ########################################## # mt purity jet1 deltaPhi cuts mtQCD = mtDphiJet1.Clone("QCD") mtQCD.Add(mtDphiEWKJet1, -1) mtQCD.Divide(mtDphiJet1) mtqcd = mtQCD.Clone("mtqcd") invertedQCD.setLabel("MtDeltaPhiJet1Cuts") invertedQCD.mtComparison(mtQCD, mtQCD, "MtDeltaPhiJet1Cuts") ########################################## # mt purity jet2 deltaPhi cuts mtQCD = mtDphiJet2.Clone("QCD") mtQCD.Add(mtDphiEWKJet2, -1) mtQCD.Divide(mtDphiJet2) mtqcd = mtQCD.Clone("mtqcd") invertedQCD.setLabel("MtDeltaPhiJet2Cuts") invertedQCD.mtComparison(mtQCD, mtQCD, "MtDeltaPhiJet2Cuts") ########################################## # mt purity all deltaPhi cuts and against tt cut mtQCD = mtDphiAllremovett.Clone("QCD") mtQCD.Add(mtDphiAllremovettEWK, -1) mtQCD.Divide(mtDphiAllremovett) mtqcd = mtQCD.Clone("mtqcd") invertedQCD.setLabel("MtDeltaPhiAndAgainsttt") invertedQCD.mtComparison(mtQCD, mtQCD, "MtDeltaPhiAndAgainsttt") ################################################# ## purities as a function of pt tau jet ### Create and customise TGraph cEff = TCanvas("MetPurity", "MetPurity", 1) cEff.cd() ptbin_error = array.array("d", [5, 5, 5, 5, 10, 10, 30]) ptbin = array.array("d", [45, 55, 65, 75, 90, 110, 150]) graph = TGraphErrors(7, ptbin, array.array("d", purityMTInvertedTauIdBvetoDphi), ptbin_error, array.array("d", purityErrMTInvertedTauIdBvetoDphi)) graph.SetMaximum(1.0) graph.SetMinimum(0.6) graph.SetMarkerStyle(kFullCircle) graph.SetMarkerColor(kBlue) graph.SetMarkerSize(1) graph.GetYaxis().SetTitle("QCD purity") graph.GetXaxis().SetTitle("p_{T}^{#tau jet} [GeV/c]") ### Re-draw graph and update canvas and gPad graph.Draw("AP") tex4 = ROOT.TLatex( 0.2, 0.955, "8 TeV 12.2 fb^{-1} CMS preliminary") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex1 = ROOT.TLatex(0.35, 0.35, "B-tagging factorisation") tex1.SetNDC() tex1.SetTextSize(25) tex1.Draw() tex2 = ROOT.TLatex(0.35, 0.27, "#Delta#phi cuts") tex2.SetNDC() tex2.SetTextSize(25) tex2.Draw() cEff.Update() cEff.SaveAs("purityMTInvertedTauIdBvetoDphiBins.png") graph = TGraphErrors(7, ptbin, array.array("d", purityMet), ptbin_error, array.array("d", purityErrMet)) graph.SetMaximum(1.1) graph.SetMinimum(0.8) graph.SetMarkerStyle(kFullCircle) graph.SetMarkerColor(kBlue) graph.SetMarkerSize(1) graph.GetYaxis().SetTitle("QCD purity") graph.GetXaxis().SetTitle("p_{T}^{#tau jet} [GeV/c]") ### Re-draw graph and update canvas and gPad graph.Draw("AP") tex4 = ROOT.TLatex( 0.2, 0.955, "8 TeV 12.2 fb^{-1} CMS preliminary") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex1 = ROOT.TLatex(0.35, 0.35, "Inverted #tau jet isolation") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() tex2 = ROOT.TLatex(0.35, 0.3, "at least 3 jets") tex2.SetNDC() tex2.SetTextSize(25) tex2.Draw() cEff.Update() cEff.SaveAs("purityMetPtBins.png") ## Mt without deltaPhi cuts cEff = TCanvas("MtNoDeltaPhiCutsPurity", "MtNoDeltaPhiCutsPurity", 1) cEff.cd() graph = TGraphErrors(7, ptbin, array.array("d", purityMtAfterBtagging), ptbin_error, array.array("d", purityErrMtAfterBtagging)) graph.SetMaximum(1.0) graph.SetMinimum(0.4) graph.SetMarkerStyle(kFullCircle) graph.SetMarkerColor(kBlue) graph.SetMarkerSize(1) graph.GetYaxis().SetTitle("QCD purity") graph.GetXaxis().SetTitle("p_{T}^{#tau jet} [GeV]") ### Re-draw graph and update canvas and gPad graph.Draw("AP") tex4 = ROOT.TLatex( 0.2, 0.955, "8 TeV 12.2 fb^{-1} CMS preliminary") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex1 = ROOT.TLatex(0.5, 0.38, "All selection cuts") tex1.SetNDC() tex1.SetTextSize(22) tex1.Draw() tex2 = ROOT.TLatex(0.5, 0.3, "no #Delta#phi cuts") tex2.SetNDC() tex2.SetTextSize(25) tex2.Draw() cEff.Update() cEff.SaveAs("purityMtNoDeltaPhiCutsBins.png") ## Mt without deltaPhi cuts cEff = TCanvas("MtDeltaPhi160Purity", "MtDeltaPhi160Purity", 1) cEff.cd() graph = TGraphErrors(7, ptbin, array.array("d", purityMtDeltaPhiCut), ptbin_error, array.array("d", purityErrMtDeltaPhiCut)) graph.SetMaximum(1.0) graph.SetMinimum(0.4) graph.SetMarkerStyle(kFullCircle) graph.SetMarkerColor(kBlue) graph.SetMarkerSize(1) graph.GetYaxis().SetTitle("QCD purity") graph.GetXaxis().SetTitle("p_{T}^{#tau jet} [GeV]") ### Re-draw graph and update canvas and gPad graph.Draw("AP") tex4 = ROOT.TLatex( 0.2, 0.955, "8 TeV 12.2 fb^{-1} CMS preliminary") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex1 = ROOT.TLatex(0.5, 0.35, "All selection cuts") tex1.SetNDC() tex1.SetTextSize(24) tex1.Draw() tex2 = ROOT.TLatex(0.5, 0.25, "#Delta#phi(#tau jet,MET) < 160^{o}") tex2.SetNDC() tex2.SetTextSize(24) tex2.Draw() cEff.Update() cEff.SaveAs("purityMtDeltaPhi160Bins.png") ## Mt 1st deltaPhi cut cEff = TCanvas("MtFirstDeltaCutPurity", "MtFirstDeltaPhiCutPurity", 1) cEff.cd() graph = TGraphErrors(7, ptbin, array.array("d", purityMtFirstDeltaPhiCut), ptbin_error, array.array("d", purityErrMtFirstDeltaPhiCut)) graph.SetMaximum(1.0) graph.SetMinimum(0.4) graph.SetMarkerStyle(kFullCircle) graph.SetMarkerColor(kBlue) graph.SetMarkerSize(1) graph.GetYaxis().SetTitle("QCD purity") graph.GetXaxis().SetTitle("p_{T}^{#tau jet} [GeV]") ### Re-draw graph and update canvas and gPad graph.Draw("AP") tex4 = ROOT.TLatex( 0.2, 0.955, "8 TeV 12.2 fb^{-1} CMS preliminary") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex1 = ROOT.TLatex(0.4, 0.4, "All selection cuts") tex1.SetNDC() tex1.SetTextSize(24) tex1.Draw() tex2 = ROOT.TLatex(0.3, 0.3, "#Delta#phi(#tau jet,MET) vs #Delta#phi(jet1,MET) cut") tex2.SetNDC() tex2.SetTextSize(24) tex2.Draw() cEff.Update() cEff.SaveAs("purityMtFirstDeltaPhiCutBins.png") ## Mt 2nd deltaPhi cut cEff = TCanvas("MtSecondDeltaCutPurity", "MtFirstSecondPhiCutPurity", 1) cEff.cd() graph = TGraphErrors(7, ptbin, array.array("d", purityMtSecondDeltaPhiCut), ptbin_error, array.array("d", purityErrMtSecondDeltaPhiCut)) graph.SetMaximum(1.0) graph.SetMinimum(0.4) graph.SetMarkerStyle(kFullCircle) graph.SetMarkerColor(kBlue) graph.SetMarkerSize(1) graph.GetYaxis().SetTitle("QCD purity") graph.GetXaxis().SetTitle("p_{T}^{#tau jet} [GeV]") ### Re-draw graph and update canvas and gPad graph.Draw("AP") tex4 = ROOT.TLatex( 0.2, 0.955, "8 TeV 12.2 fb^{-1} CMS preliminary") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex1 = ROOT.TLatex(0.2, 0.88, "All selection cuts") tex1.SetNDC() tex1.SetTextSize(22) tex1.Draw() tex2 = ROOT.TLatex( 0.2, 0.8, "#Delta#phi(#tau jet,MET) vs #Delta#phi(jet1/2,MET) cuts") tex2.SetNDC() tex2.SetTextSize(24) tex2.Draw() cEff.Update() cEff.SaveAs("purityMtSecondDeltaPhiCutBins.png") ## Mt 2nd deltaPhi cut cEff = TCanvas("MtThirdDeltaCutPurity", "MtThirdDeltaPhiCutPurity", 1) cEff.cd() graph = TGraphErrors(7, ptbin, array.array("d", purityMtThirdDeltaPhiCut), ptbin_error, array.array("d", purityErrMtThirdDeltaPhiCut)) graph.SetMaximum(1.0) graph.SetMinimum(0.4) graph.SetMarkerStyle(kFullCircle) graph.SetMarkerColor(kBlue) graph.SetMarkerSize(1) graph.GetYaxis().SetTitle("QCD purity") graph.GetXaxis().SetTitle("p_{T}^{#tau jet} [GeV]") ### Re-draw graph and update canvas and gPad graph.Draw("AP") tex4 = ROOT.TLatex( 0.2, 0.955, "8 TeV 12.2 fb^{-1} CMS preliminary") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex1 = ROOT.TLatex(0.2, 0.88, "All selection cuts") tex1.SetNDC() tex1.SetTextSize(22) tex1.Draw() tex2 = ROOT.TLatex( 0.2, 0.8, "#Delta#phi(#tau jet,MET) vs #Delta#phi(jet1/2/3,MET) cuts") tex2.SetNDC() tex2.SetTextSize(24) tex2.Draw() cEff.Update() cEff.SaveAs("purityMtThirdDeltaPhiCutBins.png") ## Mt deltaPhi cuts and against tt cEff = TCanvas("MtMtRemovettPurity", "MtMtRemovettPurity", 1) cEff.cd() graph = TGraphErrors(7, ptbin, array.array("d", purityMtRemovett), ptbin_error, array.array("d", purityErrMtRemovett)) graph.SetMaximum(1.0) graph.SetMinimum(0.4) graph.SetMarkerStyle(kFullCircle) graph.SetMarkerColor(kBlue) graph.SetMarkerSize(1) graph.GetYaxis().SetTitle("QCD purity") graph.GetXaxis().SetTitle("p_{T}^{#tau jet} [GeV]") ### Re-draw graph and update canvas and gPad graph.Draw("AP") tex4 = ROOT.TLatex( 0.2, 0.955, "8 TeV 12.2 fb^{-1} CMS preliminary") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex1 = ROOT.TLatex(0.2, 0.88, "All selection cuts ") tex1.SetNDC() tex1.SetTextSize(22) tex1.Draw() tex2 = ROOT.TLatex( 0.2, 0.8, "#Delta#phi(#tau jet,MET) vs #Delta#phi(jet1/2/3,MET) cuts") tex2.SetNDC() tex2.SetTextSize(22) tex2.Draw() tex3 = ROOT.TLatex(0.2, 0.72, "#Delta#phi cut against tt+jets") tex3.SetNDC() tex3.SetTextSize(22) tex3.Draw() cEff.Update() cEff.SaveAs("purityMtAgainstttCutBins.png")
def plot(datasets): ptGenuineTau = plots.PlotBase([ datasets.getDataset("TTToHplusBWB_M120").getDatasetRootHisto( analysis + "/VetoTauSelection/SelectedGenuineTauByPt") ]) ptFakeTau = plots.PlotBase([ datasets.getDataset("TTToHplusBWB_M120").getDatasetRootHisto( analysis + "/VetoTauSelection/SelectedFakeTauByPt") ]) ptGenuineTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptFakeTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptGenuineTau._setLegendStyles() ptGenuineTau._setLegendLabels() ptGenuineTau.histoMgr.setHistoDrawStyleAll("P") ptGenuineTau.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptGenuineTau = ptGenuineTau.histoMgr.getHisto( "TTToHplusBWB_M120").getRootHisto().Clone( analysis + "/VetoTauSelection/SelectedGenuineTauByPt") ptFakeTau._setLegendStyles() ptFakeTau._setLegendLabels() ptFakeTau.histoMgr.setHistoDrawStyleAll("P") ptFakeTau.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptFakeTau = ptFakeTau.histoMgr.getHisto("TTToHplusBWB_M120").getRootHisto( ).Clone(analysis + "/VetoTauSelection/SelectedFakeTauByPt") canvas3 = ROOT.TCanvas("canvas3", "", 500, 500) # canvas3.SetLogy() # hptIsolEff.SetMaximum(0.1) # hptIsolEff.SetMinimum(0.002) hptGenuineTau.SetMarkerColor(4) hptGenuineTau.SetMarkerSize(1) hptGenuineTau.SetMarkerStyle(24) hptGenuineTau.Draw("EP") hptFakeTau.SetMarkerColor(2) hptFakeTau.SetMarkerSize(1) hptFakeTau.SetMarkerStyle(25) hptFakeTau.Draw("same") hptGenuineTau.GetYaxis().SetTitle("#tau jets / 25 GeV/c") hptGenuineTau.GetYaxis().SetTitleOffset(1.5) hptGenuineTau.GetXaxis().SetTitle("p_{T}^{#tau jet} (GeV/c)") tex1 = ROOT.TLatex(0.55, 0.6, "Genuine #tau jets") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.5, 0.61, hptGenuineTau.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hptGenuineTau.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hptGenuineTau.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.55, 0.55, "Fake #tau jets") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.5, 0.551, hptFakeTau.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptFakeTau.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hptFakeTau.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() tex5 = ROOT.TLatex(0.55, 0.8, "Signal, m_{H^{#pm}} = 120 GeV/c^{2}") # tex5 = ROOT.TLatex(0.55,0.9,"tt+jets") tex5.SetNDC() tex5.SetTextSize(18) tex5.Draw() canvas3.Print("PtVetoTaus_h120.png") canvas3.Print("PtVetoTaus_h120.C") ptGenuineTautt = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/VetoTauSelection/SelectedGenuineTauByPt") ]) ptFakeTautt = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/VetoTauSelection/SelectedFakeTauByPt") ]) ptGenuineTautt.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptFakeTautt.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) ptGenuineTautt._setLegendStyles() ptGenuineTautt._setLegendLabels() ptGenuineTautt.histoMgr.setHistoDrawStyleAll("P") ptGenuineTautt.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptGenuineTautt = ptGenuineTautt.histoMgr.getHisto("TTJets").getRootHisto( ).Clone(analysis + "/VetoTauSelection/SelectedGenuineTauByPt") ptFakeTautt._setLegendStyles() ptFakeTautt._setLegendLabels() ptFakeTautt.histoMgr.setHistoDrawStyleAll("P") ptFakeTautt.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hptFakeTautt = ptFakeTautt.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/VetoTauSelection/SelectedFakeTauByPt") canvas4 = ROOT.TCanvas("canvas4", "", 500, 500) # canvas3.SetLogy() hptGenuineTautt.SetMaximum(10.0) # hptIsolEff.SetMinimum(0.002) hptGenuineTautt.SetMarkerColor(4) hptGenuineTautt.SetMarkerSize(1) hptGenuineTautt.SetMarkerStyle(24) hptGenuineTautt.Draw("EP") hptFakeTautt.SetMarkerColor(2) hptFakeTautt.SetMarkerSize(1) hptFakeTautt.SetMarkerStyle(25) hptFakeTautt.Draw("same") hptGenuineTautt.GetYaxis().SetTitle("#tau jets / 25 GeV/c") hptGenuineTautt.GetYaxis().SetTitleOffset(1.5) hptGenuineTautt.GetXaxis().SetTitle("p_{T}^{#tau jet} (GeV/c)") tex1 = ROOT.TLatex(0.55, 0.7, "Genuine #tau jets") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.5, 0.71, hptGenuineTautt.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hptGenuineTautt.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hptGenuineTautt.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.55, 0.6, "Fake #tau jets") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.5, 0.61, hptFakeTautt.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hptFakeTautt.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hptFakeTautt.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() # tex5 = ROOT.TLatex(0.55,0.8,"Signal, m_{H^{#pm}} = 120 GeV/c^{2}") tex5 = ROOT.TLatex(0.55, 0.8, "tt+jets") tex5.SetNDC() tex5.SetTextSize(18) tex5.Draw() canvas4.Print("PtVetoTaus_tt.png") canvas4.Print("PtVetoTaus_tt.C") etaGenuineTautt = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/VetoTauSelection/SelectedGenuineTauByEta") ]) etaFakeTautt = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/VetoTauSelection/SelectedFakeTauByEta") ]) etaGenuineTautt.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaFakeTautt.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) etaGenuineTautt._setLegendStyles() etaGenuineTautt._setLegendLabels() etaGenuineTautt.histoMgr.setHistoDrawStyleAll("P") etaGenuineTautt.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hetaGenuineTautt = etaGenuineTautt.histoMgr.getHisto( "TTJets").getRootHisto().Clone( analysis + "/VetoTauSelection/SelectedGenuineTauByEta") etaFakeTautt._setLegendStyles() etaFakeTautt._setLegendLabels() etaFakeTautt.histoMgr.setHistoDrawStyleAll("P") etaFakeTautt.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5)) hetaFakeTautt = etaFakeTautt.histoMgr.getHisto("TTJets").getRootHisto( ).Clone(analysis + "/VetoTauSelection/SelectedFakeTauByEta") canvas5 = ROOT.TCanvas("canvas5", "", 500, 500) # canvas3.SetLogy() hetaGenuineTautt.SetMaximum(5.0) # hetaGenuineTautt.SetMinimum(0.002) hetaGenuineTautt.SetMarkerColor(4) hetaGenuineTautt.SetMarkerSize(1) hetaGenuineTautt.SetMarkerStyle(24) hetaGenuineTautt.Draw("EP") hetaFakeTautt.SetMarkerColor(2) hetaFakeTautt.SetMarkerSize(1) hetaFakeTautt.SetMarkerStyle(25) hetaFakeTautt.Draw("same") hetaGenuineTautt.GetYaxis().SetTitle("#tau jets") hetaGenuineTautt.GetYaxis().SetTitleOffset(1.5) hetaGenuineTautt.GetXaxis().SetTitle("#eta^{#tau jet}") tex1 = ROOT.TLatex(0.55, 0.85, "Genuine #tau jets") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.5, 0.86, hetaGenuineTautt.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hetaGenuineTautt.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hetaGenuineTautt.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.55, 0.8, "Fake #tau jets") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.5, 0.81, hetaFakeTautt.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hetaFakeTautt.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hetaFakeTautt.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2, 0.95, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() # tex5 = ROOT.TLatex(0.55,0.8,"Signal, m_{H^{#pm}} = 120 GeV/c^{2}") tex5 = ROOT.TLatex(0.2, 0.85, "tt+jets") tex5.SetNDC() tex5.SetTextSize(18) tex5.Draw() canvas5.Print("EtaVetoTaus_tt.png") canvas5.Print("EtaVetoTaus_tt.C")
def doPlots(table, onlyWjets, mcEvents, normalize, lumi): nrows = table.getNrows() function = ROOT.TF1("fitFunction", "[0]") function.SetParameter(0, 0) f2 = ROOT.TF1("fitG", "gaus") f2.SetLineColor(ROOT.kRed) f2.SetLineWidth(2) binning = { "Data": (8, 60, 100), "Diboson": (8, 0, 2), "DYJetsToLL": (8, 1, 5), "EWKMCsum": (8, 40, 120), "SingleTop": (8, 3, 6), "TTJets": (10, 25, 35), "W3Jets": (10, 6, 11), "WJets": (14, 10, 80), } if onlyWjets: binning["WJets"] = (24, 10, 90) if not normalize: binning["Data"] = (10, 70, 120) binning["EWKMCsum"] = (6, 60, 120) binning["SingleTop"] = (8, 4, 6) binning["TTJets"] = (10, 32, 42) binning["W3Jets"] = (12, 6, 12) if onlyWjets: binning["WJets"] = (10, 20, 60) if mcEvents: binning["TTJets"] = (12, 320, 440) binning["WJets"] = (24, 30, 90) for icol in xrange(table.getNcolumns()): name = table.getColumnNames()[icol] label = plots._legendLabels.get(name, name) if name != "Data": label += " simulation" h = ROOT.TH1F(name, name, nrows, 0, nrows) h2 = ROOT.TH1F(name+"_dist", name, *(binning.get(name, (10, 0, 100)))) mean = dataset.Count(0, 0) for irow in xrange(nrows): count = table.getCount(irow, icol) h.SetBinContent(irow+1, count.value()) h.SetBinError(irow+1, count.uncertainty()) h2.Fill(count.value()) mean.add(count) mean = dataset.Count(mean.value()/nrows, mean.uncertainty()/nrows) h.Fit("fitFunction") value = function.GetParameter(0) error = function.GetParError(0) # function.SetParameters(1., 40., 1.); # function.SetParLimits(0, 0.0, 1.0); # fitResult = graph.Fit(function, "NRSE+EX0"); # print "Fit status", fitResult.Status() # #fitResult.Print("V"); # #fitResult.GetCovarianceMatrix().Print(); # function.SetLineColor(graph.GetMarkerColor()); # function.SetLineWidth(2); function.Draw("same") ROOT.gPad.Update() stat = h.FindObject("stats") if stat: stat.SetX1NDC(0.2) stat.SetX2NDC(0.44) stat.SetY1NDC(0.2) stat.SetY2NDC(0.3) stat.SetTextColor(ROOT.kRed) stat.SetLineColor(ROOT.kRed) # return (function, fitResult) styles.dataStyle.apply(h) p = plots.PlotBase([h]) p.histoMgr.setHistoDrawStyle(name, "EP") p.createFrame("fluctuation_"+name, opts={"ymin": 0, "ymaxfactor": 1.2, "nbins": nrows}) p.frame.GetXaxis().SetTitle("Embedding trial number") ylabel = "Simulation" if name == "Data": ylabel = "Data" ylabel += " events" p.frame.GetYaxis().SetTitle(ylabel) step = 1 start = 0 if onlyWjets: start = 4 step = 5 for irow in xrange(start, nrows, step): p.frame.GetXaxis().SetBinLabel(irow+1, "%d"%(irow+1)) xmin = p.frame.GetXaxis().GetXmin() xmax = p.frame.GetXaxis().GetXmax() leg = histograms.moveLegend(histograms.createLegend(), dx=-0.07, dy=-0.6, dh=-0.15) leg.AddEntry(h, "Trial values", "P") def createLine(val, st=1, col=ROOT.kRed): l = ROOT.TLine(xmin, val, xmax, val) l.SetLineWidth(2) l.SetLineStyle(st) l.SetLineColor(col) return l fv = createLine(value) leg.AddEntry(fv, "Fitted value", "L") p.appendPlotObject(fv) # fe = createLine(value+error, ROOT.kDashed) # leg.AddEntry(fe, "Fit uncertainty", "L") # p.appendPlotObject(fe) # p.appendPlotObject(createLine(value-error, ROOT.kDashed)) v = createLine(mean.value(), col=ROOT.kBlue) leg.AddEntry(v, "Mean", "L") p.appendPlotObject(v) ve = createLine(mean.value()+mean.uncertainty(), st=ROOT.kDashed, col=ROOT.kBlue) leg.AddEntry(ve, "Mean uncertainty", "L") p.appendPlotObject(ve) p.appendPlotObject(createLine(mean.value()-mean.uncertainty(), st=ROOT.kDashed, col=ROOT.kBlue)) p.legend = leg p.appendPlotObject(histograms.PlotText(0.65, 0.33, label, size=20)) p.draw() if name != "Data": histograms.addCmsPreliminaryText(text="Simulation") histograms.addEnergyText() histograms.addLuminosityText(None, None, lumi) p.save() ############### f2.SetParameter(1, value) h2.Fit("fitG") # f2.Draw("same") ROOT.gPad.Update() stat = h2.FindObject("stats") if stat: stat.SetX1NDC(0.62) stat.SetX2NDC(0.9) stat.SetY1NDC(0.7) stat.SetY2NDC(0.85) stat.SetTextColor(ROOT.kRed) stat.SetLineColor(ROOT.kRed) styles.dataStyle.apply(h2) p = plots.PlotBase([h2]) p.histoMgr.setHistoDrawStyle(name+"_dist", "HIST") p.createFrame("fluctuation_"+name+"_dist", opts={"ymin": 0, "ymaxfactor": 1.4, "nbins": nrows}) p.frame.GetXaxis().SetTitle(ylabel) p.frame.GetYaxis().SetTitle("Occurrances") ymin = p.frame.GetYaxis().GetXmin() ymax = p.frame.GetYaxis().GetXmax() leg = histograms.moveLegend(histograms.createLegend(), dx=-0.07, dy=-0.25, dh=-0.15) leg.AddEntry(h2, "Trials", "F") leg.AddEntry(f2, "Gaussian fit", "L") def createLine2(val, st=1): l = ROOT.TLine(val, ymin, val, ymax) l.SetLineWidth(1) l.SetLineColor(ROOT.kBlue) l.SetLineStyle(st) return l p.appendPlotObject(h2, "FUNC") p.appendPlotObject(stat) p.appendPlotObject(histograms.PlotText(0.65, 0.88, label, size=20)) # fv = createLine2(value) # leg.AddEntry(fv, "Fit of values", "L") # p.appendPlotObject(fv) # fe = createLine2(value+error, ROOT.kDashed) # leg.AddEntry(fe, "Fit of values unc.", "L") # p.appendPlotObject(fe) # p.appendPlotObject(createLine2(value-error, ROOT.kDashed)) p.legend = leg p.draw() if name != "Data": histograms.addCmsPreliminaryText(text="Simulation") histograms.addEnergyText() histograms.addLuminosityText(None, None, lumi) p.save()
def plot(datasets): ############################################################ mt = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto(analysis + "/transverseMass") ]) mtMuonNotInTau = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassMuonNotInTau") ]) mtElectronNotInTau = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassElectronNotInTau") ]) mtTauNotInTau = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassTauNotInTau") ]) mtLeptonNotInTau = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassLeptonNotInTau") ]) mtNoLeptonNotInTau = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassNoLeptonNotInTau") ]) mtNoLeptonGoodMet = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassNoLeptonGoodMet") ]) mtNoLeptonGoodMetGoodTau = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassNoLeptonGoodMetGoodTau") ]) mtTopChiSelection = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassTopChiSelection") ]) mtWMassSelection = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassWmassCut") ]) mtTauVeto = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassTauVeto") ]) mtLeptonRealSignalTau = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassLeptonRealSignalTau") ]) mtLeptonFakeSignalTau = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassLeptonFakeSignalTau") ]) mtObservableLeptons = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassObservableLeptons") ]) mtNoObservableLeptons = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseNoMassObservableLeptons") ]) mt.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtElectronNotInTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtMuonNotInTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtTauNotInTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtNoLeptonNotInTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtLeptonNotInTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtNoLeptonGoodMet.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtNoLeptonGoodMetGoodTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtTopChiSelection.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtWMassSelection.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtLeptonRealSignalTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtLeptonFakeSignalTau.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtObservableLeptons.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtNoObservableLeptons.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtTauVeto.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtMetReso02 = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto( analysis + "/transverseMassMetReso02") ]) deltaEtMetGenMet = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto(analysis + "/deltaEtMetGenMet") ]) deltaPhiMetGenMet = plots.PlotBase([ datasets.getDataset("TTJets").getDatasetRootHisto(analysis + "/deltaPhiMetGenMet") ]) deltaEtMetGenMet.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) deltaPhiMetGenMet.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtMetReso02.histoMgr.normalizeMCToLuminosity( datasets.getDataset("Data").getLuminosity()) mtLeptonRealSignalTau._setLegendStyles() mtLeptonRealSignalTau._setLegendLabels() mtLeptonRealSignalTau.histoMgr.setHistoDrawStyleAll("P") mtLeptonRealSignalTau.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtLeptonRealSignalTau = mtLeptonRealSignalTau.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassLeptonRealSignalTau") mtTauVeto._setLegendStyles() mtTauVeto._setLegendLabels() mtTauVeto.histoMgr.setHistoDrawStyleAll("P") mtTauVeto.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) hmtTauVeto = mtTauVeto.histoMgr.getHisto("TTJets").getRootHisto().Clone( analysis + "/transverseMassTauVeto") mtLeptonFakeSignalTau._setLegendStyles() mtLeptonFakeSignalTau._setLegendLabels() mtLeptonFakeSignalTau.histoMgr.setHistoDrawStyleAll("P") mtLeptonFakeSignalTau.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtLeptonFakeSignalTau = mtLeptonFakeSignalTau.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassLeptonFakeSignalTau") mtObservableLeptons._setLegendStyles() mtObservableLeptons._setLegendLabels() mtObservableLeptons.histoMgr.setHistoDrawStyleAll("P") mtObservableLeptons.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtObservableLeptons = mtObservableLeptons.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassObservableLeptons") mtNoObservableLeptons._setLegendStyles() mtNoObservableLeptons._setLegendLabels() mtNoObservableLeptons.histoMgr.setHistoDrawStyleAll("P") mtNoObservableLeptons.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtNoObservableLeptons = mtNoObservableLeptons.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseNoMassObservableLeptons") mtTopChiSelection._setLegendStyles() mtTopChiSelection._setLegendLabels() mtTopChiSelection.histoMgr.setHistoDrawStyleAll("P") mtTopChiSelection.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtTopChiSelection = mtTopChiSelection.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassTopChiSelection") mtWMassSelection._setLegendStyles() mtWMassSelection._setLegendLabels() mtWMassSelection.histoMgr.setHistoDrawStyleAll("P") mtWMassSelection.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtWMassSelection = mtWMassSelection.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassWmassCut") mtNoLeptonNotInTau._setLegendStyles() mtNoLeptonNotInTau._setLegendLabels() mtNoLeptonNotInTau.histoMgr.setHistoDrawStyleAll("P") mtNoLeptonNotInTau.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtNoLeptonNotInTau = mtNoLeptonNotInTau.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassNoLeptonNotInTau") mtNoLeptonGoodMet._setLegendStyles() mtNoLeptonGoodMet._setLegendLabels() mtNoLeptonGoodMet.histoMgr.setHistoDrawStyleAll("P") mtNoLeptonGoodMet.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtNoLeptonGoodMet = mtNoLeptonGoodMet.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassNoLeptonGoogMet") mtNoLeptonGoodMetGoodTau._setLegendStyles() mtNoLeptonGoodMetGoodTau._setLegendLabels() mtNoLeptonGoodMetGoodTau.histoMgr.setHistoDrawStyleAll("P") mtNoLeptonGoodMetGoodTau.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtNoLeptonGoodMetGoodTau = mtNoLeptonGoodMetGoodTau.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassNoLeptonGoogMetGoodTau") mtLeptonNotInTau._setLegendStyles() mtLeptonNotInTau._setLegendLabels() mtLeptonNotInTau.histoMgr.setHistoDrawStyleAll("P") mtLeptonNotInTau.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtLeptonNotInTau = mtLeptonNotInTau.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassLeptonNotInTau") mtMuonNotInTau._setLegendStyles() mtMuonNotInTau._setLegendLabels() mtMuonNotInTau.histoMgr.setHistoDrawStyleAll("P") mtMuonNotInTau.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) hmtMuonNotInTau = mtMuonNotInTau.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassMuonNotInTau") mtElectronNotInTau._setLegendStyles() mtElectronNotInTau._setLegendLabels() mtElectronNotInTau.histoMgr.setHistoDrawStyleAll("P") mtElectronNotInTau.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hmtElectronNotInTau = mtElectronNotInTau.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassMuonNotInTau") mtTauNotInTau._setLegendStyles() mtTauNotInTau._setLegendLabels() mtTauNotInTau.histoMgr.setHistoDrawStyleAll("P") mtTauNotInTau.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) hmtTauNotInTau = mtTauNotInTau.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassTauNotInTau") mt._setLegendStyles() mt._setLegendLabels() mt.histoMgr.setHistoDrawStyleAll("P") mt.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) hmt = mt.histoMgr.getHisto("TTJets").getRootHisto().Clone( analysis + "/transverseMass") mtMetReso02._setLegendStyles() mtMetReso02._setLegendLabels() mtMetReso02.histoMgr.setHistoDrawStyleAll("P") mtMetReso02.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) hmtMetReso02 = mtMetReso02.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/transverseMassmtMetReso02") deltaEtMetGenMet._setLegendStyles() deltaEtMetGenMet._setLegendLabels() deltaEtMetGenMet.histoMgr.setHistoDrawStyleAll("P") deltaEtMetGenMet.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hdeltaEtMetGenMet = deltaEtMetGenMet.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/deltaEtMetGenMet") deltaPhiMetGenMet._setLegendStyles() deltaPhiMetGenMet._setLegendLabels() deltaPhiMetGenMet.histoMgr.setHistoDrawStyleAll("P") deltaPhiMetGenMet.histoMgr.forEachHisto( lambda h: h.getRootHisto().Rebin(10)) hdeltaPhiMetGenMet = deltaPhiMetGenMet.histoMgr.getHisto( "TTJets").getRootHisto().Clone(analysis + "/deltaPhiMetGenMet") ######################################################### canvas12 = ROOT.TCanvas("canvas12", "", 500, 500) canvas12.SetLogy() hmt.SetMinimum(0.01) # hmt.SetMaximum(17000) hmt.SetMarkerColor(4) hmt.SetMarkerSize(1) hmt.SetMarkerStyle(24) hmt.Draw("EP") hmtLeptonRealSignalTau.SetMarkerColor(7) hmtLeptonRealSignalTau.SetMarkerSize(1) hmtLeptonRealSignalTau.SetMarkerStyle(21) hmtLeptonRealSignalTau.Draw("same") hmtLeptonFakeSignalTau.SetMarkerColor(2) hmtLeptonFakeSignalTau.SetMarkerSize(1) hmtLeptonFakeSignalTau.SetMarkerStyle(20) hmtLeptonFakeSignalTau.Draw("same") hmt.GetYaxis().SetTitle("Events") hmt.GetYaxis().SetTitleOffset(1.0) hmt.GetXaxis().SetTitle("m_{T}(#tau jet, MET) (GeV/c^{2})") tex3 = ROOT.TLatex(0.48, 0.9, "All selected events") tex3.SetNDC() tex3.SetTextSize(18) tex3.Draw() marker3 = ROOT.TMarker(0.45, 0.91, hmt.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hmt.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hmt.GetMarkerSize()) marker3.Draw() tex2 = ROOT.TLatex(0.48, 0.85, "Leptons + real signal #tau") tex2.SetNDC() tex2.SetTextSize(18) tex2.Draw() marker2 = ROOT.TMarker(0.45, 0.86, hmtLeptonRealSignalTau.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hmtLeptonRealSignalTau.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hmtLeptonRealSignalTau.GetMarkerSize()) marker2.Draw() tex6 = ROOT.TLatex(0.48, 0.80, "Leptons + fake signal #tau") tex6.SetNDC() tex6.SetTextSize(18) tex6.Draw() marker6 = ROOT.TMarker(0.45, 0.81, hmtLeptonFakeSignalTau.GetMarkerStyle()) marker6.SetNDC() marker6.SetMarkerColor(hmtLeptonFakeSignalTau.GetMarkerColor()) marker6.SetMarkerSize(0.9 * hmtLeptonFakeSignalTau.GetMarkerSize()) marker6.Draw() tex4 = ROOT.TLatex(0.25, 0.96, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(18) tex4.Draw() # tex5 = ROOT.TLatex(0.3,0.2,"m_{H^{#pm}} = 200 GeV/c^{2}") tex5 = ROOT.TLatex(0.25, 0.3, "tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex7 = ROOT.TLatex(0.25, 0.15, "tan#beta = 30") tex7.SetNDC() tex7.SetTextSize(20) # tex7.Draw() canvas12.Print("mtTailRealFakeSignalTau_tt.png") canvas12.Print("mtTailRealFakeSignalTau_tt.C") ################################################## canvas11 = ROOT.TCanvas("canvas11", "", 500, 500) canvas11.SetLogy() hmt.SetMinimum(0.01) # hmt.SetMaximum(17000) hmt.SetMarkerColor(4) hmt.SetMarkerSize(1) hmt.SetMarkerStyle(24) hmt.Draw("EP") hmtObservableLeptons.SetMarkerColor(7) hmtObservableLeptons.SetMarkerSize(1) hmtObservableLeptons.SetMarkerStyle(21) hmtObservableLeptons.Draw("same") hmtNoObservableLeptons.SetMarkerColor(2) hmtNoObservableLeptons.SetMarkerSize(1) hmtNoObservableLeptons.SetMarkerStyle(20) hmtNoObservableLeptons.Draw("same") hmt.GetYaxis().SetTitle("Events") hmt.GetYaxis().SetTitleOffset(1.0) hmt.GetXaxis().SetTitle("m_{T}(#tau jet, MET) (GeV/c^{2})") tex3 = ROOT.TLatex(0.58, 0.9, "All selected events") tex3.SetNDC() tex3.SetTextSize(18) tex3.Draw() marker3 = ROOT.TMarker(0.55, 0.91, hmt.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hmt.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hmt.GetMarkerSize()) marker3.Draw() tex2 = ROOT.TLatex(0.58, 0.85, "Observable leptons") tex2.SetNDC() tex2.SetTextSize(18) tex2.Draw() marker2 = ROOT.TMarker(0.55, 0.86, hmtObservableLeptons.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hmtObservableLeptons.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hmtObservableLeptons.GetMarkerSize()) marker2.Draw() tex6 = ROOT.TLatex(0.58, 0.80, "No observable lepton ") tex6.SetNDC() tex6.SetTextSize(18) tex6.Draw() marker6 = ROOT.TMarker(0.55, 0.81, hmtNoObservableLeptons.GetMarkerStyle()) marker6.SetNDC() marker6.SetMarkerColor(hmtNoObservableLeptons.GetMarkerColor()) marker6.SetMarkerSize(0.9 * hmtNoObservableLeptons.GetMarkerSize()) marker6.Draw() tex4 = ROOT.TLatex(0.25, 0.96, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(18) tex4.Draw() # tex5 = ROOT.TLatex(0.3,0.2,"m_{H^{#pm}} = 200 GeV/c^{2}") tex5 = ROOT.TLatex(0.25, 0.3, "tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex7 = ROOT.TLatex(0.25, 0.15, "tan#beta = 30") tex7.SetNDC() tex7.SetTextSize(20) # tex7.Draw() canvas11.Print("mtTailObservableLeptons_tt.png") canvas11.Print("mtTailObservableLeptons_tt.C") ################################################## canvas4 = ROOT.TCanvas("canvas4", "", 500, 500) canvas4.SetLogy() hmt.SetMinimum(0.01) # hmt.SetMaximum(17000) hmt.SetMarkerColor(4) hmt.SetMarkerSize(1) hmt.SetMarkerStyle(24) hmt.Draw("EP") hmtElectronNotInTau.SetMarkerColor(2) hmtElectronNotInTau.SetMarkerSize(1) hmtElectronNotInTau.SetMarkerStyle(20) hmtElectronNotInTau.Draw("same") hmtMuonNotInTau.SetMarkerColor(7) hmtMuonNotInTau.SetMarkerSize(1) hmtMuonNotInTau.SetMarkerStyle(21) hmtMuonNotInTau.Draw("same") hmtTauNotInTau.SetMarkerColor(6) hmtTauNotInTau.SetMarkerSize(1) hmtTauNotInTau.SetMarkerStyle(23) hmtTauNotInTau.Draw("same") hmtSum = hmtTauNotInTau.Clone("mtSum") hmtSum.SetName("mtSum") hmtSum.SetTitle("associated lepton") hmtSum.Add(hmtElectronNotInTau) hmtSum.Add(hmtMuonNotInTau) hmtSum.SetMarkerColor(1) hmtSum.SetMarkerSize(1) hmtSum.SetMarkerStyle(20) # hmtSum.Draw("same") hmt.GetYaxis().SetTitle("Events") hmt.GetYaxis().SetTitleOffset(1.0) hmt.GetXaxis().SetTitle("m_{T}(#tau jet, MET) (GeV/c^{2})") tex3 = ROOT.TLatex(0.58, 0.9, "All selected events") tex3.SetNDC() tex3.SetTextSize(18) tex3.Draw() marker3 = ROOT.TMarker(0.55, 0.91, hmt.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hmt.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hmt.GetMarkerSize()) marker3.Draw() tex2 = ROOT.TLatex(0.58, 0.85, "associated electron") tex2.SetNDC() tex2.SetTextSize(18) tex2.Draw() marker2 = ROOT.TMarker(0.55, 0.86, hmtElectronNotInTau.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hmtElectronNotInTau.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hmtElectronNotInTau.GetMarkerSize()) marker2.Draw() tex6 = ROOT.TLatex(0.58, 0.80, "associated muon ") tex6.SetNDC() tex6.SetTextSize(18) tex6.Draw() marker6 = ROOT.TMarker(0.55, 0.81, hmtMuonNotInTau.GetMarkerStyle()) marker6.SetNDC() marker6.SetMarkerColor(hmtMuonNotInTau.GetMarkerColor()) marker6.SetMarkerSize(0.9 * hmtMuonNotInTau.GetMarkerSize()) marker6.Draw() tex1 = ROOT.TLatex(0.58, 0.75, "associated hadronic #tau ") tex1.SetNDC() tex1.SetTextSize(18) tex1.Draw() marker1 = ROOT.TMarker(0.55, 0.76, hmtTauNotInTau.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hmtTauNotInTau.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hmtTauNotInTau.GetMarkerSize()) marker1.Draw() tex8 = ROOT.TLatex(0.58, 0.7, "associated leptons ") tex8.SetNDC() tex8.SetTextSize(18) # tex8.Draw() marker8 = ROOT.TMarker(0.55, 0.71, hmtSum.GetMarkerStyle()) marker8.SetNDC() marker8.SetMarkerColor(hmtSum.GetMarkerColor()) marker8.SetMarkerSize(0.9 * hmtSum.GetMarkerSize()) # marker8.Draw() tex4 = ROOT.TLatex(0.25, 0.96, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(18) tex4.Draw() # tex5 = ROOT.TLatex(0.3,0.2,"m_{H^{#pm}} = 200 GeV/c^{2}") tex5 = ROOT.TLatex(0.25, 0.3, "tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex7 = ROOT.TLatex(0.25, 0.15, "tan#beta = 30") tex7.SetNDC() tex7.SetTextSize(20) # tex7.Draw() canvas4.Print("mtTailComparison_tt.png") canvas4.Print("mtTailComparison_tt.C") ################################################## canvas5 = ROOT.TCanvas("canvas5", "", 500, 500) canvas5.SetLogy() # hmtVetohptIsolEff.SetMaximum(0.1) # hetabTop.SetMinimum(2000) hmt.SetMarkerColor(4) hmt.SetMarkerSize(1) hmt.SetMarkerStyle(24) hmt.Draw("EP") hmtMetReso02.SetMarkerColor(1) hmtMetReso02.SetMarkerSize(1) hmtMetReso02.SetMarkerStyle(22) hmtMetReso02.Draw("same") hmtTauVeto.SetMarkerColor(2) hmtTauVeto.SetMarkerSize(1) hmtTauVeto.SetMarkerStyle(20) hmtTauVeto.Draw("same") hmt.GetYaxis().SetTitle("Events") hmt.GetYaxis().SetTitleOffset(2.0) hmt.GetXaxis().SetTitle("m_{T}(#tau jet, MET) (GeV/c^{2})") tex3 = ROOT.TLatex(0.43, 0.85, "All events") tex3.SetNDC() tex3.SetTextSize(20) tex3.Draw() marker3 = ROOT.TMarker(0.4, 0.87, hmt.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hmt.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hmt.GetMarkerSize()) marker3.Draw() tex1 = ROOT.TLatex(0.43, 0.8, "MET resolution > 0.2") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.4, 0.82, hmtMetReso02.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hmtMetReso02.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hmtMetReso02.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.43, 0.75, "#tau-jet veto") tex2.SetNDC() tex2.SetTextSize(20) tex2.Draw() marker2 = ROOT.TMarker(0.4, 0.77, hmtTauVeto.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hmtTauVeto.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hmtTauVeto.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2, 0.96, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() # tex5 = ROOT.TLatex(0.6,0.7,"m_{H^{#pm}} = 200 GeV/c^{2}") tex5 = ROOT.TLatex(0.25, 0.3, "tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.6, 0.62, "|#eta^{b quark}| < 2.4") tex6.SetNDC() tex6.SetTextSize(20) # tex6.Draw() canvas5.Print("mtMetResoComparison_tt.png") canvas5.Print("mtMetResoComparison_tt.C") ################################################## canvas7 = ROOT.TCanvas("canvas7", "", 500, 500) canvas7.SetLogy() # hmtVetohptIsolEff.SetMaximum(0.1) # hetabTop.SetMinimum(2000) hmt.SetMarkerColor(4) hmt.SetMarkerSize(1) hmt.SetMarkerStyle(24) hmt.Draw("EP") hmtLeptonNotInTau.SetMarkerColor(2) hmtLeptonNotInTau.SetMarkerSize(1) hmtLeptonNotInTau.SetMarkerStyle(20) hmtLeptonNotInTau.Draw("same") hmtMetReso02.SetMarkerColor(1) hmtMetReso02.SetMarkerSize(1) hmtMetReso02.SetMarkerStyle(23) hmtMetReso02.Draw("same") hmt.GetYaxis().SetTitle("Events") hmt.GetYaxis().SetTitleOffset(0.9) hmt.GetXaxis().SetTitle("m_{T}(#tau jet, MET) (GeV/c^{2})") tex3 = ROOT.TLatex(0.55, 0.85, "All events") tex3.SetNDC() tex3.SetTextSize(20) tex3.Draw() marker3 = ROOT.TMarker(0.52, 0.86, hmt.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hmt.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hmt.GetMarkerSize()) marker3.Draw() tex8 = ROOT.TLatex(0.55, 0.80, "associated leptons ") tex8.SetNDC() tex8.SetTextSize(18) tex8.Draw() marker8 = ROOT.TMarker(0.52, 0.81, hmtLeptonNotInTau.GetMarkerStyle()) marker8.SetNDC() marker8.SetMarkerColor(hmtLeptonNotInTau.GetMarkerColor()) marker8.SetMarkerSize(0.9 * hmtLeptonNotInTau.GetMarkerSize()) marker8.Draw() tex1 = ROOT.TLatex(0.55, 0.75, "E_{T}^{miss} resolution > 0.2") tex1.SetNDC() tex1.SetTextSize(20) tex1.Draw() marker1 = ROOT.TMarker(0.52, 0.76, hmtMetReso02.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hmtMetReso02.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hmtMetReso02.GetMarkerSize()) marker1.Draw() tex4 = ROOT.TLatex(0.2, 0.96, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() # tex5 = ROOT.TLatex(0.6,0.7,"m_{H^{#pm}} = 200 GeV/c^{2}") tex5 = ROOT.TLatex(0.25, 0.3, "tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.6, 0.62, "|#eta^{b quark}| < 2.4") tex6.SetNDC() tex6.SetTextSize(20) # tex6.Draw() canvas7.Print("mtLeptonMetComparison_tt.png") canvas7.Print("mtLeptonMetComparison_tt.C") ################################################## canvas8 = ROOT.TCanvas("canvas8", "", 500, 500) canvas8.SetLogy() # hmtVetohptIsolEff.SetMaximum(0.1) # hetabTop.SetMinimum(2000) hmt.SetMarkerColor(4) hmt.SetMarkerSize(1) hmt.SetMarkerStyle(24) hmt.Draw("EP") hmtNoLeptonNotInTau.SetMarkerColor(2) hmtNoLeptonNotInTau.SetMarkerSize(1) hmtNoLeptonNotInTau.SetMarkerStyle(20) hmtNoLeptonNotInTau.Draw("same") hmtNoLeptonGoodMet.SetMarkerColor(6) hmtNoLeptonGoodMet.SetMarkerSize(1) hmtNoLeptonGoodMet.SetMarkerStyle(25) hmtNoLeptonGoodMet.Draw("same") hmtNoLeptonGoodMetGoodTau.SetMarkerColor(1) hmtNoLeptonGoodMetGoodTau.SetMarkerSize(1) hmtNoLeptonGoodMetGoodTau.SetMarkerStyle(23) hmtNoLeptonGoodMetGoodTau.Draw("same") hmt.GetYaxis().SetTitle("Events") hmt.GetYaxis().SetTitleOffset(0.9) hmt.GetXaxis().SetTitle("m_{T}(#tau jet, MET) (GeV/c^{2})") tex3 = ROOT.TLatex(0.55, 0.85, "All events") tex3.SetNDC() tex3.SetTextSize(18) tex3.Draw() marker3 = ROOT.TMarker(0.52, 0.86, hmt.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hmt.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hmt.GetMarkerSize()) marker3.Draw() tex8 = ROOT.TLatex(0.55, 0.80, "No associated leptons ") tex8.SetNDC() tex8.SetTextSize(18) tex8.Draw() marker8 = ROOT.TMarker(0.52, 0.81, hmtNoLeptonNotInTau.GetMarkerStyle()) marker8.SetNDC() marker8.SetMarkerColor(hmtNoLeptonNotInTau.GetMarkerColor()) marker8.SetMarkerSize(0.9 * hmtNoLeptonNotInTau.GetMarkerSize()) marker8.Draw() # tex1 = ROOT.TLatex(0.55,0.75,"No associated leptons and") tex1 = ROOT.TLatex(0.55, 0.75, "+ E_{T}^{miss} resolution < 0.2") tex1.SetNDC() tex1.SetTextSize(18) tex1.Draw() marker1 = ROOT.TMarker(0.52, 0.76, hmtNoLeptonGoodMet.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hmtNoLeptonGoodMet.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hmtNoLeptonGoodMet.GetMarkerSize()) marker1.Draw() tex2 = ROOT.TLatex(0.55, 0.70, "+ matched #tau jet") tex2.SetNDC() tex2.SetTextSize(18) tex2.Draw() marker2 = ROOT.TMarker(0.52, 0.71, hmtNoLeptonGoodMetGoodTau.GetMarkerStyle()) marker2.SetNDC() marker2.SetMarkerColor(hmtNoLeptonGoodMetGoodTau.GetMarkerColor()) marker2.SetMarkerSize(0.9 * hmtNoLeptonGoodMetGoodTau.GetMarkerSize()) marker2.Draw() tex4 = ROOT.TLatex(0.2, 0.96, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() # tex5 = ROOT.TLatex(0.6,0.7,"m_{H^{#pm}} = 200 GeV/c^{2}") tex5 = ROOT.TLatex(0.25, 0.3, "tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.6, 0.62, "|#eta^{b quark}| < 2.4") tex6.SetNDC() tex6.SetTextSize(20) # tex6.Draw() canvas8.Print("mtNoLeptonsGoodMet_tt.png") canvas8.Print("mtNoLeptonsGoodMet_tt.C") ################################################## canvas9 = ROOT.TCanvas("canvas9", "", 500, 500) canvas9.SetLogy() # hmtVetohptIsolEff.SetMaximum(0.1) # hetabTop.SetMinimum(2000) hmt.SetMarkerColor(4) hmt.SetMarkerSize(1) hmt.SetMarkerStyle(24) hmt.Draw("EP") hmtTopChiSelection.SetMarkerColor(2) hmtTopChiSelection.SetMarkerSize(1) hmtTopChiSelection.SetMarkerStyle(20) hmtTopChiSelection.Draw("same") hmtWMassSelection.SetMarkerColor(6) hmtWMassSelection.SetMarkerSize(1) hmtWMassSelection.SetMarkerStyle(25) hmtWMassSelection.Draw("same") hmt.GetYaxis().SetTitle("Events") hmt.GetYaxis().SetTitleOffset(0.9) hmt.GetXaxis().SetTitle("m_{T}(#tau jet, MET) (GeV/c^{2})") tex3 = ROOT.TLatex(0.55, 0.85, "All events") tex3.SetNDC() tex3.SetTextSize(18) tex3.Draw() marker3 = ROOT.TMarker(0.52, 0.86, hmt.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hmt.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hmt.GetMarkerSize()) marker3.Draw() tex8 = ROOT.TLatex(0.55, 0.80, "Top mass cut ") tex8.SetNDC() tex8.SetTextSize(18) tex8.Draw() marker8 = ROOT.TMarker(0.52, 0.81, hmtTopChiSelection.GetMarkerStyle()) marker8.SetNDC() marker8.SetMarkerColor(hmtTopChiSelection.GetMarkerColor()) marker8.SetMarkerSize(0.9 * hmtTopChiSelection.GetMarkerSize()) marker8.Draw() tex1 = ROOT.TLatex(0.55, 0.75, "W mass cut") tex1.SetNDC() tex1.SetTextSize(18) tex1.Draw() marker1 = ROOT.TMarker(0.52, 0.76, hmtWMassSelection.GetMarkerStyle()) marker1.SetNDC() marker1.SetMarkerColor(hmtWMassSelection.GetMarkerColor()) marker1.SetMarkerSize(0.9 * hmtWMassSelection.GetMarkerSize()) marker1.Draw() tex4 = ROOT.TLatex(0.2, 0.96, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() # tex5 = ROOT.TLatex(0.6,0.7,"m_{H^{#pm}} = 200 GeV/c^{2}") tex5 = ROOT.TLatex(0.25, 0.3, "tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.6, 0.62, "|#eta^{b quark}| < 2.4") tex6.SetNDC() tex6.SetTextSize(20) # tex6.Draw() canvas9.Print("mtTopMassCut_tt.png") canvas9.Print("mtTopMassCut_tt.C") ################################################## ################################################## canvas6 = ROOT.TCanvas("canvas6", "", 500, 500) # canvas6.SetLogy() # hmtVetohptIsolEff.SetMaximum(0.1) # hetabTop.SetMinimum(2000) hdeltaEtMetGenMet.SetMarkerColor(4) hdeltaEtMetGenMet.SetMarkerSize(1) hdeltaEtMetGenMet.SetMarkerStyle(20) hdeltaEtMetGenMet.Draw("EP") hdeltaEtMetGenMet.GetYaxis().SetTitle("Events") hdeltaEtMetGenMet.GetYaxis().SetTitleOffset(1.0) hdeltaEtMetGenMet.GetXaxis().SetTitle("(GenMet - MET)/GenMet") tex3 = ROOT.TLatex(0.43, 0.85, "All events") tex3.SetNDC() tex3.SetTextSize(20) # tex3.Draw() marker3 = ROOT.TMarker(0.4, 0.87, hdeltaEtMetGenMet.GetMarkerStyle()) marker3.SetNDC() marker3.SetMarkerColor(hdeltaEtMetGenMet.GetMarkerColor()) marker3.SetMarkerSize(0.9 * hdeltaEtMetGenMet.GetMarkerSize()) # marker3.Draw() tex4 = ROOT.TLatex(0.2, 0.96, "7 TeV CMS Preliminary ") tex4.SetNDC() tex4.SetTextSize(20) tex4.Draw() # tex5 = ROOT.TLatex(0.6,0.7,"m_{H^{#pm}} = 200 GeV/c^{2}") tex5 = ROOT.TLatex(0.75, 0.85, "tt+jets") tex5.SetNDC() tex5.SetTextSize(20) tex5.Draw() tex6 = ROOT.TLatex(0.6, 0.62, "|#eta^{b quark}| < 2.4") tex6.SetNDC() tex6.SetTextSize(20) # tex6.Draw() canvas6.Print("metResolution_tt.png") canvas6.Print("metResolution_tt.C")