17parser = argparse.ArgumentParser()
21 default=
"/afs/desy.de/user/h/hsvidras/repositories/photoneff/analysis/plots_lima/lima/",
22 help=
'Path to folder with efficiency ratio files generated by the photon efficiency workflow.')
23args = parser.parse_args()
28def make_1D_bin(name, min_val, max_val):
29 return {name: [min_val, max_val]}
32def make_2D_bin(bin_x, bin_y):
38def make_3D_bin(bin_x, bin_y, bin_z):
57table_location = args.input_path
60yedges = np.load(f
"{table_location}/table_pRecoilPhipRecoilTheta_pRecoilfrom0p2andpRecoilto0p4_pRecoilPhibins.npy")
61xedges = np.load(f
"{table_location}/table_pRecoilPhipRecoilTheta_pRecoilfrom0p2andpRecoilto0p4_pRecoilThetabins.npy")
64values = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*values.npy")
65stat_up = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*statistical_up.npy")
66stat_down = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*statistical_down.npy")
67sys_up = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*systematic_up.npy")
68sys_down = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*systematic_down.npy")
71bins_phi = [make_1D_bin(
"phi", lowbin, highbin)
for lowbin, highbin
in zip(yedges[:-1], yedges[1:])]
72bins_theta = [make_1D_bin(
"theta", lowbin, highbin)
for lowbin, highbin
in zip(xedges[:-1], xedges[1:])]
76for n, valuenp
in enumerate(values):
78 bins_with_text = valuenp.split(
'pRecoilfrom')[1].split(
'pRecoilto')
79 lowbin_str = bins_with_text[0][:-3].replace(
'p',
'.')
80 highbin_str = bins_with_text[1][:-11].replace(
'p',
'.')
81 pbin = make_1D_bin(
"E", float(lowbin_str), float(highbin_str))
83 value = np.load(valuenp)
84 stat_err_up_table = np.load(stat_up[n])
85 stat_err_down_table = np.load(stat_down[n])
86 sys_err_up_table = np.load(sys_up[n])
87 sys_err_down_table = np.load(sys_down[n])
88 for j, ybin
in enumerate(bins_phi):
89 for i, xbin
in enumerate(bins_theta):
91 weightInfo[
"Weight"] = value[i, j]
92 weightInfo[
"StatErrUp"] = stat_err_up_table[i, j]
93 weightInfo[
"StatErrDown"] = stat_err_down_table[i, j]
94 weightInfo[
"SystErrUp"] = sys_err_up_table[i, j]
95 weightInfo[
"SystErrDown"] = sys_err_down_table[i, j]
96 weightInfo[
"TotalErrUp"] = (sys_err_up_table[i, j]**2 + stat_err_up_table[i, j]**2)**0.5
97 weightInfo[
"TotalErrDown"] = (sys_err_down_table[i, j]**2 + stat_err_down_table[i, j]**2)**0.5
98 table.append([weightInfo, make_3D_bin(xbin, ybin, pbin)])
101outOfRangeWeightInfo = {}
102outOfRangeWeightInfo[
"Weight"] = np.nan
103outOfRangeWeightInfo[
"StatErrUp"] = np.nan
104outOfRangeWeightInfo[
"SystErrUp"] = np.nan
105outOfRangeWeightInfo[
"StatErrDown"] = np.nan
106outOfRangeWeightInfo[
"SystErrDown"] = np.nan
107outOfRangeWeightInfo[
"TotalErrDown"] = np.nan
108outOfRangeWeightInfo[
"TotalErrDown"] = np.nan
111addtable = b2.register_module(
'ParticleWeightingLookUpCreator')
112addtable.param(
'tableIDNotSpec', table)
113addtable.param(
'outOfRangeWeight', outOfRangeWeightInfo)
114addtable.param(
'experimentHigh', -1)
115addtable.param(
'experimentLow', 0)
116addtable.param(
'runHigh', -1)
117addtable.param(
'runLow', 0)
118addtable.param(
'tableName',
"PhotonEfficiencyDataMCRatio_June2021")
120eventinfosetter = b2.register_module(
'EventInfoSetter')
121eventinfosetter.param(
'evtNumList', [10])
122eventinfosetter.param(
'runList', [0])
123eventinfosetter.param(
'expList', [0])
125my_path = b2.create_path()
126my_path.add_module(addtable)
127my_path.add_module(eventinfosetter)