def closure( filenames, plot ): leptonPtCut = 15 # only larger than 15 make sense here, since this is the reprocessing cut commonCut = "([email protected]() || Max$(electrons.pt)<{0}) && ([email protected]() || Max$(muons.pt)<{0})".format(leptonPtCut) #commonCut = "1" totalHist = getHists( filenames, plot, cut=commonCut ) gGenHist = getHists( filenames, plot, cut="photons[0].isGen(0) && "+commonCut ) eHist = multiDimFakeRate( filenames, plot, commonCut, False ) fakeHist = predictionHistos( filenames, plot, cut=commonCut )[0] fakeHist.SetLineColor(4) eHist.SetLineColor(3) gGenHist.SetLineColor(2) eHistSys = eHist.Clone( randomName() ) eHistSys = setRelativeUncertainty( eHistSys, 0.11 ) eHistSys.SetFillColor( eHistSys.GetLineColor() ) eHistSys.SetFillStyle(3354) eHistSys.SetMarkerSize(0) gDatasetAbbrs = [getDatasetAbbr(f) for f in filenames ] gDatasetAbbrs = mergeDatasetAbbr( gDatasetAbbrs ) multihisto = Multihisto() multihisto.setMinimum(0.01) multihisto.setMaximum(20) multihisto.leg.SetHeader( "/".join([ datasetToLatex(x) for x in gDatasetAbbrs]) ) multihisto.addHisto( totalHist, "Simulation", draw="e0 hist" ) multihisto.addHisto( fakeHist, "QCD", toStack=True, draw="hist" ) multihisto.addHisto( gGenHist, "gen#gamma", toStack=True, draw="e0 hist" ) multihisto.addHisto( eHist, "e#rightarrow#gamma", toStack=True, draw="hist" ) infoText = ROOT.TLatex(0.03,.96, "CMS Private Work - 8TeV #geq1#gamma,#geq2jets" ) infoText.SetNDC() can = ROOT.TCanvas() can.cd() multihisto.Draw() infoText.Draw() r = Ratio( "Sim./Pred.", totalHist, multihisto.stack.GetStack().Last() ) r.draw(0,2) SaveAs( can, "ewkPrediction_%s_%s"%(getSaveNameFromDatasets(filenames), plot)) ROOT.SetOwnership( can, False ) del can
S10scaledUsingS10.Divide( s10 ) S10scaledUsingS10.Multiply( data ) S10scaledUsingS10.SetLineStyle( 2 ) S7scaledUsingS7 = s7.Clone( randomName() ) S7scaledUsingS7.Divide( s7 ) S7scaledUsingS7.Multiply( data ) S7scaledUsingS7.SetLineStyle( 3 ) S7scaledUsingS10 = s7.Clone( randomName() ) S7scaledUsingS10.Divide( s10 ) S7scaledUsingS10.Multiply( data ) S7scaledUsingS10.SetLineStyle( 8 ) mh = Multihisto() mh.setMaximum(0.07) mh.addHisto( data, "Data", draw="p" ) mh.addHisto( s10, "S10 Scenario", draw="hist" ) mh.addHisto( S10scaledUsingS10, "S10 scaled by data/S10", draw="hist") mh.addHisto( s7, "S7 Scenario", draw="hist") mh.addHisto( S7scaledUsingS7, "S7 scaled by data/S7", draw="hist") mh.addHisto( S7scaledUsingS10, "S7 scaled by data/S10", draw="hist") mh.Draw() mh.leg.SetX1( .65 ) mh.leg.SetY1( .7 ) mh.leg.SetX2( 1 ) mh.leg.SetY2( 1 ) ROOT.gPad.SetLogy(0) ROOT.gPad.SaveAs("plots/pileupScenarios.pdf")
S10scaledUsingS10.Divide(s10) S10scaledUsingS10.Multiply(data) S10scaledUsingS10.SetLineStyle(2) S7scaledUsingS7 = s7.Clone(randomName()) S7scaledUsingS7.Divide(s7) S7scaledUsingS7.Multiply(data) S7scaledUsingS7.SetLineStyle(3) S7scaledUsingS10 = s7.Clone(randomName()) S7scaledUsingS10.Divide(s10) S7scaledUsingS10.Multiply(data) S7scaledUsingS10.SetLineStyle(8) mh = Multihisto() mh.setMaximum(0.07) mh.addHisto(data, "Data", draw="p") mh.addHisto(s10, "S10 Scenario", draw="hist") mh.addHisto(S10scaledUsingS10, "S10 scaled by data/S10", draw="hist") mh.addHisto(s7, "S7 Scenario", draw="hist") mh.addHisto(S7scaledUsingS7, "S7 scaled by data/S7", draw="hist") mh.addHisto(S7scaledUsingS10, "S7 scaled by data/S10", draw="hist") mh.Draw() mh.leg.SetX1(.65) mh.leg.SetY1(.7) mh.leg.SetX2(1) mh.leg.SetY2(1) ROOT.gPad.SetLogy(0) ROOT.gPad.SaveAs("plots/pileupScenarios.pdf")
def inclusiveAndIsrSamples(fList1, fList2, saveAffix=""): cut = "[email protected]() && [email protected]()" treeName = "photonTree" plot = "met" if saveAffix == "pt130": cut += " && photons[0].pt>130" saveAffix = "_" + saveAffix mh = Multihisto() h1 = getHists(fList1, plot, cut) h1gen = getHists(fList1, plot, cut + "&&photons[0].isGen(0)") h2 = getHists(fList2, plot, cut) h2gen = getHists(fList2, plot, cut + "&&photons[0].isGen(0)") for h in h2, h2gen: h.SetLineColor(2) for h in h1gen, h2gen: h.SetLineStyle(2) for h in [h2, h2gen, h1, h1gen]: h.SetLabelSize(1. / 31.5562 / 0.502113, "xyz") h.SetTitleSize(1. / 31.5562 / 0.502113, "xyz") h.GetXaxis().SetTitleOffset(1.1) h.GetYaxis().SetTitleOffset(0.85) if plot == "met": h.GetXaxis().SetTitle("#met#text{ [GeV]}") abbr1 = shortName(fList1) abbr2 = shortName(fList2) mh = Multihisto() if "ZGamma" in fList1[0]: mh.setMaximum(10) mh.setMinimum(2e-4) mh.leg.SetFillStyle(0) mh.leg.SetX1(0.6) mh.leg.SetY1(0.6) mh.addHisto(h1, datasetToLatex(abbr1)) mh.addHisto(h1gen, "#text{match to gen }#gamma") mh.addHisto(h2, datasetToLatex(abbr2)) mh.addHisto(h2gen, "#text{match to gen }#gamma") mh.Draw() info.SetTextSize(1. / 31.5562 / 0.502113) info.Draw() if "pt130" in saveAffix: cutInfo = ROOT.TLatex(.2, .8, "p_{T,#gamma}#geq#SI{130}{GeV}") cutInfo.SetNDC() info.SetTextSize(1. / 31.5562 / 0.502113) cutInfo.Draw() SavePad("inclusiveAndIsrSample_%s%s" % (abbr1, saveAffix)) ROOT.gPad.SaveAs( "/home/knut/master/documents/thesis/plots/inclusiveAndIsrSample_%s%s.tex" % (abbr1, saveAffix)) correctTiksPlot( "/home/knut/master/documents/thesis/plots/inclusiveAndIsrSample_%s%s.tex" % (abbr1, saveAffix))
def inclusiveAndIsrSamples(fList1, fList2, saveAffix=""): cut = "[email protected]() && [email protected]()" treeName = "photonTree" plot = "met" if saveAffix == "pt130": cut += " && photons[0].pt>130" saveAffix = "_" + saveAffix mh = Multihisto() h1 = getHists(fList1, plot, cut) h1gen = getHists(fList1, plot, cut + "&&photons[0].isGen(0)") h2 = getHists(fList2, plot, cut) h2gen = getHists(fList2, plot, cut + "&&photons[0].isGen(0)") for h in h2, h2gen: h.SetLineColor(2) for h in h1gen, h2gen: h.SetLineStyle(2) for h in [h2, h2gen, h1, h1gen]: h.SetLabelSize(1.0 / 31.5562 / 0.502113, "xyz") h.SetTitleSize(1.0 / 31.5562 / 0.502113, "xyz") h.GetXaxis().SetTitleOffset(1.1) h.GetYaxis().SetTitleOffset(0.85) if plot == "met": h.GetXaxis().SetTitle("#met#text{ [GeV]}") abbr1 = shortName(fList1) abbr2 = shortName(fList2) mh = Multihisto() if "ZGamma" in fList1[0]: mh.setMaximum(10) mh.setMinimum(2e-4) mh.leg.SetFillStyle(0) mh.leg.SetX1(0.6) mh.leg.SetY1(0.6) mh.addHisto(h1, datasetToLatex(abbr1)) mh.addHisto(h1gen, "#text{match to gen }#gamma") mh.addHisto(h2, datasetToLatex(abbr2)) mh.addHisto(h2gen, "#text{match to gen }#gamma") mh.Draw() info.SetTextSize(1.0 / 31.5562 / 0.502113) info.Draw() if "pt130" in saveAffix: cutInfo = ROOT.TLatex(0.2, 0.8, "p_{T,#gamma}#geq#SI{130}{GeV}") cutInfo.SetNDC() info.SetTextSize(1.0 / 31.5562 / 0.502113) cutInfo.Draw() SavePad("inclusiveAndIsrSample_%s%s" % (abbr1, saveAffix)) ROOT.gPad.SaveAs("/home/knut/master/documents/thesis/plots/inclusiveAndIsrSample_%s%s.tex" % (abbr1, saveAffix)) correctTiksPlot("/home/knut/master/documents/thesis/plots/inclusiveAndIsrSample_%s%s.tex" % (abbr1, saveAffix))