Skip to content

Refactor IntegratedLuminosity_cff.py#115

Open
lnestor wants to merge 2 commits into
masterfrom
lumi-changes
Open

Refactor IntegratedLuminosity_cff.py#115
lnestor wants to merge 2 commits into
masterfrom
lumi-changes

Conversation

@lnestor

@lnestor lnestor commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Justification

Every time I opened IntegratedLuminosity_cff.py I got annoyed. It is very cluttered, has several helper functions that aren't written well, and isn't clear how to add a new year or new dataset. It also computes the luminosity for every possible combination of eras, and we just don't need that. The was we currently use it mostly is for a single era.

Proposal

I propose a new interface: get_lumi(dataset, year, era). I would also be fine with get_lumi("MET_2017C") for example, just accepting a single string, but I think splitting it makes sense. This new function would calculate just the luminosity requested. That makes this file much simpler to understand. I think it is easy to understand how to add new years and datasets.

I also propose changing the filename to integrated_luminosity.py. I don't care too much about the filename, however the _cff suffix annoys me because this file isn't used in any CMSSW configuration files, and that is what _cff is for. It should have no suffix to be in line with the rest of our codebase. Also, python files should be snake_case.

Backwards Compatibility

Obviously switching the interface from a lumi dictionary to get_lumi will break old scripts. I have added a custom object, that when a script calls lumi["something"] it will raise a deprecation error with a useful error message. This means we don't need to change every part of the code base, we just to incrementally change what we are currently working on. And to be honest, like 50% or more of the scripts in this repository wouldn't even run anyways, because either they are in Python2, the data files no longer exist, etc.

Verification

I have compared every key in the original lumi dictionary to the new get_lumi function, and they all match.

@lnestor lnestor added the cleaup label Feb 1, 2026
The old file (IntegratedLuminosity_cff.py) was a confusing mess.
This change makes the interface simpler with a function and
doesn't deal with making all possible combinations of lumi values
in a dictionary, of which only 1 will be used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant