#!/usr/bin/env python 

import json
# ROOT imports
from ROOT import TChain
# custom ROOT classes 
from ROOT import alp, ComposableSelector, CounterOperator, JetFilterOperator, BTagFilterOperator, JetPairingOperator, DiJetPlotterOperator
from ROOT import BaseOperator, FolderOperator, EventWriterOperator


config = {"jets_branch_name": "Jets",
          "hlt_names":[]}

selector = ComposableSelector(alp.Event)(0, json.dumps(config))
selector.addOperator(BaseOperator(alp.Event)())
selector.addOperator(CounterOperator(alp.Event)())
selector.addOperator(JetFilterOperator(alp.Event)(2.5, 30., 4))
selector.addOperator(CounterOperator(alp.Event)())
selector.addOperator(BTagFilterOperator(alp.Event)("pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.800, 4))
selector.addOperator(CounterOperator(alp.Event)())
selector.addOperator(FolderOperator(alp.Event)("empty_one"))
selector.addOperator(JetPairingOperator(alp.Event)(4))
selector.addOperator(FolderOperator(alp.Event)("4CSVM"))
selector.addOperator(DiJetPlotterOperator(alp.Event)())
selector.addOperator(CounterOperator(alp.Event)())
selector.addOperator(EventWriterOperator(alp.Event)())
selector.addOperator(FolderOperator(alp.Event)("empty_two"))

tchain = TChain("ntuple/tree")
tchain.Add("/lustre/cmswork/hh/alpha_ntuples/v0_20161004/GluGluToHHTo4B_node_SM_13TeV-madgraph_v14-v1/0000/output.root")
Exemplo n.º 2
0
    #read weights from alpSamples 
    config["xsec_br"]  = samples[sname]["xsec_br"]
    config["matcheff"] = samples[sname]["matcheff"]
    config["kfactor"]  = samples[sname]["kfactor"]

    json_str = json.dumps(config)

    w2 = {'PUWeight', 'GenWeight'} 
    w2_v = vector("string")()
    for w in w2: w2_v.push_back(w)

    #define selectors list
    selector = ComposableSelector(alp.Event)(0, json_str)
    selector.addOperator(BaseOperator(alp.Event)())
    selector.addOperator(FolderOperator(alp.Event)("base"))
    selector.addOperator(CounterOperator(alp.Event)(w2_v))

    selector.addOperator(FolderOperator(alp.Event)("trigger"))
    selector.addOperator(TriggerOperator(alp.Event)(trg_namesD_v))
    selector.addOperator(CounterOperator(alp.Event)(w2_v))

    selector.addOperator(FolderOperator(alp.Event)("acc"))
    selector.addOperator(JetFilterOperator(alp.Event)(2.5, 30., 4))
    selector.addOperator(CounterOperator(alp.Event)(w2_v)) #debug - no bTagWeight?
    selector.addOperator(JetPlotterOperator(alp.Event)("pt",w2_v))
    selector.addOperator(MiscellPlotterOperator(alp.Event)(w2_v))

    selector.addOperator(FolderOperator(alp.Event)("btag"))
    selector.addOperator(BTagFilterOperator(alp.Event)(btagAlgo, 0.800, 4, config["isData"], data_path))
    selector.addOperator(CounterOperator(alp.Event)(weights_v))
Exemplo n.º 3
0
        "(Entry$ > {}) && ( Entry$ <= {} ) {}".format(n_ev_base,
                                                      n_ev_base + n_ev_sfrac,
                                                      extra_cut))
    n_ev_base += n_ev_subsam[s]
el = TEventList("el", "el")
for list_to_add in els:
    el.Add(list_to_add)
print "total number of entries in list " + str(el.GetN())
tc_hem.SetEventList(el)
tchain.SetEventList(el)

selector = ComposableSelector(alp.Event)(0, json_str)

selector.addOperator(FolderOperator(alp.Event)("pair"))
selector.addOperator(JetPairingOperator(alp.Event)(4))
selector.addOperator(CounterOperator(alp.Event)(weights_v))
selector.addOperator(JetPlotterOperator(alp.Event)(bTagAlgo, weights_v))
selector.addOperator(DiJetPlotterOperator(alp.Event)(weights_v))
selector.addOperator(EventWriterOperator(alp.Event)(json_str, weights_v))

selector.addOperator(ThrustFinderOperator(alp.Event)())
selector.addOperator(HemisphereProducerOperator(alp.Event)())
selector.addOperator(HemisphereMixerOperator(alp.Event)(tc_hem, nn_vars_v))
selector.addOperator(MixedEventWriterOperator(alp.Event)())

ofile = oDir
nev = numEvents if (numEvents > 0 and
                    numEvents < tchain.GetEntries()) else tchain.GetEntries()
procOpt = "ofile=./" + oname + ".root" if not oDir else "ofile=" + oDir + "/" + oname + ".root"
#procOpt = "ofile=./.root" if not oDir else "ofile="+oDir+"/mixed_.root"
print "max numEv {}".format(nev)
Exemplo n.º 4
0
    print "empty files {}".format(nerr)
    print "genevts {}".format(ngenev)

    #read weights from alpSamples
    config["xsec_br"] = samples[sname]["xsec_br"]
    config["matcheff"] = samples[sname]["matcheff"]
    config["kfactor"] = samples[sname]["kfactor"]

    json_str = json.dumps(config)

    #define selectors list
    selector = ComposableSelector(alp.Event)(0, json_str)
    selector.addOperator(BaseOperator(alp.Event)())
    selector.addOperator(FolderOperator(alp.Event)("base"))
    selector.addOperator(
        CounterOperator(alp.Event)(config["n_gen_events"], w_nobTag_v))

    selector.addOperator(FolderOperator(alp.Event)("trigger"))
    selector.addOperator(TriggerOperator(alp.Event)(trg_namesD_v))
    selector.addOperator(
        CounterOperator(alp.Event)(config["n_gen_events"], w_nobTag_v))

    selector.addOperator(FolderOperator(alp.Event)("acc"))
    selector.addOperator(JetFilterOperator(alp.Event)(2.4, 30., 4))
    selector.addOperator(
        CounterOperator(alp.Event)(config["n_gen_events"], w_nobTag_v))
    #    selector.addOperator(JetPlotterOperator(alp.Event)("pt",w_nobTag_v))
    #    selector.addOperator(MiscellPlotterOperator(alp.Event)(w_nobTag_v))

    selector.addOperator(FolderOperator(alp.Event)("btag"))
    selector.addOperator(
Exemplo n.º 5
0
    ngenev = hcount.GetBinContent(1)
    config["n_gen_events"] = ngenev
    print "gen numEv {}".format(ngenev)

    #read weights from alpSamples
    config["xsec_br"] = samples[sname]["xsec_br"]
    config["matcheff"] = samples[sname]["matcheff"]
    config["kfactor"] = samples[sname]["kfactor"]

    json_str = json.dumps(config)

    #define selectors list
    selector = ComposableSelector(alp.Event)(0, json_str)

    #simple dump of alpha ntuples in alp format
    selector.addOperator(CounterOperator(alp.Event)(w_nobTag_v))
    selector.addOperator(EventWriterOperator(alp.Event)(json_str, w_nobTag_v))

    #create tChain and process each files
    tchain = TChain("ntuple/tree")
    for File in files:
        tchain.Add(File)
    nev = numEvents if (numEvents > 0 and numEvents < tchain.GetEntries()
                        ) else tchain.GetEntries()
    procOpt = "ofile=./" + sname + ".root" if not oDir else "ofile=" + oDir + "/" + sname + ".root"
    print "max numEv {}".format(nev)
    tchain.Process(selector, procOpt, nev)
    ns += 1

    #some cleaning
    hcount.Reset()
Exemplo n.º 6
0
    elif args.jetCorr == 1: 
        print "- applying JEC Down -"
        selector.addOperator(JEShifterOperator(alp.Event)(-1))
    elif args.jetCorr == 2:
        print "- applying JER Up -"
        selector.addOperator(JERShifterOperator(alp.Event)(+1))
    elif args.jetCorr == 3:
        print "- applying JER Down -"
        selector.addOperator(JERShifterOperator(alp.Event)(-1))
    else:
        print "- default JEC-JER applied -"


    selector.addOperator(FolderOperator(alp.Event)("base"))
    #selector.addOperator(WeightSumOperator(alp.Event)(w_nobTag_v))
    selector.addOperator(CounterOperator(alp.Event)(config["n_gen_events"],w_nobTag_v))

    #trigger
    if args.doTrigger:
        if not args.doMixed:
           selector.addOperator(FolderOperator(alp.Event)("trigger"))
           selector.addOperator(TriggerOperator(alp.Event)(trg_names_v))
           selector.addOperator(CounterOperator(alp.Event)(config["n_gen_events"],w_nobTag_v))
        else: 
  	    print "WARNING: is Mixed sample - trigger filter applied already"

    selector.addOperator(FolderOperator(alp.Event)("acc"))
    selector.addOperator(JetFilterOperator(alp.Event)(2.4, 30., 4))
    selector.addOperator(CounterOperator(alp.Event)(config["n_gen_events"],w_nobTag_v))
    if args.savePlots: selector.addOperator(JetPlotterOperator(alp.Event)(btagAlgo, weights_v)) #with bTag since jets are sorted