17 parser = 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.')
23 args = parser.parse_args()
28 def make_1D_bin(name, min_val, max_val):
29 return {name: [min_val, max_val]}
32 def make_2D_bin(bin_x, bin_y):
38 def make_3D_bin(bin_x, bin_y, bin_z):
57 table_location = args.input_path
60 yedges = np.load(f
"{table_location}/table_pRecoilPhipRecoilTheta_pRecoilfrom0p2andpRecoilto0p4_pRecoilPhibins.npy")
61 xedges = np.load(f
"{table_location}/table_pRecoilPhipRecoilTheta_pRecoilfrom0p2andpRecoilto0p4_pRecoilThetabins.npy")
64 values = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*values.npy")
65 stat_up = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*statistical_up.npy")
66 stat_down = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*statistical_down.npy")
67 sys_up = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*systematic_up.npy")
68 sys_down = glob.glob(f
"{table_location}/table_pRecoilPhipRecoilTheta*systematic_down.npy")
71 bins_phi = [make_1D_bin(
"phi", lowbin, highbin)
for lowbin, highbin
in zip(yedges[:-1], yedges[1:])]
72 bins_theta = [make_1D_bin(
"theta", lowbin, highbin)
for lowbin, highbin
in zip(xedges[:-1], xedges[1:])]
76 for 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)])
101 outOfRangeWeightInfo = {}
102 outOfRangeWeightInfo[
"Weight"] = np.nan
103 outOfRangeWeightInfo[
"StatErrUp"] = np.nan
104 outOfRangeWeightInfo[
"SystErrUp"] = np.nan
105 outOfRangeWeightInfo[
"StatErrDown"] = np.nan
106 outOfRangeWeightInfo[
"SystErrDown"] = np.nan
107 outOfRangeWeightInfo[
"TotalErrDown"] = np.nan
108 outOfRangeWeightInfo[
"TotalErrDown"] = np.nan
111 addtable = b2.register_module(
'ParticleWeightingLookUpCreator')
112 addtable.param(
'tableIDNotSpec', table)
113 addtable.param(
'outOfRangeWeight', outOfRangeWeightInfo)
114 addtable.param(
'experimentHigh', -1)
115 addtable.param(
'experimentLow', 0)
116 addtable.param(
'runHigh', -1)
117 addtable.param(
'runLow', 0)
118 addtable.param(
'tableName',
"PhotonEfficiencyDataMCRatio_June2021")
120 eventinfosetter = b2.register_module(
'EventInfoSetter')
121 eventinfosetter.param(
'evtNumList', [10])
122 eventinfosetter.param(
'runList', [0])
123 eventinfosetter.param(
'expList', [0])
125 my_path = b2.create_path()
126 my_path.add_module(addtable)
127 my_path.add_module(eventinfosetter)