From f8ecfab63e6842ce58a4525b6323347fb0fd8c03 Mon Sep 17 00:00:00 2001 From: rkansal47 Date: Wed, 20 Sep 2023 08:41:16 -0500 Subject: [PATCH 1/3] bf --- src/HHbbVV/postprocessing/postprocessing.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/HHbbVV/postprocessing/postprocessing.py b/src/HHbbVV/postprocessing/postprocessing.py index 386d5fe5..f7f8c4a9 100644 --- a/src/HHbbVV/postprocessing/postprocessing.py +++ b/src/HHbbVV/postprocessing/postprocessing.py @@ -351,6 +351,14 @@ def get_res_selection_regions( } +plot_sig_keys_nonres = [ + "HHbbVV", + "VBFHHbbVV", + "qqHH_CV_1_C2V_0_kl_1_HHbbVV", + "qqHH_CV_1_C2V_2_kl_1_HHbbVV", +] + + def main(args): shape_vars, scan, scan_cuts, scan_wps = _init(args) sig_keys, sig_samples, bg_keys, bg_samples = _process_samples(args) @@ -459,6 +467,7 @@ def main(args): systematics, template_dir, bg_keys=bg_keys, + plot_sig_keys=plot_sig_keys_nonres if not args.resonant else sig_keys, plot_dir=plot_dir, prev_cutflow=cutflow, # sig_splits=sig_splits, From c37bf0437f384ed9279d8e6935043fdf71cc0661 Mon Sep 17 00:00:00 2001 From: rkansal47 Date: Wed, 20 Sep 2023 13:28:10 -0500 Subject: [PATCH 2/3] bug fix --- src/HHbbVV/postprocessing/postprocessing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HHbbVV/postprocessing/postprocessing.py b/src/HHbbVV/postprocessing/postprocessing.py index f7f8c4a9..c4a92142 100644 --- a/src/HHbbVV/postprocessing/postprocessing.py +++ b/src/HHbbVV/postprocessing/postprocessing.py @@ -705,7 +705,8 @@ def apply_weights( for sample in events_dict: events = events_dict[sample] if sample == data_key: - events[weight_key] = events["weight"] + if weight_key not in events: + events[weight_key] = events["weight"] elif f"{weight_key}_noTrigEffs" not in events: fj_trigeffs = ak8TrigEffsLookup( events["ak8FatJetParticleNetMD_Txbb"].values, From 65c4156163214d23e12144ba5a5a974c6baf827d Mon Sep 17 00:00:00 2001 From: rkansal47 Date: Thu, 21 Sep 2023 16:00:51 -0500 Subject: [PATCH 3/3] minor update --- src/HHbbVV/postprocessing/postprocessing.py | 4 +++- src/HHbbVV/postprocessing/utils.py | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/HHbbVV/postprocessing/postprocessing.py b/src/HHbbVV/postprocessing/postprocessing.py index c4a92142..6917c676 100644 --- a/src/HHbbVV/postprocessing/postprocessing.py +++ b/src/HHbbVV/postprocessing/postprocessing.py @@ -960,6 +960,9 @@ def lpsfs( - Does it for all years once if args.lp_sf_all_years or just for the given year 2) Saves them to ``systs_file`` and CSV for posterity """ + if not all_years: + warnings.warn(f"LP SF only calculated from single year's samples", RuntimeWarning) + for sig_key in sig_keys: if sig_key not in systematics or "lp_sf" not in systematics[sig_key]: print(f"\nGetting LP SFs for {sig_key}") @@ -978,7 +981,6 @@ def lpsfs( ) # Only for testing, can do just for a single year else: - warnings.warn(f"LP SF only calculated from single year's samples", RuntimeWarning) # calculate only for current year events_dict[sig_key] = postprocess_lpsfs(events_dict[sig_key]) sel, cf = utils.make_selection( diff --git a/src/HHbbVV/postprocessing/utils.py b/src/HHbbVV/postprocessing/utils.py index 0ebfabf1..d07395d8 100644 --- a/src/HHbbVV/postprocessing/utils.py +++ b/src/HHbbVV/postprocessing/utils.py @@ -180,9 +180,9 @@ def _hem_cleaning(sample, events): if sample.endswith("2018C") or sample.endswith("2018D"): hem_cut = np.any( (events["ak8FatJetEta"] > -3.2) - * (events["ak8FatJetEta"] < -1.3) - * (events["ak8FatJetPhi"] > -1.57) - * (events["ak8FatJetPhi"] < -0.87), + & (events["ak8FatJetEta"] < -1.3) + & (events["ak8FatJetPhi"] > -1.57) + & (events["ak8FatJetPhi"] < -0.87), axis=1, ) print(f"Removing {np.sum(hem_cut)} events") @@ -192,11 +192,11 @@ def _hem_cleaning(sample, events): else: hem_cut = np.any( (events["ak8FatJetEta"] > -3.2) - * (events["ak8FatJetEta"] < -1.3) - * (events["ak8FatJetPhi"] > -1.57) - * (events["ak8FatJetPhi"] < -0.87), + & (events["ak8FatJetEta"] < -1.3) + & (events["ak8FatJetPhi"] > -1.57) + & (events["ak8FatJetPhi"] < -0.87), axis=1, - ) * (np.random.rand(len(events)) < 0.632) + ) & (np.random.rand(len(events)) < 0.632) print(f"Removing {np.sum(hem_cut)} events") return events[~hem_cut] @@ -207,6 +207,7 @@ def load_samples( year: str, filters: List = None, columns: List = None, + hem_cleaning: bool = True, ) -> Dict[str, pd.DataFrame]: """ Loads events with an optional filter. @@ -217,6 +218,8 @@ def load_samples( samples (Dict[str, str]): dictionary of samples and selectors to load. year (str): year. filters (List): Optional filters when loading data. + columns (List): Optional columns to load. + hem_cleaning (bool): Whether to apply HEM cleaning to 2018 data. Returns: Dict[str, pd.DataFrame]: ``events_dict`` dictionary of events dataframe for each sample. @@ -272,7 +275,7 @@ def load_samples( else: events["finalWeight"] = events["weight"] - if year == "2018": + if year == "2018" and hem_cleaning: events = _hem_cleaning(sample, events) if not_empty: