Skip to content

Commit

Permalink
allow JetResolution to handle additional filename metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
lgray committed Jan 8, 2025
1 parent 1f69f3a commit e8203cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions coffea/jetmet_tools/JetResolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ def __init__(self, **kwargs):
)
)
info = name.split("_")
if len(info) != 5:
if len(info) > 6 or len(info) < 5:
raise Exception("Corrector name is not properly formatted!")
offset = len(info) - 5

campaign = _checkConsistency(campaign, info[0])
dataera = _checkConsistency(dataera, info[1])
datatype = _checkConsistency(datatype, info[2])
levels.append(info[3])
datatype = _checkConsistency(datatype, info[2 + offset])
levels.append(info[3 + offset])
funcs.append(func)
jettype = _checkConsistency(jettype, info[4])
jettype = _checkConsistency(jettype, info[4 + offset])

if campaign is None:
raise Exception("Unable to determine production campaign of JECs!")
Expand Down
1 change: 1 addition & 0 deletions coffea/lookup_tools/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"jec": convert_jec_txt_file,
"jersf": convert_jersf_txt_file,
"jr": convert_jr_txt_file,
"jer": convert_jr_txt_file,
"junc": convert_junc_txt_file,
"ea": convert_effective_area_file,
"pileup": convert_pileup_json_file,
Expand Down
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/test_jetmet_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def jetmet_evaluator():
"* * tests/samples/RegroupedV2_Fall17_17Nov2017_V32_MC_UncertaintySources_AK4PFchs.junc.txt.gz",
"* * tests/samples/Regrouped_Fall17_17Nov2017_V32_MC_UncertaintySources_AK4PFchs.junc.txt",
"* * tests/samples/Spring16_25nsV10_MC_PtResolution_AK4PFPuppi.jr.txt.gz",
"* * tests/samples/Summer23Prompt23_RunCv1234_JRV1_MC_PtResolution_AK4PFPuppi.jr.txt.gz",
"* * tests/samples/Spring16_25nsV10_MC_SF_AK4PFPuppi.jersf.txt.gz",
"* * tests/samples/Autumn18_V7_MC_SF_AK4PFchs.jersf.txt.gz",
]
Expand Down Expand Up @@ -206,6 +207,9 @@ def test_jet_resolution():
jer_names = ["Spring16_25nsV10_MC_PtResolution_AK4PFPuppi"]
reso = JetResolution(**{name: evaluator[name] for name in jer_names})

check2023_names = ["Summer23Prompt23_RunCv1234_JRV1_MC_PtResolution_AK4PFPuppi"]
_ = JetResolution(**{name: evaluator[name] for name in check2023_names})

print(reso)

resos = reso.getResolution(JetEta=test_eta, Rho=test_Rho, JetPt=test_pt)
Expand Down

0 comments on commit e8203cb

Please sign in to comment.