-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix Crystal Ball integral near n = 1 for RooCBShape and RooCrystalBall #19602
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
base: master
Are you sure you want to change the base?
Conversation
319894c
to
42f69ae
Compare
Thanks!
|
The check is done on lines 270 and 274 in
I don't think this one is necessary? On line 113 I only see |
Thanks a lot for clarifying! |
Hi, for the function
In the first attachment you can see that there's no weird behaviour, other than what looks like float-point errors. I assume these small float-point errors is the reason why the RooFit implementation uses the logarithmic approximation in some finite range around MathCore_crystalball_fix.pdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
Leaving @guitargeek comment on whether the Math:: function should also be made modified (switchToLogThreshold --> 1e-5 range) so that useLog is consistent across ROOT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @MartinDuyTat for this great PR!
For consistency, I would indeed suggest to use the same tolerance for the TMath
function before merging this PR:
Test Results 15 files 15 suites 2d 19h 34m 15s ⏱️ For more details on these failures, see this check. Results for commit b464b36. ♻️ This comment has been updated with latest results. |
Hi @guitargeek I've just updated the |
391d132
to
b464b36
Compare
This Pull request:
Fix bug in calculation of Crystal Ball integrals used in RooFit
Changes
Why?
In the integral of the Crystal Ball function, the analytical expression results in 0/0 when
n = 1
. To circumvent this, whenabs(n - 1) < 1e-5
an alternative calculation is used which can be derived by a Taylor expansion.In particular, the expression
is approximated to
This is done by expanding the quantity inside the parentheses to first order in
n - 1
.However, since there is a factor
1.0 - n
in front of the parentheses, this expression effectively becomes a zeroth order expansion inn - 1
. This is problematic because the pre-factorstd::pow(r, n)
is in fact a function ofn
, with a non-zero first order term inn - 1
.Therefore, the quantity inside the parentheses really should be expanded to second order in
n - 1
, otherwise the whole expression will have an incorrect value at first order inn - 1
.Here are plots that show the issue, and also the
C++
scripts that produced the plots. I have scanned the relevant functions acrossn = 1
and one can clearly see that the current implementation is wrong, and this PR ensures that the gradient is correct nearn = 1
.RooCrystalBall_fix.pdf
RooCBShape_fix.pdf
RooCBShape_fix.txt
RooCrystalBall_fix.txt
Checklist: