diff --git a/higgs_dna/systematics/event_weight_systematics.py b/higgs_dna/systematics/event_weight_systematics.py index 3851174cb843feb8ee1229a416ddae062ba1763d..91216aa39c1fe3ee22a83a253dc17f72898531da 100644 --- a/higgs_dna/systematics/event_weight_systematics.py +++ b/higgs_dna/systematics/event_weight_systematics.py @@ -488,14 +488,10 @@ def TriggerSF(photons, weights, year="2017", is_correction=True, **kwargs): elif "2016" in year: year = "2016" - if "2022" in year: - print("\n WARNING: We still have to validate the trigger efficiencies for 2022. \nFalling back to 2017 for the moment...") - year = "2017" - - jsonpog_file_lead = os.path.join(os.path.dirname(__file__), f"JSONs/TriggerSF/{year}/TriggerSF_lead_{year}.json") - jsonpog_file_sublead = os.path.join(os.path.dirname(__file__), f"JSONs/TriggerSF/{year}/TriggerSF_sublead_{year}.json") - evaluator_lead = correctionlib.CorrectionSet.from_file(jsonpog_file_lead)["TriggerSF"] - evaluator_sublead = correctionlib.CorrectionSet.from_file(jsonpog_file_sublead)["TriggerSF"] + json_file_lead = os.path.join(os.path.dirname(__file__), f"JSONs/TriggerSF/{year}/TriggerSF_lead_{year}.json") + json_file_sublead = os.path.join(os.path.dirname(__file__), f"JSONs/TriggerSF/{year}/TriggerSF_sublead_{year}.json") + evaluator_lead = correctionlib.CorrectionSet.from_file(json_file_lead)["TriggerSF"] + evaluator_sublead = correctionlib.CorrectionSet.from_file(json_file_sublead)["TriggerSF"] if year in ["2016", "2017", "2018"]: if is_correction: @@ -539,21 +535,21 @@ def TriggerSF(photons, weights, year="2017", is_correction=True, **kwargs): elif "2022" in year: + sf_lead_p_lead = evaluator_lead.evaluate( + "nominal", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_lead"].pt + ) + sf_lead_p_sublead = evaluator_lead.evaluate( + "nominal", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_sublead"].pt + ) + sf_sublead_p_lead = evaluator_sublead.evaluate( + "nominal", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_lead"].pt + ) + sf_sublead_p_sublead = evaluator_sublead.evaluate( + "nominal", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_sublead"].pt + ) + if is_correction: # only calculate correction to nominal weight - # ToDo: include pT!!! - sf_lead_p_lead = evaluator_lead.evaluate( - "nominal", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_lead"].pt - ) - sf_lead_p_sublead = evaluator_lead.evaluate( - "nominal", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_sublead"].pt - ) - sf_sublead_p_lead = evaluator_sublead.evaluate( - "nominal", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_lead"].pt - ) - sf_sublead_p_sublead = evaluator_sublead.evaluate( - "nominal", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_sublead"].pt - ) sf = sf_lead_p_lead * sf_sublead_p_sublead + sf_lead_p_sublead * sf_sublead_p_lead - sf_lead_p_lead * sf_lead_p_sublead sfup, sfdown = None, None @@ -561,20 +557,7 @@ def TriggerSF(photons, weights, year="2017", is_correction=True, **kwargs): else: # only calculate systs sf = np.ones(len(weights._weight)) - # get nominal SF to divide it out - sf_lead_p_lead = evaluator_lead.evaluate( - "nominal", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_lead"].pt - ) - sf_lead_p_sublead = evaluator_lead.evaluate( - "nominal", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_sublead"].pt - ) - sf_sublead_p_lead = evaluator_sublead.evaluate( - "nominal", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_lead"].pt - ) - sf_sublead_p_sublead = evaluator_sublead.evaluate( - "nominal", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_sublead"].pt - ) _sf = sf_lead_p_lead * sf_sublead_p_sublead + sf_lead_p_sublead * sf_sublead_p_lead - sf_lead_p_lead * sf_lead_p_sublead # up SF @@ -582,10 +565,10 @@ def TriggerSF(photons, weights, year="2017", is_correction=True, **kwargs): "up", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_lead"].pt ) sfup_lead_p_sublead = evaluator_lead.evaluate( - "up", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_sublead"].pt + "up", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_sublead"].pt ) sfup_sublead_p_lead = evaluator_sublead.evaluate( - "up", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_lead"].pt + "up", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_lead"].pt ) sfup_sublead_p_sublead = evaluator_sublead.evaluate( "up", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_sublead"].pt @@ -597,10 +580,10 @@ def TriggerSF(photons, weights, year="2017", is_correction=True, **kwargs): "down", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_lead"].pt ) sfdown_lead_p_sublead = evaluator_lead.evaluate( - "down", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_sublead"].pt + "down", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_sublead"].pt ) sfdown_sublead_p_lead = evaluator_sublead.evaluate( - "down", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_lead"].pt + "down", abs(photons["pho_lead"].ScEta), photons["pho_lead"].r9, photons["pho_lead"].pt ) sfdown_sublead_p_sublead = evaluator_sublead.evaluate( "down", abs(photons["pho_sublead"].ScEta), photons["pho_sublead"].r9, photons["pho_sublead"].pt diff --git a/scripts/pull_files.py b/scripts/pull_files.py index ec79af0fa3c748fab79fdf0b5a03bd966055ba34..f74791b38f748d43debe77a0fbe4b185d115b45d 100644 --- a/scripts/pull_files.py +++ b/scripts/pull_files.py @@ -318,7 +318,23 @@ def get_trigger_json(logger, target_dir): "2018_sublead": { "from": "/eos/cms/store/group/phys_higgs/cmshgg/tbevilac/JSONs/2018/TriggerSF_sublead_2018.json", "to": f"{to_prefix}/2018/TriggerSF_sublead_2018.json", - } + }, + "2022preEE_lead": { + "from": "/eos/cms/store/group/phys_higgs/cmshgg/fmausolf/HiggsDNA_JSONs/TriggerSF_lead_2022_preEE.json", + "to": f"{to_prefix}/2022preEE/TriggerSF_lead_2022preEE.json", + }, + "2022preEE_sublead": { + "from": "/eos/cms/store/group/phys_higgs/cmshgg/fmausolf/HiggsDNA_JSONs/TriggerSF_sublead_2022_preEE.json", + "to": f"{to_prefix}/2022preEE/TriggerSF_sublead_2022preEE.json", + }, + "2022postEE_lead": { + "from": "/eos/cms/store/group/phys_higgs/cmshgg/fmausolf/HiggsDNA_JSONs/TriggerSF_lead_2022_postEE.json", + "to": f"{to_prefix}/2022postEE/TriggerSF_lead_2022postEE.json", + }, + "2022postEE_sublead": { + "from": "/eos/cms/store/group/phys_higgs/cmshgg/fmausolf/HiggsDNA_JSONs/TriggerSF_sublead_2022_postEE.json", + "to": f"{to_prefix}/2022postEE/TriggerSF_sublead_2022postEE.json", + }, } fetch_file("TriggerSF", logger, from_to_dict, type="copy")