Skip to content

[6.42] [RF] Generalize boundary finding for RooHistPdf and RooHistFunc - #24277

Merged
dpiparo merged 4 commits into
root-project:v6-42-00-patchesfrom
root-project-bot:BP_6.42_pull_21969
Nov 20, 2026
Merged

dpiparo merged 4 commits into
root-project:v6-42-00-patchesfrom
root-project-bot:BP_6.42_pull_21969

Conversation

@root-project-bot

Copy link
Copy Markdown

Backport of #21969, requested by @guitargeek.

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.

(cherry picked from commit eeffe46)
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
(cherry picked from commit ca6ed9b)
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
(cherry picked from commit 6c08bc5)
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
(cherry picked from commit c107cea)
@github-actions

Copy link
Copy Markdown

Test Results

    24 files      24 suites   4d 1h 47m 33s ⏱️
 3 941 tests  3 941 ✅ 0 💤 0 ❌
85 018 runs  85 018 ✅ 0 💤 0 ❌

Results for commit 55e79c6.

@dpiparo
dpiparo merged commit de73d23 into root-project:v6-42-00-patches Nov 20, 2026
39 of 40 checks passed
@dpiparo
dpiparo deleted the BP_6.42_pull_21969 branch November 20, 2026 20:48
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