Skip to content

[RF][HS3] Export RooParamHistFunc as a product of two step functions - #24002

Closed
cburgard wants to merge 1 commit into
root-project:masterfrom
cburgard:hs3-paramhistfunc
Closed

cburgard wants to merge 1 commit into
root-project:masterfrom
cburgard:hs3-paramhistfunc

Conversation

@cburgard

@cburgard cburgard commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

This Pull request:

Adds HS3 export of RooParamHistFunc (RooFit core), which so far had no HS3 mapping at all.

A RooParamHistFunc with relative parameters (paramRelative = true, the default, e.g. in rf709_BarlowBeeston) takes in bin i the value pi times the content wi of bin i of its histogram. That is what a HistFactory sample does, so it is written like one:

{"name": "func", "type": "product", "factors": ["func_nominal", "func_scale"]}
{"name": "func_nominal", "type": "step", "data": {"axes": [...], "contents": [...]}}
{"name": "func_scale", "type": "step", "variables": ["x"], "parameters": ["func_gamma_bin_0", ...], "axes": [...]}

i.e. a product of the dataset-like step (RooHistFunc) and the parameter-list step (the HistFactory ParamHistFunc). On import, it becomes a RooProduct of these two, with the same value in every bin and the same integral. From the second export on, the JSON is stable.

Not supported, with an explicit error:

  • Absolute parameters (paramRelative = false): the analytical integral of RooParamHistFunc is then not consistent with its value (it is Σ pi · wi · voli instead of Σ pi · voli), see [RF] RooParamHistFunc: analytical integral inconsistent with value for paramRelative = false #24003. A mapping to ParamHistFunc would have a different integral than the original. This can be added once it is clear whether this will be fixed in RooParamHistFunc or the class is going to be deprecated.
  • An observable whose binning differs from the binning of the histogram (the ParamHistFunc takes its bins from the observable).

RooHistConstraint, the constraint term that goes with RooParamHistFunc in Barlow-Beeston setups, is built on the fly when the likelihood is created and is not persisted in workspaces, so it is not mapped.

Related: #24001 (per-bin parameters of ParamHistFunc in HS3 bin order; one-dimensional functions like the one written here are not affected).

Changes or fixes:

File Change
JSONFactories_RooFitCore.cxx New exporter for RooParamHistFunc. It creates the two step functions as temporary objects and queues them for export (registered with autoExportDependants = false, so that the queued objects are exported).
testRooFitHS3.cxx New test RooParamHistFuncAsHistFactoryProduct: the written structure, values per bin and integral after the round trip, a stable JSON from the second export on, and the errors for absolute parameters and for a differing binning.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

Tests run (Linux, Ubuntu 26.04, GCC 15.2, RelWithDebInfo, -Droofit=ON -Dtesting=ON): testRooFitHS3 105 → 106 tests, testJSONInterface 1, testHistFactory 69, all passing. clang-format clean.

AI assistance: Claude Code (claude-opus-5-5) implemented the changes, the test and this description under review of the author. The commit carries Assisted-by: claude-code:claude-opus-5-5.

🤖 Generated with Claude Code

A RooParamHistFunc with relative parameters (the default) takes in bin i the
value p_i times the content of bin i of its histogram. This is what a
HistFactory sample does, so it is now written like one: as a `product` of a
`step` with the histogram (RooHistFunc, `<name>_nominal`) and a `step` with
the parameters (ParamHistFunc, `<name>_scale`). It is read back as a
RooProduct of these two, with the same values and integral.

RooParamHistFunc with absolute parameters (paramRelative = false) is not
supported and raises an error: its analytical integral is not consistent
with its value. The observable must have the binning of the histogram.

Assisted-by: claude-code:claude-opus-5-5
@cburgard cburgard changed the title [RF][HS3] Export RooParamHistFunc as a product of two step functions (depends on #23996) [RF][HS3] Export RooParamHistFunc as a product of two step functions Nov 6, 2026
@guitargeek

Copy link
Copy Markdown
Contributor

Hi @cburgard! If we deprecate RooParamHistFunc and remove in ROOT 6.46 (see #24003 (comment)), would you still want this PR?

@guitargeek

Copy link
Copy Markdown
Contributor

The deprecation PR was already merged:

So RooParamHistFunc is frozen, and we don't have to add HS3 export.

@guitargeek guitargeek closed this Nov 6, 2026
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.

2 participants