-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly recompute PU weights in case of an upper bound #87
base: master
Are you sure you want to change the base?
Conversation
I did exactly that in #197 before I saw this pull request. I am not sure why it is stated in #87 (comment) that "Resetting cropped in every iteration didn't work either." That seemed to work for me. |
Too much time has passed since I submitted the PR, so I cannot remember what I tried at the time. It does look like resetting
So, the final weights are not actually cropped to 3.0 as one would expect. |
Well, the |
fixing typo and adding electron cases
The current code has a severe bug that fills the PU weights with nan-s (not a numbers) if there exists a PU weight that needs to be cropped:
nanoAOD-tools/src/WeightCalculatorFromHistogram.cc
Lines 103 to 104 in 2012f6f
nanoAOD-tools/src/WeightCalculatorFromHistogram.cc
Lines 92 to 94 in 2012f6f
The problem is that when the while loop goes beyond the first iteration, N (= the number of bins in MC histogram) more values will be added to
cropped
variable. ThencheckIntegral
loops over the size ofcropped
variable and the running indexi
is used to retrieve the number of events (refvals_
), but this obviously goes beyond the vector boundaries. The computed integrals and final weights become just pure garbage. Resettingcropped
in every iteration didn't work either.For these reasons I and @veelken decided to redo this logic by scaling the largest weight and adjusting the remaining weights until the largest weight approaches to
hardmax
(defaults to 3.) (or, equivalently, until the new integral is close enough to the original one):hardmax
;maxshift
(defaults to 0.0025).Below is an extreme illustration of how the algorithm works:
In practice large PU weights are assigned to a handful of events and the above reweighting procedure basically won't even affect any other weight if the input Ntuple contains a reasonable number of events (which it should if we want to get an accurate PU profile).