Refactor IntegratedLuminosity_cff.py#115
Open
lnestor wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Justification
Every time I opened
IntegratedLuminosity_cff.pyI 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 withget_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_cffsuffix annoys me because this file isn't used in any CMSSW configuration files, and that is what_cffis 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
lumidictionary toget_lumiwill break old scripts. I have added a custom object, that when a script callslumi["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
lumidictionary to the newget_lumifunction, and they all match.