24parser = argparse.ArgumentParser()
28 default=
"/nfs/dust/belle2/user/kovalch/energyBiasCorrFiles/Feb2021.txt",
29 help=
'Path to input file with energy bias correction values .')
30args = parser.parse_args()
32weightsDB = args.input_path
33df_weightDB = pd.read_csv(weightsDB, delimiter=
r"\s+")
35tableName =
"Feb2021:TestEnergy"
36tableName2 =
"Feb2021:TestEnergy2"
41def make_1D_bin(name, min_val, max_val):
42 return {name: [min_val, max_val]}
45def get_weight(namew, w, namewerr, werr):
46 return {namew: w, namewerr: werr}
49def make_2D_bin(bin_x, bin_y):
55def make_3D_bin(bin_x, bin_y, bin_z):
57 bin_3d.update(bin_y).update(bin_z)
79for x
in range(0, len(df_weightDB)):
81 bins_x = make_1D_bin(df_weightDB[
'namebin1'].values[x], df_weightDB[
'minbin1'].values[x], df_weightDB[
'maxbin1'].values[x])
82 bins_y = make_1D_bin(df_weightDB[
'namebin2'].values[x], df_weightDB[
'minbin2'].values[x], df_weightDB[
'maxbin2'].values[x])
83 weightInfo = get_weight(
"Weight", df_weightDB[
'w'].values[x],
"StatErr", df_weightDB[
'werr'].values[x])
84 tableIDNotSpec.append([weightInfo, make_2D_bin(bins_x, bins_y)])
86 tableIDSpec.append([[weightInfo, make_2D_bin(bins_x, bins_y)], binID])
89outOfRangeWeightInfo = {}
90outOfRangeWeightInfo[
"Weight"] = -1
91outOfRangeWeightInfo[
"StatErr"] = -1
94addtable = b2.register_module(
'ParticleWeightingLookUpCreator')
95addtable.param(
'tableIDSpec', tableIDSpec)
96addtable.param(
'outOfRangeWeight', outOfRangeWeightInfo)
97addtable.param(
'experimentHigh', -1)
98addtable.param(
'experimentLow', 0)
99addtable.param(
'runHigh', -1)
100addtable.param(
'runLow', 0)
101addtable.param(
'tableName', tableName)
103addtable2 = b2.register_module(
'ParticleWeightingLookUpCreator')
104addtable2.param(
'tableIDNotSpec', tableIDNotSpec)
105addtable2.param(
'outOfRangeWeight', outOfRangeWeightInfo)
106addtable2.param(
'experimentHigh', -1)
107addtable2.param(
'experimentLow', 0)
108addtable2.param(
'runHigh', -1)
109addtable2.param(
'runLow', 0)
110addtable2.param(
'tableName', tableName2)
112eventinfosetter = b2.register_module(
'EventInfoSetter')
113eventinfosetter.param(
'evtNumList', [10])
114eventinfosetter.param(
'runList', [0])
115eventinfosetter.param(
'expList', [0])
117my_path = b2.create_path()
118my_path.add_module(addtable)
119my_path.add_module(addtable2)
120my_path.add_module(eventinfosetter)