From 1cd79549ee8ceb0f5e64e06611d891098905c05a Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 5 Oct 2020 11:15:33 -0500 Subject: update how the energy bias is applied in chi2 and plot-michels This commit updates how the energy bias is applied when we correct for the energy bias in correct_energy_bias(). The correct way to apply this correction is to compute: T_corrected = T_reco/(1+bias) whereas previously we were multiplying by (1-bias). --- utils/chi2 | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'utils/chi2') diff --git a/utils/chi2 b/utils/chi2 index 23c8560..205037b 100755 --- a/utils/chi2 +++ b/utils/chi2 @@ -489,17 +489,19 @@ def correct_energy_bias(df): Corrects for the energy bias of the reconstruction relative to the true Monte Carlo energy. """ - # Note: We subtract here since the values in the energy_bias array are MC - # reconstruction relative to truth. So, for example if we have an energy - # bias of -2% at 100 MeV, then the array will contain -0.02. In this case, - # our reconstruction is low relative to the truth, so we need to *increase* - # our estimate. - df.loc[df['id1'] == 20,'energy1'] -= df.loc[df['id1'] == 20,'energy1']*np.interp(df.loc[df['id1'] == 20,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['e_bias']) - df.loc[df['id2'] == 20,'energy2'] -= df.loc[df['id2'] == 20,'energy2']*np.interp(df.loc[df['id2'] == 20,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['e_bias']) - df.loc[df['id3'] == 20,'energy3'] -= df.loc[df['id3'] == 20,'energy3']*np.interp(df.loc[df['id3'] == 20,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['e_bias']) - df.loc[df['id1'] == 22,'energy1'] -= df.loc[df['id1'] == 22,'energy1']*np.interp(df.loc[df['id1'] == 22,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['u_bias']) - df.loc[df['id2'] == 22,'energy2'] -= df.loc[df['id2'] == 22,'energy2']*np.interp(df.loc[df['id2'] == 22,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['u_bias']) - df.loc[df['id3'] == 22,'energy3'] -= df.loc[df['id3'] == 22,'energy3']*np.interp(df.loc[df['id3'] == 22,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['u_bias']) + # Note: We divide here since we define the bias as: + # + # bias = (T_reco - T_true)/T_true + # + # Therefore, + # + # T_true = T_reco/(1+bias) + df.loc[df['id1'] == 20,'energy1'] /= (1+np.interp(df.loc[df['id1'] == 20,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['e_bias'])) + df.loc[df['id2'] == 20,'energy2'] /= (1+np.interp(df.loc[df['id2'] == 20,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['e_bias'])) + df.loc[df['id3'] == 20,'energy3'] /= (1+np.interp(df.loc[df['id3'] == 20,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['e_bias'])) + df.loc[df['id1'] == 22,'energy1'] /= (1+np.interp(df.loc[df['id1'] == 22,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['u_bias'])) + df.loc[df['id2'] == 22,'energy2'] /= (1+np.interp(df.loc[df['id2'] == 22,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['u_bias'])) + df.loc[df['id3'] == 22,'energy3'] /= (1+np.interp(df.loc[df['id3'] == 22,'energy1'],ENERGY_BIAS['T'],ENERGY_BIAS['u_bias'])) df['ke'] = df['energy1'].fillna(0) + df['energy2'].fillna(0) + df['energy3'].fillna(0) return df -- cgit