Skip to content
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

[RF] Fix ranged integrals with factorized variables #12011

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Jan 11, 2023

The RooRealIntegral class is smart enough to figure out which
variables the function the integrated function doesn't depend on and
trivially integrates them itself by multiplying with the variable
definition range.

However, if the integration range is a subrange of the variable range,
this was not considered. This resulted in wrong results. for integrals
like pdf.createIntegral(x, "subrange"), where the pdf doesn't depend
on x. These kind of integrals can occur in the projections that the
RooAddPdf does, so it's important that they work, and fixing this
partially addresses #11486.

This change also fixes a so-far unknown bug in the RooXYChi2Var, which
also used these kind of integrals. Without this fix, the Integrate()
feature for chi2FitTo() was completely broken, which can be seen in
the output of the rf609 tutorial with any previous ROOT version. The
tutorial looks okay by chance, because the function is dominted by the
quadratic term in x that is constant in the fit. But if one makes this
a floating parameter, the problem gets obvious.

Probably that was the reason why the main model parameter was set
constant to begin with, to sweep the bug under the rug. Now, the
tutorials are updated to have the quadratic coefficient floating too.
And also stressRooFit, since the reference file has to be updated
anyway.

To demonstrate that things work correctly now, a new unit test was
implemented that does the closure check of the integrate() feature of
the RooXYChi2Var with a linear fit function.

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

The `RooRealIntegral` class is smart enough to figure out which
variables the function the integrated function doesn't depend on and
trivially integrates them itself by multiplying with the variable
definition range.

However, if the integration range is a subrange of the variable range,
this was not considered. This resulted in wrong results. for integrals
like `pdf.createIntegral(x, "subrange")`, where the pdf doesn't depend
on x. These kind of integrals can occur in the projections that the
RooAddPdf does, so it's important that they work, and fixing this
partially addresses root-project#11486.

This change also fixes a so-far unknown bug in the `RooXYChi2Var`, which
also used these kind of integrals. Without this fix, the `Integrate()`
feature for `chi2FitTo()` was completely broken, which can be seen in
the output of the `rf609` tutorial with any previous ROOT version. The
tutorial looks okay by chance, because the function is dominted by the
quadratic term in `x` that is constant in the fit. But if one makes this
a floating parameter, the problem gets obvious.

Probably that was the reason why the main model parameter was set
constant to begin with, to sweep the bug under the rug. Now, the
tutorials are updated to have the quadratic coefficient floating too.
And also `stressRooFit`, since the reference file has to be updated
anyway.

To demonstrate that things work correctly now, a new unit test was
implemented that does the closure check of the `integrate()` feature of
the `RooXYChi2Var` with a linear fit function.
@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thanks Jonas for the fix!

@guitargeek guitargeek merged commit ae7ef4f into root-project:master Jan 12, 2023
@guitargeek guitargeek deleted the integral_fix_1 branch January 12, 2023 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants