Ejemplo n.º 1
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()
Ejemplo n.º 2
0
    else:
         nerr+=1
    tf.Close()
    ngenev += hcount.GetBinContent(1)

#read weights from alpSamples -- DEBUG - unused
config["xsec_br"]  = -1.
config["matcheff"] = -1.
config["kfactor"]  = -1.
config["n_gen_events"] = ngenev
print  "gen numEv {}".format(ngenev)
print  "empty files {}".format(nerr)

json_str = json.dumps(config)

#weights to be applied 
for sam in sam_list_ :
  ns+=1
  selector = ComposableSelector(alp.Event)(0, json_str)
  selector.addOperator(BaseOperator(alp.Event)())
  weightsSM = {'PUWeight', 'PdfWeight', 'BTagWeight','ReWeightingNoN_'+sam}
  weightsSM_v = vector("string")()
  for w in weightsSM: weightsSM_v.push_back(w)
  selector.addOperator(FolderOperator(alp.Event)("pair"))
  selector.addOperator(JetPlotterOperator(alp.Event)(btagAlgo, weightsSM_v))        
  selector.addOperator(DiJetPlotterOperator(alp.Event)(weightsSM_v))
  procOpt = "ofile=./"+"HHTo4B_"+sam+".root" if not oDir else "ofile="+oDir+"HHTo4B_"+sam+".root"
  tchain.Process(selector, procOpt, tchain.GetEntries())  

print "### processed {} samples ###".format(ns)
Ejemplo n.º 3
0
        print "ERROR: no generated evts histos"
        continue       
    tf.Close()
    ngenev = h_genEvts.GetBinContent(1)
    config["n_gen_events"]=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(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()
Ejemplo n.º 4
0
    if not files:
        print "WARNING: files do not exist"
        continue

    if "Run" in files[0]: config["isData"] = True

    #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(
        CounterOperator(alp.Event)(config["n_gen_events"], weights_v))
    selector.addOperator(TreeConverterOperator(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
Ejemplo n.º 5
0
    print tchain.Draw(
        ">>el{}".format(sname),
        "(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"
Ejemplo n.º 6
0
    print  "empty files {}".format(nerr)

    #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))
Ejemplo n.º 7
0
        print "ERROR: no generated evts histos"
        continue
    tf.Close()
    ngenev = h_genEvts.GetBinContent(1)
    config["n_gen_events"] = 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(CounterOperator(alp.Event)())

    selector.addOperator(TriggerOperator(alp.Event)(trg_names_v))
    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))
    selector.addOperator(ThrustFinderOperator(alp.Event)())
    selector.addOperator(HemisphereProducerOperator(alp.Event)())
    selector.addOperator(HemisphereWriterOperator(alp.Event)())

    #create tChain and process each files
    tchain = TChain("pair/tree")
Ejemplo n.º 8
0
            tf = TFile(f)
            if tf.Get('counter/c_nEvents'):
                hcount.Add(tf.Get('counter/c_nEvents'))
            else:
                nerr += 1
            tf.Close()
        ngenev = hcount.GetBinContent(1)
        config["n_gen_events"] = ngenev
        print "empty files {}".format(nerr)
        print "genevts {}".format(ngenev)

    json_str = json.dumps(config)

    #define selectors list
    selector = ComposableSelector(alp.Event)(0, json_str)
    selector.addOperator(BaseOperator(alp.Event)())
    if args.jetCorr == 0:
        print "- applying JEC Up -"
        selector.addOperator(JEShifterOperator(alp.Event)(+1))
    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 -"
Ejemplo n.º 9
0
        tf.Close()
    ngenev = hcount.GetBinContent(1)
    config["n_gen_events"]=ngenev
    print  "gen numEv {}".format(ngenev)
    print  "empty files {}".format(nerr)

    #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(CounterOperator(alp.Event)())

    selector.addOperator(TriggerOperator(alp.Event)(trg_namesD_v))
    selector.addOperator(CounterOperator(alp.Event)())

    selector.addOperator(JetFilterOperator(alp.Event)(2.5, 30., 4))
    selector.addOperator(CounterOperator(alp.Event)())

    selector.addOperator(FolderOperator(alp.Event)("def"))
    selector.addOperator(JetPlotterOperator(alp.Event)("pt",weights_v))
    selector.addOperator(MiscellPlotterOperator(alp.Event)(weights_v))
    selector.addOperator(CounterOperator(alp.Event)())

    selector.addOperator(BTagFilterOperator(alp.Event)("pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.800, 2, config["isData"], data_path))
    selector.addOperator(CounterOperator(alp.Event)())
Ejemplo n.º 10
0
    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"]

    # load the operator
    gROOT.ProcessLine("#include \"{}\"".format(operator_file))
    operator_name = os.path.splitext(os.path.basename(operator_file))[0]
    Operator = importlib.import_module("ROOT.{}".format(operator_name))

    # define selectors list
    selector = ComposableSelector(alp.Event)(0, json.dumps(config))
    selector.addOperator(Operator(alp.Event)())

    #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()
Ejemplo n.º 11
0
        continue
    else:
        if "Run" in files[0]: config["isData"] = True
        if "GluGluToHH" in files[0] or "HHTo4B" in files[0]:
            config["isSignal"] = True

    #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)("trg_Iso"))
    selector.addOperator(FolderOperator(alp.Event)("trg_IsoAndJet"))
    selector.addOperator(
        CounterOperator(alp.Event)(config["n_gen_events"], weights_v))
    selector.addOperator(JetPlotterOperator(alp.Event)(btagAlgo, weights_v))
    selector.addOperator(MiscellPlotterOperator(alp.Event)(weights_v))
    selector.addOperator(EventWriterOperator(alp.Event)(json_str, weights_v))

    #create tChain and process each files
    #    tchain = TChain("trg_Iso/tree")
    tchain = TChain("trg_IsoAndJet/tree")
    for File in files:
        tchain.Add(File)
    nev = numEvents if (numEvents > 0 and numEvents < tchain.GetEntries()
Ejemplo n.º 12
0
        continue

    if "Run" in files[0]: config["isData"] = True

    json_str = json.dumps(config)

    #get hem_tree for mixing
    tch_hem = TChain("pair/hem_tree")
    for f in files:
        tch_hem.Add(f)

    print tch_hem.GetEntries()

    #define selectors list
    selector = ComposableSelector(alp.Event)(0, json_str)
    selector.addOperator(ThrustFinderOperator(alp.Event)())
    selector.addOperator(HemisphereProducerOperator(alp.Event)())
    selector.addOperator(
        HemisphereMixerOperator(alp.Event)(tch_hem, btagAlgo, btag_wp[1],
                                           nn_vars_v, 11))  #WARNING!!
    selector.addOperator(
        MixedEventWriterOperator(alp.Event)(btagAlgo, btag_wp[1], mixing_comb))

    #create tChain and process each files
    tchain = TChain("pair/tree")
    for File in files:
        tchain.Add(File)
    entr = tchain.GetEntries()
    nev = numEvents if (numEvents > 0 and numEvents < entr) else entr
    sname = sname + "_{}".format(args.comb)
    procOpt = "ofile=./" + sname + ".root" if not oDir else "ofile=" + oDir + "/" + sname + ".root"
Ejemplo n.º 13
0
            tf.Close()
        ngenev = hcount.GetBinContent(1)
        config["n_gen_events"] = ngenev
        print "gen numEv {}".format(ngenev)
        print "empty files {}".format(nerr)

    #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)())
    if args.jetCorr == 0:
        print "- applying JEC Up -"
        selector.addOperator(JEShifterOperator(alp.Event)(+1))
    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)(True))
    elif args.jetCorr == 3:
        print "- applying JER Down -"
        selector.addOperator(JERShifterOperator(alp.Event)(False))
    else:
        print "- default JEC-JER applied -"
Ejemplo n.º 14
0
        continue

    if "Run" in files[0]: config["isData"] = True

    json_str = json.dumps(config)

    #get hem_tree for mixing
    tch_hem = TChain("pair/hem_tree")
    for f in files:
        tch_hem.Add(f)

    print tch_hem.GetEntries()

    #define selectors list
    selector = ComposableSelector(alp.Event)(0, json_str)
    selector.addOperator(ThrustFinderOperator(alp.Event)())
    selector.addOperator(HemisphereProducerOperator(alp.Event)())
    selector.addOperator(
        HemisphereMixerOperator(alp.Event)(tch_hem, btagAlgo, btag_wp[1],
                                           nn_vars_v))
    selector.addOperator(MixedEventWriterOperator(alp.Event)(btagAlgo, 4))

    #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)
Ejemplo n.º 15
0
        print "WARNING: files do not exist"
        continue
    else:
        if "Run" in files[0]: config["isData"] = True
        if "GluGluToHH" in files[0] or "HHTo4B" in files[0]: config["isSignal"] = True

    #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)("pair"))
    selector.addOperator(CounterOperator(alp.Event)(config["n_gen_events"], 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))

    #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)
Ejemplo n.º 16
0
    if not files: 
        print "WARNING: files do not exist"
        continue

    if "Run" in files[0]: config["isData"] = True 

    #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(CounterOperator(alp.Event)())
    selector.addOperator(TreeConverterOperator(alp.Event)())

    #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)
Ejemplo n.º 17
0
    if not files:
        print "WARNING: files do not exist"
        continue
    else:
        if "Run" in files[0]: config["isData"] = True

    #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)(weights_v))

    selector.addOperator(ReWeightingOperator(alp.Event)())

    selector.addOperator(FolderOperator(alp.Event)("reweight"))
    selector.addOperator(CounterOperator(alp.Event)(weights_v))
    if args.savePlots:
        selector.addOperator(
            JetPlotterOperator(alp.Event)(btagAlgo, weights_v))
    if args.savePlots:
        selector.addOperator(DiJetPlotterOperator(alp.Event)(weights_v))
    selector.addOperator(EventWriterOperator(alp.Event)(json_str, weights_v))
Ejemplo n.º 18
0
        tf.Close()
    ngenev = hcount.GetBinContent(1)
    config["n_gen_events"] = ngenev
    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))
Ejemplo n.º 19
0
        ngenev = hcount.GetBinContent(1)
        config["n_gen_events"] = ngenev
        print "empty files {}".format(nerr)
        print "genevts {}".format(ngenev)

    #read weights from alpSamples
    if not args.doMixed:
        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)())
    if args.jetCorr == 0:
        print "- applying JEC Up -"
        selector.addOperator(JEShifterOperator(alp.Event)(+1))
    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 -"
Ejemplo n.º 20
0
    config["xsec_br"] = samples[sname]["xsec_br"]
    config["matcheff"] = samples[sname]["matcheff"]
    config["kfactor"] = samples[sname]["kfactor"]

    json_str = json.dumps(config)

    #get hem_tree for mixing
    tch = TChain("pair/hem_tree")
    for f in files:
        tch.Add(f)

    print tch.GetEntries()

    #define selectors list
    selector = ComposableSelector(alp.Event)(0, json_str)
    selector.addOperator(ThrustFinderOperator(alp.Event)())
    selector.addOperator(HemisphereProducerOperator(alp.Event)())
    selector.addOperator(HemisphereMixerOperator(alp.Event)(tch, nn_vars_v))
    selector.addOperator(MixedEventWriterOperator(alp.Event)())

    #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
Ejemplo n.º 21
0
            tf.Close()
        ngenev = hcount.GetBinContent(1)
        config["n_gen_events"]=ngenev
        print  "gen numEv {}".format(ngenev)
        print  "empty files {}".format(nerr)

    #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)())
    if args.jetCorr == 0:
        print "- applying JEC Up -"
        selector.addOperator(JEShifterOperator(alp.Event)(+1))
    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 -"
Ejemplo n.º 22
0
        tf.Close()
    ngenev = hcount.GetBinContent(1)
    config["n_gen_events"]=ngenev
    print  "gen numEv {}".format(ngenev)
    print  "empty files {}".format(nerr)

    #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(CounterOperator(alp.Event)())

    selector.addOperator(TriggerOperator(alp.Event)(trg_names_v))
    selector.addOperator(CounterOperator(alp.Event)())

    selector.addOperator(JetFilterOperator(alp.Event)(2.5, 30., 4))
    selector.addOperator(CounterOperator(alp.Event)())
    selector.addOperator(FolderOperator(alp.Event)("acc"))
    selector.addOperator(JetPlotterOperator(alp.Event)("pfCombinedInclusiveSecondaryVertexV2BJetTags",weights_v))

    selector.addOperator(BTagFilterOperator(alp.Event)("pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.800, 4, config["isData"], data_path))
    selector.addOperator(CounterOperator(alp.Event)())
    selector.addOperator(FolderOperator(alp.Event)("btag"))
    selector.addOperator(JetPlotterOperator(alp.Event)("pfCombinedInclusiveSecondaryVertexV2BJetTags",weights_v))        
Ejemplo n.º 23
0
        if "_v14" in files[0]:
            isHLT = True  #patch - check better way to look for HLT

    #read counters to get generated eventsbj
    ngenev = 0
    for f in files:
        tf = TFile(f)
        hcount.Add(tf.Get('counter/c_nEvents'))
        tf.Close()
    ngenev = hcount.GetBinContent(1)
    config["n_gen_events"] = ngenev
    print "gen numEv {}".format(ngenev)

    #define selectors list
    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(JetPairingOperator(alp.Event)(4))
    if (isHLT): selector.addOperator(TriggerOperator(alp.Event)(trg_names_v))
    else: print "no HLT, skip trigger selection"
    selector.addOperator(CounterOperator(alp.Event)())
    selector.addOperator(DiJetPlotterOperator(alp.Event)())
    selector.addOperator(CounterOperator(alp.Event)())
    selector.addOperator(EventWriterOperator(alp.Event)())
#!/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")
Ejemplo n.º 25
0
        tchain.Add(f)

#read weights from alpSamples -- DEBUG - unused
config["xsec_br"] = -1.
config["matcheff"] = -1.
config["kfactor"] = -1.

config["n_gen_events"] = ngenev
print "gen numEv {}".format(ngenev)
print "empty files {}".format(nerr)

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"],weights_v))

selector.addOperator(
    ReWeightingOperator(alp.Event)(rw_fname_SM, rw_fname_BM, rw_fname_HH))

#selector.addOperator(FolderOperator(alp.Event)("pair"))
#selector.addOperator(CounterOperator(alp.Event)(config["n_gen_events"],weights_v))
if args.savePlots:
    selector.addOperator(JetPlotterOperator(alp.Event)(btagAlgo, weights_v))
if args.savePlots:
    selector.addOperator(DiJetPlotterOperator(alp.Event)(weights_v))
selector.addOperator(EventWriterOperator(alp.Event)(json_str, weights_v))