Skip to content

[RF] Fix RooHistPdf sub-range integrals with interpolation#20119

Merged
guitargeek merged 1 commit into
root-project:masterfrom
ferdymercury:patch-24
Jun 25, 2026
Merged

[RF] Fix RooHistPdf sub-range integrals with interpolation#20119
guitargeek merged 1 commit into
root-project:masterfrom
ferdymercury:patch-24

Conversation

@ferdymercury

@ferdymercury ferdymercury commented Oct 15, 2025

Copy link
Copy Markdown
Collaborator

The analytical integral of a RooHistPdf sums the underlying RooDataHist
bin contents, which only matches the interpolated curve over the full
range. For interpolated histograms (intOrder > 0), RooHistPdf took this
shortcut also over sub-ranges, returning the step-function (intOrder == 0)
area regardless of the interpolation order. Fall back to numerical
integration in that case; full-range integrals and non-interpolated
histograms are unaffected and still use the analytical path.

Closes #20116.

@github-actions

github-actions Bot commented Oct 15, 2025

Copy link
Copy Markdown

Test Results

    23 files      23 suites   2d 17h 48m 5s ⏱️
 3 874 tests  3 873 ✅ 0 💤 1 ❌
80 055 runs  80 054 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 511d34a.

♻️ This comment has been updated with latest results.

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for implementing the right fix! I added a test, and now it's good to go.

@guitargeek guitargeek added the bug label Jun 24, 2026
@guitargeek guitargeek changed the title [RF] disable analytical integrals also with linear interpolation [RF] Fix RooHistPdf sub-range integrals with interpolation Jun 24, 2026
The analytical integral of a RooHistPdf sums the bin contents of the
underlying RooDataHist, which integrates the piecewise-constant
histogram. For interpolated histograms (intOrder > 0) this only matches
the actual curve over the full range; over a sub-range it does not, so
the integral was wrong (it returned the intOrder == 0 step-function area
regardless of the interpolation order).

Fall back to numerical integration for sub-range integrals of interpolated
histograms, but only when integrating over the histogram's own fundamental
observable. A derived (non-fundamental) observable has already passed the
constant-Jacobian check in okayForAnalytical and is a genuine transform of
the histogram variable, e.g. the RooLinearVar that RooMomentMorphFuncND
uses to renormalize its components; those keep the analytical path they
rely on. Full-range integrals and non-interpolated histograms are
unaffected.

Closes root-project#20116.

🤖 Done with the help of AI.
@guitargeek guitargeek merged commit 51b58e3 into root-project:master Jun 25, 2026
31 of 34 checks passed
@guitargeek

Copy link
Copy Markdown
Contributor

/backport to 6.40

@root-project-bot

Copy link
Copy Markdown

Preparing to backport PR #20119 to branch 6.40 requested by guitargeek

@root-project-bot

Copy link
Copy Markdown

This PR has been backported to branch 6.40: #22703

@ferdymercury ferdymercury deleted the patch-24 branch June 25, 2026 14:49
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.

Wrong integrals for RooHistPdf with interpolation order = 1

3 participants