From 85c8b695cd07a52477edc3a3e31a31d8b8b091a8 Mon Sep 17 00:00:00 2001 From: Lanqing Yuan Date: Mon, 18 Dec 2023 15:38:56 -0600 Subject: [PATCH] Simplify match for pema issue (#74) * removed pema dependence * lists * remove trash --- jobs/config.ini | 2 +- saltax/match/match.py | 37 +++++++++++++++++-------------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/jobs/config.ini b/jobs/config.ini index 51b64ef..8090adb 100644 --- a/jobs/config.ini +++ b/jobs/config.ini @@ -4,7 +4,7 @@ t_sleep = 1 [job] container = xenonnt-development.simg -runids = 021952,022510,022776,022773,022738,022735,022732,022726,022723,022717,022694,022691,022685,028636,031661,031124,029866,027982,030329,025444,027513,030891,025416,025161,028945,031709,028239,030937,028510,028636,031661,031124,029866,027982,030329,025444,027513,030891,025416,025161,028945,031709,028239,030937,028510,027323,026550,025953,031657,029198,026577,028031,025719,029208,026624,031147,028426,030102,029144,029472,027705,031156,031802,026503,029139,028047,025579,030079,025953,028542,025413,031803,029938,030287,026603,028890,030128,029410,031761 +runids = 021952,022510,022776,022773,022738,022735,022732,022726,022723,022717,022694,022691,022685,022682,022679,022676,022670,022667,028636,031661,031124,029866,027982,030329,025444,027513,030891,025416,025161,028945,031709,028239,030937,028510,028636,031661,031124,029866,027982,030329,025444,027513,030891,025416,025161,028945,031709,028239,030937,028510,027323,026550,025953,031657,029198,026577,028031,025719,029208,026624,031147,028426,030102,029144,029472,027705,031156,031802,026503,029139,028047,025579,030079,025953,028542,025413,031803,029938,030287,026603,028890,030128,029410,031761 output_folder = /project/lgrandi/yuanlq/salt/ saltax_mode = salt faxconf_version = sr0_v4 diff --git a/saltax/match/match.py b/saltax/match/match.py index 6546c18..9a97a9e 100644 --- a/saltax/match/match.py +++ b/saltax/match/match.py @@ -2,12 +2,11 @@ from tqdm import tqdm -def filter_out_missing_s1_s2(truth, match): +def filter_out_missing_s1_s2(truth): """ Filter out simulated events that have no S1 or S2 or both :param truth: truth from wfsim - :param match: match_acceptance_extended from pema - :return: filtered truth and match + :return: filtered truth """ bad_mask = np.zeros(len(truth), dtype=bool) max_event_number = np.max(np.unique(truth['event_number'])) @@ -30,15 +29,14 @@ def filter_out_missing_s1_s2(truth, match): print("Filter out %s percent of events due to missing S1 or S2 or both"\ % (np.sum(bad_mask)/len(truth)*100)) - return truth[~bad_mask], match[~bad_mask] + return truth[~bad_mask] -def filter_out_multiple_s1_s2(truth, match): +def filter_out_multiple_s1_s2(truth): """ Filter out simulated events that have multiple S1 or S2 reconstructed from wfsim. :param truth: truth from wfsim - :param match: match_acceptance_extended from pema - :return: filtered truth and match + :return: filtered truth """ bad_mask = np.zeros(len(truth), dtype=bool) max_event_number = np.max(np.unique(truth['event_number'])) @@ -54,7 +52,7 @@ def filter_out_multiple_s1_s2(truth, match): print("Filter out %s percent of events due to multiple S1 or S2"\ % (np.sum(bad_mask)/len(truth)*100)) - return truth[~bad_mask], match[~bad_mask] + return truth[~bad_mask] def filter_out_not_found(truth, match): @@ -140,10 +138,10 @@ def pair_events_to_matched_simu(matched_simu, events): j_selected_events = np.where((events['s1_endtime']>=e_simu['s1_time'])& (e_simu['s1_endtime']>=events['s1_time']))[0] - j_selected_events = np.where((events['s1_endtime']>=e_simu['s1_time'])& - (e_simu['s1_endtime']>=events['s1_time'])& - (events['s2_endtime']>=e_simu['s2_time'])& - (e_simu['s2_endtime']>=events['s2_time']))[0] + #j_selected_events = np.where((events['s1_endtime']>=e_simu['s1_time'])& + # (e_simu['s1_endtime']>=events['s1_time'])& + # (events['s2_endtime']>=e_simu['s2_time'])& + # (e_simu['s2_endtime']>=events['s2_time']))[0] assert len(j_selected_events) <= 1, "Multiple events found for one truth event!?" # If no event is found, then we consider lost @@ -156,17 +154,16 @@ def pair_events_to_matched_simu(matched_simu, events): return matched_to -def pair_salt_to_simu(truth, match, events_simu, events_salt): +def pair_salt_to_simu(truth, events_simu, events_salt): """ Filter out bad simulation truth and then pair salted events to matched simulation events. :param truth: filtered truth - :param match: match_acceptance_extended from pema :param events_simu: events from wfsim :param events_salt: events from saltax after reconstruction - :return: ind_salt_matched_to_simu, ind_simu_matched_to_truth, truth_filtered, match_filtered + :return: ind_salt_matched_to_simu, ind_simu_matched_to_truth, truth_filtered """ - truth_filtered, match_filtered = filter_out_missing_s1_s2(truth, match) - truth_filtered, match_filtered = filter_out_multiple_s1_s2(truth_filtered, match_filtered) + truth_filtered = filter_out_missing_s1_s2(truth) + truth_filtered = filter_out_multiple_s1_s2(truth_filtered) # Temporarily turn off this filter because of wfsim bug in s2 timing #truth_filtered, match_filtered = filter_out_not_found(truth_filtered, match_filtered) @@ -176,10 +173,10 @@ def pair_salt_to_simu(truth, match, events_simu, events_salt): ind_salt_matched_to_simu = pair_events_to_matched_simu(events_simu_matched_to_truth, events_salt) - return ind_salt_matched_to_simu, ind_simu_matched_to_truth, truth_filtered, match_filtered + return ind_salt_matched_to_simu, ind_simu_matched_to_truth, truth_filtered -def match(truth, match, events_simu, events_salt): +def match(truth, events_simu, events_salt): """ Match salted events to simulation events. :param truth: truth from wfsim @@ -190,7 +187,7 @@ def match(truth, match, events_simu, events_salt): """ ind_salt_matched_to_simu, \ ind_simu_matched_to_truth, \ - _, _ = pair_salt_to_simu(truth, match, events_simu, events_salt) + _ = pair_salt_to_simu(truth, events_simu, events_salt) events_simu_matched_to_truth = events_simu[ind_simu_matched_to_truth[ind_simu_matched_to_truth>=0]] events_salt_matched_to_simu = events_salt[ind_salt_matched_to_simu[ind_salt_matched_to_simu>=0]]