Repository navigation
[RF] Generalize boundary finding for RooHistPdf and RooHistFunc - #21969
Merged
Merged
Conversation
Test Results 22 files 22 suites 3d 11h 28m 35s ⏱️ Results for commit 89283a2. ♻️ This comment has been updated with latest results. |
guitargeek
marked this pull request as draft
April 24, 2026 07:47
Member
|
Is this PR making it into 6.40 or should this be shifted to 6.40.02? |
Contributor
Author
|
Let's aim for 6.40.02, it's not realistic to have this in 6.40 at this point. |
guitargeek
force-pushed
the
issue-13030
branch
3 times, most recently
from
August 4, 2026 17:05
ccb30df to
75cff41
Compare
Member
|
Now in the 6.40.06 milestone. It would be nice to have it in by then! |
The interface to return bin boundaries and sampling hints for plotting in RooHistPdf and RooHistFunc doesn't consider that the histogram variable might be a transformation of the variable for which the bin boundaries or plot hints are requested. This commit improves the situation by implementing an algorithm that assumes that plot variable and histogram variable are linearly related, and numerically figures out the inverse transformation for transforming histogram bins to plot bins if needed. Non-linear transformations are not inverted exactly, but linear transformations are very common, even explicitly via the `RooLinearVar`, and supporting those is already a good improvement in user experience. For a non-linear transformation, a warning is now emitted so the user knows that the bin boundaries are only approximate. The inverse is deliberately computed arithmetically rather than via the l-value `setVal()` interface, because inverting a boundary can land outside the range of the plot observable, which would throw. Closes root-project#13030.
Cover RooHistFunc, a transformation with negative slope and plotSamplingHint() for transformed histogram observables. On master, RooHistFunc throws for a RooLinearVar observable and plotSamplingHint() returns no hint for a shifted RooHistPdf. Assisted-by: claude-code:claude-opus-5-5
To map the bin boundaries, histogramBoundariesInPlotObs() sets the plot observable to probe the transformation and restored it with setVal(). That throws if an outer integral over a wider range had set the observable outside its default range. Restore it with assign() instead. Also fix the binBoundaries() documentation, which named RooCurve as a user (RooCurve uses plotSamplingHint()), and shorten the comments. Assisted-by: claude-code:claude-opus-5-5
The RooBinIntegrator took the bin boundaries from the integrand only when it was created, but RooRealIntegral keeps reusing it when the parameters change. For a RooHistPdf or RooHistFunc of a shifted observable, the boundaries move with the shift, so the integral was only right at the shift of its first evaluation. Afterwards, it could count an edge bin twice. Get the boundaries for each integral instead. This costs one binBoundaries() call per integral, which in the RooFit tests and tutorials is less than 0.3 % of the run time. Assisted-by: claude-code:claude-opus-5-5
guitargeek
force-pushed
the
issue-13030
branch
from
November 20, 2026 14:07
75cff41 to
89283a2
Compare
guitargeek
marked this pull request as ready for review
November 20, 2026 14:08
Contributor
Author
Sorry for the late reply! I have revived the PR now and the issue is fixed. |
dpiparo
approved these changes
Nov 20, 2026
Member
|
ready for backporting and merging then... |
Contributor
Author
|
/backport to 6.42 |
|
Preparing to backport PR #21969 to branch 6.42 requested by guitargeek |
|
This PR has been backported to branch 6.42: #24277 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The interface to return bin boundaries and sampling hints for plotting in RooHistPdf and RooHistFunc doesn't consider that the histogram variable might be a transformation of the variable for which the bin boundaries or plot hints are requested.
This commit improves the situation by implementing an algorithm that assumes that plot variable and histogram variable are linearly related, and numerically figures out the inverse transformation for transforming histogram bins to plot bins if needed.
If the transformation is not linear, the RooHistFunc or RooHistPdf won't be correctly plotted either, but linear transformations are very common, even explicitly via the
RooLinearVar, and supporting those is already a good improvement in user experience.Closes #13030.
The plot from the reproducer in the original issue does now look like this:
