# print(eff_isocut)
        # print(eff_presel)
        ratio.append(eff/eff_presel)
        deep_thr.append(thr)
        eff_iso.append(eff_isocut/eff_presel)
    print(ratio)
    print(deep_thr)
    print(eff_iso)

    # load taus from HLT physics dataset
    dataset_rates = Dataset(fileName_rates, treeName_in, treeName_gen)
    taus_rates = dataset_rates.get_taus()
    tau_1_rates = taus_rates[0]
    tau_2_rates = taus_rates[1]

    Nev_den = len(dataset_rates.get_gen_events())
    # Pt_thr_list = np.linspace(30, 101, 35)
    Pt_thr_list = pt_bins
    rate_list = []
    yerr_rate = np.zeros((2, len(Pt_thr_list)))
    for i, Pt_thr in enumerate(Pt_thr_list):
        tau_1_mask = deepTau_selection_ptdep(tau_1_rates, pt_bins, deep_thr) & reco_tau_selection(tau_1_rates, minPt=Pt_thr)
        tau_2_mask = deepTau_selection_ptdep(tau_2_rates, pt_bins, deep_thr) & reco_tau_selection(tau_2_rates, minPt=Pt_thr)
        Nev_num = ak.sum(ditau_selection(tau_1_mask, tau_2_mask))
        rate, rate_err_low, rate_err_up = compute_rate_witherr(Nev_num, Nev_den, is_MC=False, L1rate=L1rate_bm)
        rate_list.append(rate)
        yerr_rate[0][i] = rate_err_low
        yerr_rate[1][i] = rate_err_up
    # print(rate_list)

    with PdfPages(plot_path + "optimization_" + plot_name + ".pdf") as pdf:
Exemplo n.º 2
0
original_taus = dataset_eff.get_taus(apply_selection=False)

# get sample for rate computation
print("Loading sample for rate")
if args.qcd:
    # get QCD sample
    QCD_taus_list = []
    QCD_xs_list = []
    QCD_den_list = []
    with open(QCD_fileJson, "r") as json_file:
        samples = json.load(json_file)
        for key, value in samples.items():
            data = Dataset(data_path + value[0], treeName_in, treeName_gen)
            QCD_taus_list.append(data.get_taus())
            QCD_xs_list.append(value[1])
            QCD_den_list.append(len(data.get_gen_events()))
    print(QCD_xs_list)
else:
    # get HLT physics sample
    dataset_rates = Dataset(data_path + fileName_rates, treeName_in,
                            treeName_gen)
    taus_rates = dataset_rates.get_taus()
    Nev_den = len(dataset_rates.get_gen_events())

with PdfPages(plot_path + 'eff_vs_rate_{}.pdf'.format(plot_name)) as pdf:

    print("Getting reasonable thresholds")
    thr_list = np.linspace(0.0, 1.0, num=100)

    for Pt_thr in Pt_thr_list: