Skip to content

Refactor lepton background estimation#121

Draft
lnestor wants to merge 19 commits intomasterfrom
lepton-bkgd-rework
Draft

Refactor lepton background estimation#121
lnestor wants to merge 19 commits intomasterfrom
lepton-bkgd-rework

Conversation

@lnestor
Copy link
Copy Markdown
Contributor

@lnestor lnestor commented Feb 9, 2026

Currently a draft...

The existing patterns in this codebase are very hard to follow and should be replaced. Such patterns include:

  • Essentially the same scripts with different years (bkgdEstimate_2022.py, bkgdEstimate_2023.py, etc.). These happen not just for background estimations. The main difference here are the hardcoded paths to files. I propose that there is a single script that takes in a file as an argument.
  • Using a copy-and-pasted class with an add_channel function. This add_channel function just obscures what is going on I think, we should just extract the histogram we want directly. Instead you have to traverse through many layers of functions just to figure out which histogram is actually being used.

This PR is a rework of the lepton background estimations. There are many changes which I think make this process more understandable, perhaps at the cost of being a little verbose/explicit. A list of the main changes are:

  • Removes lepton background parts from bkgdEstimate_20XX.py
  • Removes LeptonBackgroundEstimate class
  • All functionality is placed in BackgroundEstimation/scripts/lepton_background_estimate.py, where each part of the estimation is defined in a self contained function (i.e. no needing to hop between multiple layers of indirection to figure out how to find P(veto), it is all in one place).
  • Data is passed in via command line arguments instead of hardcoded into the script. This way you don't need to edit the script for future years, you just pass in a different file. The file is assumed to have all the histograms necessary and will exit if not.
  • The script can output the latex table directly to be placed in the analysis note with --output-fmt latex
  • Adds a get_hist function to StandardAnalysis/python/plotUtilities that is intended to replace the existing getHist function. The new function does not hardcode condor/ to the beginning of the file path. The existing getHist function (which does prepend condor/ now prints a deprecation warning and uses get_hist behind the scenes.
    • I intend to replace all functions that prepend condor/ eventually in this manner

TODO:

  • Taus
  • Docstring for LeptonBackgroundFormatter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant