Beispiel #1
0
    def compare_plot(var, plot_range, weight, cut, **kwargs):
        histsD = dict()

        for samp in samples_mc:
            histsD[samp.name] = samp.drawHistogram(var, str(cut), weight=weight, plot_range=plot_range)
            Styling.mc_style(histsD[samp.name].hist, samp.name)

        for name, hist in histsD.items():
            hist.normalize_lumi(lumi_total)

        for samp in samples_data:
            histsD[samp.name] = samp.drawHistogram(var, str(cut), plot_range=plot_range)
            Styling.data_style(histsD[samp.name].hist)

        hists_thD = dict()
        for (k,v) in histsD.items():
            hists_thD[k] = v.hist

        merge_cmd = copy.deepcopy(merge_cmds)
        merge_cmd["QCD (MC)"] = ["QCDMu"]
        merged = merge_hists(hists_thD, merge_cmd)

        stack = dict()
        stack["mc"] = [merged[name] for name in merged.keys() if name!="single #mu"]
        stack["data"] = [merged["single #mu"]]

        canv = ROOT.TCanvas()
        pl = plot_hists_stacked(canv, stack, **kwargs)
        leg = legend(stack["data"] + stack["mc"][::-1], **kwargs)
        lb = lumi_textbox(lumi_total)
        canv.SaveAs(kwargs.get("filename", "plot") + ".pdf")
        return stack, canv, pl, leg, lb
Beispiel #2
0
    def mc_amount(cut, weight, lumi, ref=None):
        histsD = dict()
        for samp in samples_mc:
            histsD[samp.name] = samp.drawHistogram("eta_lj",
                                                   str(cut),
                                                   weight=weight,
                                                   plot_range=[100, -5, 5])

        for name, hist in histsD.items():
            hist.normalize_lumi(lumi)
        for name, hist in histsD.items():
            histsD[name] = hist.hist
        merge_cmd = copy.deepcopy(merge_cmds)
        merge_cmd["QCD (MC)"] = ["QCDMu"]
        merge_cmd["t#bar{t} incl."] = ["TTJets_MassiveBinDECAY"]
        merge_cmd.pop("data")
        merged_hists = merge_hists(histsD, merge_cmd)

        interesting = [
            "t#bar{t}", "t#bar{t} incl.", "W(#rightarrow l #nu) + jets",
            "QCD (MC)", "t-channel"
        ]

        for i in interesting:
            r = 0.0
            r0 = 0.0
            if ref and i in ref.keys():
                r0 = ref[i]
                r = 100.0 * merged_hists[i].Integral() / float(r0)
            print "%s | %d | %d | %.2f %%" % (i, merged_hists[i].Integral(),
                                              r0, r)
Beispiel #3
0
    def compare_plot(var, plot_range, weight, cut, **kwargs):
        histsD = dict()

        for samp in samples_mc:
            histsD[samp.name] = samp.drawHistogram(var,
                                                   str(cut),
                                                   weight=weight,
                                                   plot_range=plot_range)
            Styling.mc_style(histsD[samp.name].hist, samp.name)

        for name, hist in histsD.items():
            hist.normalize_lumi(lumi_total)

        for samp in samples_data:
            histsD[samp.name] = samp.drawHistogram(var,
                                                   str(cut),
                                                   plot_range=plot_range)
            Styling.data_style(histsD[samp.name].hist)

        hists_thD = dict()
        for (k, v) in histsD.items():
            hists_thD[k] = v.hist

        merge_cmd = copy.deepcopy(merge_cmds)
        merge_cmd["QCD (MC)"] = ["QCDMu"]
        merged = merge_hists(hists_thD, merge_cmd)

        stack = dict()
        stack["mc"] = [
            merged[name] for name in merged.keys() if name != "single #mu"
        ]
        stack["data"] = [merged["single #mu"]]

        canv = ROOT.TCanvas()
        pl = plot_hists_stacked(canv, stack, **kwargs)
        leg = legend(stack["data"] + stack["mc"][::-1], **kwargs)
        lb = lumi_textbox(lumi_total)
        canv.SaveAs(kwargs.get("filename", "plot") + ".pdf")
        return stack, canv, pl, leg, lb
Beispiel #4
0
    def mc_amount(cut, weight, lumi, ref=None):
        histsD = dict()
        for samp in samples_mc:
            histsD[samp.name] = samp.drawHistogram("eta_lj", str(cut), weight=weight, plot_range=[100,-5,5])

        for name, hist in histsD.items():
            hist.normalize_lumi(lumi)
        for name, hist in histsD.items():
            histsD[name] = hist.hist
        merge_cmd = copy.deepcopy(merge_cmds)
        merge_cmd["QCD (MC)"] = ["QCDMu"]
        merge_cmd["t#bar{t} incl."] = ["TTJets_MassiveBinDECAY"]
        merge_cmd.pop("data")
        merged_hists = merge_hists(histsD, merge_cmd)

        interesting = ["t#bar{t}", "t#bar{t} incl.", "W(#rightarrow l #nu) + jets", "QCD (MC)", "t-channel"]

        for i in interesting:
            r = 0.0
            r0 = 0.0
            if ref and i in ref.keys():
                r0 = ref[i]
                r = 100.0*merged_hists[i].Integral() / float(r0)
            print "%s | %d | %d | %.2f %%" % (i, merged_hists[i].Integral(), r0, r)