Ejemplo n.º 1
0
def analysis_tree_all_reweighed(graph, cuts, snodes, **kwargs):
    cutnodes = []
    for cut_name, cut in cuts:
        lepton = cut_name.split("_")[0]

        cutnode = tree.CutNode(cut, graph, cut_name, snodes, [],
            filter_funcs=[
                lambda x,lepton=lepton: tree.is_samp(x, lepton)
        ])
        cutnodes.append(
            cutnode
        )

        #an extra QCD cleaning cut on top of the previous cut, which is only done in antiiso
        for syst in ["nominal", "up", "down"]:
            cn = tree.CutNode(
                Cuts.antiiso(lepton, syst) * Cuts.deltaR_QCD(),
                graph, "antiiso_%s" % syst, [cutnode], [],
                filter_funcs=[
                    lambda p: tree.is_samp(p, "antiiso")
                ]
            )
            cutnodes.append(
                cn
            )

    from histo_descs import create_plots
    create_plots(graph, cutnodes, **kwargs)
Ejemplo n.º 2
0
    for lepton in ['mu', 'ele']:
        for name, mva_cut in Cuts.mva_wps['bdt'][lepton].items():
            cval = str(mva_cut).replace(".", "_")
            mva_name = 'mva__%s__%s__%s' % (lepton, name, cval)
            mvas[lepton][cval] = CutNode(
                Cut("%s >= %f" % (Cuts.mva_vars[lepton], mva_cut)),
                graph, mva_name, [purifications['mva']], [],
                filter_funcs=[lambda _x,_lepton=lepton: is_chan(_x, _lepton)]
            )

    #After which cuts do you want the reweighed plots?
    plot_nodes = etalj.children() + purifications['mva'].children()

    from histo_descs import create_plots
    create_plots(graph, plot_nodes)

    print "Done constructing analysis tree..."
    print "Starting projection..."

    try:
        nx.write_dot(graph, args.outfile.replace(".root", "_gviz.dot"))
    except Exception as e:
        logger.warning("Couldn't write .dot file for visual representation of analysis: %s" % str(e))

    #Make everything
    t0 = time.clock()
    for sn in sample_nodes:
        sn.recurseDown()
    t1 = time.clock()
    dt = t1-t0