# 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") tchain.Process(selector, "", 10000)
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(CounterOperator(alp.Event)()) selector.addOperator(MCTruthOperator(alp.Event)(0.5, True)) selector.addOperator(CounterOperator(alp.Event)()) selector.addOperator(FolderOperator(alp.Event)("pair")) selector.addOperator(JetPlotterOperator(alp.Event)(btagAlgo,weights_v)) selector.addOperator(DiJetPlotterOperator(alp.Event)(weights_v)) selector.addOperator(EventWriterOperator(alp.Event)(json_str,weights_v)) #create tChain and process each files tchain = TChain("pair/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 print "### processed {} samples ###".format(ns)