Skip to content

[6.40] [RF] Fix RooExtendPdf yield/shape in ranged extended fits - #23000

Merged
guitargeek merged 2 commits into
root-project:v6-40-00-patchesfrom
root-project-bot:BP_6.40_pull_22989
Aug 4, 2026
Merged

guitargeek merged 2 commits into
root-project:v6-40-00-patchesfrom
root-project-bot:BP_6.40_pull_22989

Conversation

@root-project-bot

Copy link
Copy Markdown

Backport of #22989, requested by @guitargeek.

RooExtendPdf is self-normalized, so it delegates both the shape
normalization and the extended-term fraction to the wrapped pdf. In a
fit over a sub-range, the fit machinery sets the normalization range
only on the outer RooExtendPdf; it was never propagated to the wrapped
pdf. As a result the wrapped pdf stayed normalized over the full range,
which collapsed the fitted yield N to the number of events in the fit
range (instead of reinterpreting it to the range requested in the
constructor) and biased the shape parameters.

This regressed with the multi-range fit rework in fa10523 (v6.28),
and is visible in the rf204b_extendedLikelihood_rangedFit tutorial,
where the RooExtendPdf fit disagreed with the equivalent RooAddPdf fit.

Propagate the normalization range to the wrapped pdf during graph
compilation, mirroring what RooAddPdf does for its components. This is
gated on likelihood mode: for a binned chi2 the per-bin predictions must
stay normalized over the full range so that the chi2 remains additive
across sub-ranges.

Closes root-project#22959.

🤖 Done with the help of AI.

(cherry picked from commit 4d36d9e)
The inline documentation of rf204b_extendedLikelihood_rangedFit had a
frac = integral(Fit range) / integral(Full range) definition that is
the reciprocal of what RooExtendPdf::expectedEvents() actually
computes, and text saying the expected event count is divided by it.
This went unnoticed because the ranged extended fit this tutorial
demonstrates was broken since fa10523 and only fixed by the
preceding commit, so the described numbers were never actually
verified against real output.

Also update the quoted RooAddPdf INFO log line, which was still from
the pre-BatchMode RooAbsOptTestStatistic code path and no longer
matches what fitTo() prints.

Applies to both the C++ and Python versions of the tutorial.

(cherry picked from commit ffeb75c)
@guitargeek
guitargeek merged commit fb15b95 into root-project:v6-40-00-patches Aug 4, 2026
30 of 34 checks passed
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