cms-nanoAOD / correctionlib

A generic correction library
https://cms-nanoaod.github.io/correctionlib/
BSD 3-Clause "New" or "Revised" License
16 stars 22 forks source link

RuntimeError: Duplicate Correction name #252

Closed bockjoo closed 3 months ago

bockjoo commented 3 months ago

Hi, I am getting a correctionlib RuntimeError:

>>> import correctionlib
>>> correctionlib.__version__
'2.6.1'
>>> ceval = correctionlib.CorrectionSet.from_file('vll/scalefactors/EleMu/Muons/UL/2018/2018_trigger/Efficiencies_muon_generalTracks_Z_Run2018_UL_SingleMuonTriggers_schemaV2.json')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bockjoo/opt/cmsio2/cms/services/T2/ops/Work/AAA/vll-analysis.Coffea2024.6.1/lib/python3.12/site-packages/correctionlib/highlevel.py", line 373, in from_file
    return cls(open_auto(filename))
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bockjoo/opt/cmsio2/cms/services/T2/ops/Work/AAA/vll-analysis.Coffea2024.6.1/lib/python3.12/site-packages/correctionlib/highlevel.py", line 369, in __init__
    self._base = correctionlib._core.CorrectionSet.from_string(self._data)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Duplicate Correction name: NUM_IsoMu24_DEN_CutBasedIdMedium_and_PFIsoMedium

Here, the file used can be found from

https://gitlab.cern.ch/cms-muonPOG/muonefficiencies/-/blob/master/Run2/UL/2018/2018_trigger/Efficiencies_muon_generalTracks_Z_Run2018_UL_SingleMuonTriggers_schemaV2.json

The purpose of reading the json file was to read the trigger efficiency once the json file is read using this syntax (inputs, abseta and pt):

    sf_mu = ceval[key].evaluate(abs(mu_m.eta), mu_m.pt, "nominal")

So, I guess for now the name should be changed based on the input combinations with correctionlib 2.6.1. But there was no RuntimeError with the correctionlib 2.3.3. Thanks, Bockjoo

nsmith- commented 3 months ago

This feature was added in #244 and the corresponding json should have failed validation. The Muon POG was notified in https://gitlab.cern.ch/cms-nanoAOD/jsonpog-integration/-/issues/32