Exemplo n.º 1
0
    for input_file in input_files:
        input_chain.Add(input_file)
    print("Finished loading chain with ", input_chain.GetEntries(), " entries")
    data_frame = RDF(input_chain, branch_vec)
else:
    print("Dataframe flag was set. Handling argument as dataframe.")
    input_file = args[0]
    data_frame = RDF("tree", input_file)

print("Finished converting the chain to RDataFrame")

if not options.is_dataframe and options.save:
    print("saving dataframe to disk as ",
          data_mc_string + "_" + options.name + "_dataframe.root")
    data_frame.Snapshot(
        "tree", data_mc_string + "_" + options.name + "_dataframe.root",
        branch_vec)
    print("saved dataframe to disk ...")

#binning = [200, 250, 300, 350, 400, 500, 700, 1500]
# Hadr_Recoil_Pt>200. && N_AK15Jets==1 && N_TightMuons<=2 && N_TightMuons>=1 && Muon_Pt[0]>29. && N_LooseElectrons==0 && N_LoosePhotons==0
# Triggered_HLT_IsoMu27_vX==1
# Triggered_HLT_PFMETNoMu120_PFMHTNoMu120_IDTight_PFHT60_vX == 1 || Triggered_HLT_PFMETNoMu120_PFMHTNoMu120_IDTight_vX == 1

binning_x = [250 + (10 * i) for i in range(101)]

reference_events = data_frame.Filter(options.selection).Define(
    "M_W_transverse_0", "M_W_transverse[0]").Define("AK15Jet_Pt_0",
                                                    "AK15Jet_Pt[0]")
histo = None
histo = reference_events.Define("WEIGHT1", "Weight_XS*Weight_GEN_nom").Histo1D(
Exemplo n.º 2
0
        input_chain.Add(input_file)
    print("Finished loading chain with ", input_chain.GetEntries(), " entries")
    data_frame = RDF(input_chain, branch_vec)
else:
    print("Dataframe flag was set. Handling argument as dataframe.")
    input_file = args[0]
    data_frame = RDF(options.treename, input_file)

print("Finished creating the RDataFrame")

# possibly save the created RDataFrame to disk
if not options.is_dataframe and options.save:
    print("saving dataframe to disk as ",
          data_mc_string + "_" + names + "_dataframe.root")
    data_frame.Snapshot("tree",
                        data_mc_string + "_" + names + "_dataframe.root",
                        branch_vec)
    print("saved dataframe to disk ...")

# a label for the ouput files
name = options.name

# a ROOT style selection string
selection = options.selection

# dictionaries to contain the requested 1D and 2D templates
histos_1D = {}
histos_2D = {}

# apply the selection from above to the RDataFrame and define a weight on the remaining events
# the weight can also be a branch or constructed from several branches, e.g. generator_weight*sample_weight