Ejemplo n.º 1
0
def Plot2D(hist):
    c = pltmgr.NewCanvas()

    hist.Draw("COLZ")

    pltmgr.SetAxis(hist)
    pltmgr.SetSinglePadWithPalette(c)
    pltmgr.DrawCMSLabel(pltmgr.SIMULATION)
    pltmgr.DrawEntryLeft(opt.Entry())
    c.SaveAs(opt.GetResultName("2D_chi2_tmass"))
Ejemplo n.º 2
0
def main():

    # Initiailze plot manager
    histmgr = pltmgr.Plotmgr()
    objlst = [
        "GenObs2", "Obs2", "GenObs3", "Obs3", "GenObs4", "Obs4", "GenObs7",
        "Obs7"
    ]
    filelst = [
        "results/Hist_co_TTbar_chi2_20_Acp_-20_Opt_150.root",
        "results/Hist_co_TTbar_chi2_20_Acp_-15_Opt_150.root",
        "results/Hist_co_TTbar_chi2_20_Acp_-10_Opt_150.root",
        "results/Hist_co_TTbar_chi2_20_Acp_-5_Opt_150.root",
        "results/Hist_co_TTbar_chi2_20_Acp_0_Opt_150.root",
        "results/Hist_co_TTbar_chi2_20_Acp_5_Opt_150.root",
        "results/Hist_co_TTbar_chi2_20_Acp_10_Opt_150.root",
        "results/Hist_co_TTbar_chi2_20_Acp_15_Opt_150.root",
        "results/Hist_co_TTbar_chi2_20_Acp_20_Opt_150.root"
    ]
    for file in filelst:
        histmgr.SetObjlst(file, objlst)

    # Loop object list
    for obj in ["Observable13", "Observable6", "Observable3", "Observable12"]:
        gr1 = GetGraph(histmgr)
        gr2 = GetGraph(histmgr)

        c = pltmgr.NewCanvas()
        pltmgr.SetSinglePad(c)

        pltmgr.SetAxis(gr1)
        gr1.SetTitle('')
        gr1.GetXaxis().SetTitle("Input asymmetry A_{CP} [%]")
        gr1.GetYaxis().SetTitle("Output asymmetry A_{CP} [%]")
        gr1.SetMarkerColor(ROOT.kAzure - 3)
        gr1.SetMarkerStyle(20)
        gr1.SetMaximum(pltmgr.GetGraphYmax(gr1) * 1.1)
        gr1.SetMinimum(pltmgr.GetGraphYmin(gr1) * 1.1)

        gr2.SetMarkerColor(ROOT.kRed - 7)
        gr2.SetMarkerStyle(22)

        fit_x1 = ROOT.TF1("fit_x1", "pol1", 0)
        fit_x1.SetLineColor(ROOT.kAzure - 3)
        gr1.Fit("fit_x1")

        fit_x2 = ROOT.TF1("fit_x2", "pol1", 0)
        fit_x2.SetLineColor(ROOT.kRed - 7)
        fit_x2.SetLineStyle(7)
        gr2.Fit("fit_x2")

        gr1.Draw('AEP')
        gr2.Draw('EP SAME')
        pltmgr.DrawCMSLabel(pltmgr.SIMULATION)
        pltmgr.DrawEntryLeft("1 lep, #geq 4 jets ( 2 b jets )")

        leg = pltmgr.NewLegend(0.65, 0.2, 0.85, 0.5)
        leg.SetHeader(obj)
        leg.AddEntry(gr1, "A_{CP}", "P")
        leg.AddEntry(gr2, "A'_{CP}", "P")
        leg.AddEntry(fit_x1, "Fit to A_{CP}", "L")
        leg.AddEntry(fit_x2, "Fit to A'_{CP}", "L")
        leg.Draw()

        c.SaveAs("results/Hist_{}.pdf".format(obj))
Ejemplo n.º 3
0
def main():
    # Initialize parsing manager
    opt = parmgr.Parsemgr()
    opt.AddInput("c", "chi2").AddInput("e", "uncertainty").AddInput(
        "o", "opt").AddInput("r", "region")
    opt.AddFlag("p", "pileup").AddFlag("d", "driven").AddFlag("b",
                                                              "0bjet").AddFlag(
                                                                  "i", "ISO")

    opt.SetName("chi2", "uncertainty", "opt", "region", "pileup", "0bjet",
                "ISO")
    opt.Parsing()
    # Initialize plot manager
    histmgr = pltmgr.Plotmgr()
    objlst = [
        "Obs3", "Obs6", "Obs12", "Obs13", "had_tmass", "lep_tmass", "chi2",
        "LBJetPt", "HBJetPt", "LJetPt", "LJetEta", "LepPt", "LepEta", "LepIso",
        "nVtx", "Rho"
    ]
    for sample in input.samplelst:
        histmgr.SetObjlst(opt.GetFileName(sample), objlst, sample)

    if opt.GetOption("driven"):
        qcd_histlst = [histmgr.GetMergedObj("QCD") for o in objlst]
        histmgr.RemoveObj("QCD")
        histmgr.SetObjlst(
            opt.GetFileName("Data").replace("_WJets", "_QCD"), objlst, "QCD")
        opt.SetName("driven")

    # Loop objlst
    for obj in objlst:

        c = pltmgr.NewCanvas(obj)
        leg = pltmgr.NewLegend(0.67, 0.51, 0.8, 0.81)
        bg = ROOT.THStack()
        # Initiailze hist
        data = histmgr.GetObj("Data")
        histlst = []
        for i, mc in enumerate(info.mclst):
            histlst.append(histmgr.GetMergedObj(mc))
            histlst[i].SetLineColor(pltmgr.colorlst[i])
            histlst[i].SetFillColor(pltmgr.colorlst[i])
            bg.Add(histlst[i])
            leg.AddEntry(histlst[i], mc, "F")
            if mc == "QCD" and opt.GetOption("driven"):
                pltmgr.SetNormToUnity(histlst[i])
                histlst[i].Scale(qcd_histlst[i].Integral())
        leg.AddEntry(data, "Data", "le")

        bg_sum = pltmgr.SumHist(histlst)
        top = pltmgr.NewTopPad()
        top.Draw()
        top.cd()

        bg.Draw("HIST")
        data.Draw("EP same")
        leg.Draw()

        bg.GetYaxis().SetTitle("Events")
        bg.SetMaximum(pltmgr.GetHistYmax(data) * 1.5)
        pltmgr.SetTopPlotAxis(bg)
        data.SetLineColor(1)
        data.SetLineWidth(1)
        data.SetMarkerSize(0.5)
        data.SetMarkerStyle(20)

        c.cd()

        bot = pltmgr.NewBottomPad()
        bot.Draw()
        bot.cd()

        xmin = data.GetXaxis().GetXmin()
        xmax = data.GetXaxis().GetXmax()

        line = ROOT.TLine(xmin, 1.0, xmax, 1.0)
        upper = ROOT.TLine(xmin, 1.5, xmax, 1.5)
        lower = ROOT.TLine(xmin, 0.5, xmax, 0.5)
        rel = pltmgr.DivideHist(data, bg_sum, 1)

        rel.Draw("EP")
        upper.Draw("same")
        lower.Draw("same")
        line.Draw("same")

        line.SetLineColor(ROOT.kRed)
        upper.SetLineStyle(3)
        lower.SetLineStyle(3)

        rel.SetMaximum(1.6)
        rel.SetMinimum(0.4)
        rel.GetYaxis().SetTitle("Data/MC")
        rel.GetXaxis().SetTitle(data.GetXaxis().GetTitle())
        pltmgr.SetBottomPlotAxis(rel)

        c.cd()

        pltmgr.DrawCMSLabel(pltmgr.PRELIMINARY)
        pltmgr.DrawLuminosity(41540)
        pltmgr.DrawEntryLeft(opt.Entry())
        c.SaveAs(opt.GetResultName(obj))

        top.SetLogy(True)
        c.SaveAs(opt.GetResultName(obj + "_logy"))