def generate_one_region(region): for variation in bkg_ntuple_names: print(f"Generating fit ntuples for {variation}") for sample_key in bkg_keys: dump_contents = [] ntuple_path = ntup_save_dir.joinpath( f"{region}/{variation}/run2/{sample_key}.root") ntuple_path.parent.mkdir(parents=True, exist_ok=True) if variation == "tree_NOMINAL": for branch in branch_list_wt: array_path = input_array_dir.joinpath( f"{region}/{variation}/run2/{sample_key}_{branch}.npy") branch_content = np.load(array_path) dump_contents.append(branch_content) dump_ntup_from_npy( "ntup", branch_list_wt, "f", dump_contents, ntuple_path, ) else: for branch in branch_list: array_path = input_array_dir.joinpath( f"{region}/{variation}/run2/{sample_key}_{branch}.npy") branch_content = np.load(array_path) dump_contents.append(branch_content) dump_ntup_from_npy( "ntup", branch_list, "f", dump_contents, ntuple_path, )
for variation in sig_ntuple_names: # for variation in ["tree_NOMINAL"]: # low mass print(f"Generating fit ntuples for {variation}") for sample_key in sig_keys_low: dump_contents = [] ntuple_path = ntup_save_dir.joinpath( f"low_mass/{variation}/{camp}/{sample_key}.root") ntuple_path.parent.mkdir(parents=True, exist_ok=True) if variation == "tree_NOMINAL": for branch in branch_list_wt_low: array_path = input_array_dir.joinpath( f"low_mass/{variation}/{camp}/{sample_key}_{branch}.npy") branch_content = np.load(array_path) dump_contents.append(branch_content) dump_ntup_from_npy("ntup", branch_list_wt_low, "f", dump_contents, ntuple_path) else: for branch in branch_list: array_path = input_array_dir.joinpath( f"low_mass/{variation}/{camp}/{sample_key}_{branch}.npy") branch_content = np.load(array_path) dump_contents.append(branch_content) dump_ntup_from_npy("ntup", branch_list, "f", dump_contents, ntuple_path) # high_mass print(f"Generating fit ntuples for {variation}") for sample_key in sig_keys_high: dump_contents = [] ntuple_path = ntup_save_dir.joinpath( f"high_mass/{variation}/{camp}/{sample_key}.root")
"sig_Zp057", "sig_Zp060", "sig_Zp063", "sig_Zp066", "sig_Zp069", "sig_Zp072", "sig_Zp075", "bkg_ggZZ", "bkg_qcd", ] branch_list = ["mz1", "mz2", "dnn_out", "weight"] # get ntuples for sample_key in sample_keys: dump_contents = [] for branch in branch_list: array_path = input_array_dir.joinpath(f"{sample_key}_{branch}.npy") branch_content = np.load(array_path) dump_contents.append(branch_content) ntuple_path = ntup_save_dir.joinpath(f"{sample_key}.root") dump_ntup_from_npy( "ntup", branch_list, "f", dump_contents, ntuple_path, )