示例#1
0
from plots.common.sample import Sample
from plots.common.cuts import Cuts
import sys

if __name__=="__main__":
    if len(sys.argv)!=2:
        print "Usage: %s /path/to/mu/iso/nominal/T_t_ToLeptons.root" % sys.argv[1]
        sys.exit(0)

    s = Sample.fromFile(sys.argv[1])
    cut = Cuts.final(2,1)
    nentries = s.tree.Draw("cos_theta", str(cut))
    print "Nentries=",nentries
示例#2
0
    merge_cmd["t#bar{t} excl"] = ["TTJets_FullLept", "TTJets_SemiLept"]
    merge_cmd["QCD (MC)"] = ["QCDMu"]
    merge_cmd["t#bar{t} incl"] = ["TTJets_MassiveBinDECAY"]
    merge_cmd["WJets incl"] = ["WJets_inclusive"]
    merge_cmd["WJets excl"] = ["W1Jets_exclusive", "W2Jets_exclusive", "W3Jets_exclusive", "W4Jets_exclusive"]
    merged_hists = merge_hists(histsD, merge_cmd)

    normd = dict()
    for hn, h in merged_hists.items():
        normd[hn] = get_hist_int_err(h)
    return merged_hists, normd


if __name__=="__main__":
    #cut = Cuts.mu * Cuts.n_jets(2) * Cuts.mt_mu * Cuts.top_mass_sig * Cuts.eta_lj * Cuts.n_tags(1)
    cut = Cuts.mu * Cuts.final(2,1)

    cutsref = [
        ("1mu", Cuts.mu, (5879691, 268238, 50236)),
        ("2J", Cuts.mu*Cuts.n_jets(2), (972069, 75674, 22387)),
        ("met", Cuts.mu*Cuts.n_jets(2)*Cut("met>45"), (404707, 46185, 11052)),
        ("0T", Cuts.mu*Cuts.n_jets(2)*Cut("met>45")*Cuts.n_tags(0), (-1, -1, -1)),
        ("rmslj_0T", Cuts.mu*Cuts.n_jets(2)*Cut("met>45")*Cuts.n_tags(0)*Cuts.rms_lj, (-1, -1, -1)),
        ("1T", Cuts.mu*Cuts.n_jets(2)*Cut("met>45")*Cuts.n_tags(1), (6197, 17505, 4173)),
        ("rmslj_1T", Cuts.mu*Cuts.n_jets(2)*Cut("met>45")*Cuts.n_tags(1)*Cuts.rms_lj, (5095, 14197, 3664)),
    ]

    for (name, cut, (refW, refTT, refT)) in cutsref:
        #hist, norms = mc_amount(cut, "pu_weight*muon_IDWeight*muon_IsoWeight")
        hist, norms = mc_amount(cut, "1.0")
        print 80*"-"
示例#3
0
from plots.common.sample import Sample
from plots.common.sample_style import ColorStyleGen
from plots.common.hist_plots import plot_hists
from plots.common.cuts import Cuts, Weights
from plots.common.legend import legend
from plots.common.tdrstyle import tdrstyle

if __name__=="__main__":
	samp = Sample.fromFile("~/Documents/stpol/data/out_step3_joosep_11_07_19_44/mu/iso/nominal/W4Jets_exclusive.root")
	samp.tree.AddFriend("trees/WJets_weights", samp.file_name)

	tdrstyle()
	
	cut = str(Cuts.final(2,0)*Cuts.Wflavour("W_heavy"))
	mean_weight = samp.drawHistogram(str(Weights.wjets_madgraph_weight("nominal")), cut, weight="1.0", plot_range=[200, 0, 2]).hist.GetMean()
	print "mean weight=%.2f" % mean_weight
	hi0 = samp.drawHistogram("cos_theta", cut, weight="1.0", plot_range=[20, -1, 1]).hist
	hi0.Scale(samp.lumiScaleFactor(20000))
	hi1 = samp.drawHistogram("cos_theta", cut, weight=str(Weights.wjets_madgraph_weight("nominal")), plot_range=[20, -1, 1]).hist
	hi1.Scale(samp.lumiScaleFactor(20000))
	hi2 = samp.drawHistogram("cos_theta", cut, weight=str(Weights.wjets_madgraph_weight("wjets_up")), plot_range=[20, -1, 1]).hist
	hi2.Scale(samp.lumiScaleFactor(20000))
	hi3 = samp.drawHistogram("cos_theta", cut, weight=str(Weights.wjets_madgraph_weight("wjets_down")), plot_range=[20, -1, 1]).hist
	hi3.Scale(samp.lumiScaleFactor(20000))

	hists = [hi0, hi1, hi2, hi3]
	#for h in hists:
	#	h.Scale(1.0/h.Integral())
	hi0.SetTitle("unweighted")
	hi1.SetTitle("weighted")
	hi2.SetTitle("weighted wjets_up")
示例#4
0
    if args.tag:
        out_dir += "/" + args.tag
    mkdir_p(out_dir)

    # plot_ratios("2J0T", Cuts.final(2,0), samples, out_dir, args.recreate)
    # plot_ratios("2J1T", Cuts.final(2,1), samples, out_dir, args.recreate)

    colls_in, colls_out = plot_sherpa_vs_madgraph(
        costheta, "2J",
        Cuts.mu*Cuts.final_jet(2),
        samples.values(), out_dir, recreate=args.recreate, legend_pos="top-left", nudge_x=-0.03, nudge_y=0, systematic="nominal"
    )

    coll_in, coll_out = plot_sherpa_vs_madgraph(
        costheta, "2J0T",
        Cuts.mu*Cuts.final(2,0),
        samples.values(), out_dir, recreate=args.recreate, legend_pos="top-left", nudge_x=-0.03, nudge_y=0
    )

    coll_in, coll_out = plot_sherpa_vs_madgraph(
        costheta, "2J1T",
        Cuts.mu*Cuts.final(2,1),
        samples.values(), out_dir, recreate=args.recreate, legend_pos="top-left", nudge_x=-0.03, nudge_y=0
    )

    hi_mg = colls_out["madgraph/weighted"].hists["WJets_hf"] + colls_out["madgraph/weighted"].hists["WJets_lf"]
    hi_sh = colls_out["sherpa/unweighted"].hists["WJets_hf"] + colls_out["sherpa/unweighted"].hists["WJets_lf"]
    hi_sh_w = colls_out["sherpa/weighted"].hists["WJets_hf"] + colls_out["sherpa/weighted"].hists["WJets_lf"]

    hf_mg = colls_out["madgraph/weighted"].hists["WJets_hf"].Integral() / hi_mg.Integral()
    lf_mg = colls_out["madgraph/weighted"].hists["WJets_lf"].Integral() / hi_mg.Integral()
示例#5
0
文件: met_phi.py 项目: HEP-KBFI/stpol
    weights = [
        ("weight__nominal", Weights.total_weight("mu")),
    ]


    c1 = (
        "2j0t",
        Cuts.mt_mu()*Cuts.n_jets(2)*Cuts.n_tags(0)*Cuts.lepton("mu")*Cuts.hlt("mu"),
    )
    c2 = (
        "2j1t",
        Cuts.mt_mu()*Cuts.n_jets(2)*Cuts.n_tags(1)*Cuts.lepton("mu")*Cuts.hlt("mu"),
    )
    c3 = (
        "final_cb_2j1t",
        Cuts.final(2,1),
    )
    cuts = [c1, c2, c3]

    varnodes = {}
    for k, v in variables.items():
        for c in cuts:
            vn = tree.hist_node(graph, v, c, weights)
            vn.addParents(top.children())

    tree.HistNode.logger.setLevel(logging.INFO)
    print "Recursing down"
    for snode in snodes:
        snode.recurseDown()
示例#6
0
    merge_cmd["WJets incl"] = ["WJets_inclusive"]
    merge_cmd["WJets excl"] = [
        "W1Jets_exclusive", "W2Jets_exclusive", "W3Jets_exclusive",
        "W4Jets_exclusive"
    ]
    merged_hists = merge_hists(histsD, merge_cmd)

    normd = dict()
    for hn, h in merged_hists.items():
        normd[hn] = get_hist_int_err(h)
    return merged_hists, normd


if __name__ == "__main__":
    #cut = Cuts.mu * Cuts.n_jets(2) * Cuts.mt_mu * Cuts.top_mass_sig * Cuts.eta_lj * Cuts.n_tags(1)
    cut = Cuts.mu * Cuts.final(2, 1)

    cutsref = [
        ("1mu", Cuts.mu, (5879691, 268238, 50236)),
        ("2J", Cuts.mu * Cuts.n_jets(2), (972069, 75674, 22387)),
        ("met", Cuts.mu * Cuts.n_jets(2) * Cut("met>45"), (404707, 46185,
                                                           11052)),
        ("0T", Cuts.mu * Cuts.n_jets(2) * Cut("met>45") * Cuts.n_tags(0),
         (-1, -1, -1)),
        ("rmslj_0T", Cuts.mu * Cuts.n_jets(2) * Cut("met>45") *
         Cuts.n_tags(0) * Cuts.rms_lj, (-1, -1, -1)),
        ("1T", Cuts.mu * Cuts.n_jets(2) * Cut("met>45") * Cuts.n_tags(1),
         (6197, 17505, 4173)),
        ("rmslj_1T", Cuts.mu * Cuts.n_jets(2) * Cut("met>45") *
         Cuts.n_tags(1) * Cuts.rms_lj, (5095, 14197, 3664)),
    ]
示例#7
0
文件: flat.py 项目: HEP-KBFI/stpol
        
        #ROOT functions can be used
        ("abs_eta_lj", "abs(eta_lj)", [20, 0, 5]),

        ("bdt", Cuts.mva_vars['mu'], [60, -1, 1]),
    ]

    #Define all the weight strategies that we want to apply
    weights = [
        ("weight__nominal", Weights.total_weight("mu")),

        #Demonstrate reweighting
        ("weight__puw", Weights.pu("nominal")),
        ("weight__puw_up", Weights.pu("up")),
    ]

    #All the cut regions that we are interested in
    cuts = [
        ("2j0t", Cuts.mt_mu()*Cuts.n_jets(2)*Cuts.n_tags(0)*Cuts.lepton("mu")*Cuts.hlt("mu")),
        ("2j1t", Cuts.mt_mu()*Cuts.n_jets(2)*Cuts.n_tags(1)*Cuts.lepton("mu")*Cuts.hlt("mu")),
        ("final_cb_2j1t", Cuts.final(2,1))
    ]

    #Construct the analysis chain
    snodes, out = analysis_tree(cuts, weights, variables, args.infiles, args.outfile)

    print "Recursing down"
    for sn in snodes:
        sn.recurseDown()

    out.close()