← Back to Pull requests

[RF][HS3] Follow the HS3 0.3 specification fixes (HS3 #154) #24201

Closed
unknown closed this pull request without merging on Nov 19, 2026 16:54 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 13:10 UTC
Author

This Pull request:

Brings RooFit's HS3 import and export in line with HS3 PR
#154
("Fixes before v0.3"). That PR implements the decisions on HS3
#156
and the fixes of
#157.
Each commit is one change, with a test.

Commits 12–15 are a separate topic on top: the layouts in which the auxiliary measurements
(constraint terms) of HistFactory models are written. They don't depend on HS3 #154. Commits 17–19 keep documents
before 0.3 that are published on HEPData importable and writable.

Where HS3 0.3 now forbids or changes something that older documents rely on, the new behaviour applies to
documents with hs3_version 0.3 or later, and older documents are read as before, usually with a warning. The code
for the old behaviour (implicit HistFactory constraint terms, staterror gammas configured from the sample errors) is
kept, not removed: older documents need it, and it may be reactivated for constraint types that infer their strength
from the channel.

[!NOTE]

HS3 #154 was merged on 2026-11-18 (merge commit

5570053).

All commits follow #154, including "data": null for pure models (HS3 commit

c67e621,

with the reading of the old placeholder restricted to "data": [0] in

0109565).

Changes or fixes:

| # | Commit | Change | Test |
|---|---|---|---|
| 1 | Leave infinite bounds of data axes out instead of writing null | Continuous data axes omit an infinite bound (HS3 0.3 leaves null undefined); RooFit wrote null, or the largest double for constraint data. Import: an axis with one bound sets that bound only. The validator rejects infinite bounds on binned axes. | UnboundedDataAxes |
| 2 | Write the location of landau_dist as "mu" | HS3 renames mean → mu. Export writes mu; mean is still read (with a warning in ≥ 0.3 documents). | LandauLocationKey |
| 3 | Follow the HS3 0.3 rules for "extended" on mixture_dist | Missing flag with one coefficient per summand: rejected in ≥ 0.3. Explicit false with one coefficient per summand: honoured (built from the normalized coefficients c_i/Σc, not extendable) instead of a warning. Missing flag with n−1 coefficients: still accepted. No coefficients: read and written with a warning (undefined in 0.3). | MixtureDistExtendedFlag (extended) |
| 4 | Translate TRUE, FALSE, === and !== in imported expressions | Mapped to 1, 0, ==, != for TFormula. | ExpressionBuiltins |
| 5 | Reserved names, and no distributions in generic expressions | Objects named PI, EULER, TRUE, FALSE, ifelse or a function of the language: validator error for ≥ 0.3, warning otherwise and on export. A generic expression referring to a distribution: rejected on import (≥ 0.3). The export fails for anything that would be written as such an expression (RooFormulaVar/RooGenericPdf depending on a pdf, RooTFnBinding with a pdf, the transformation helpers of RooLognormal/RooExponential). Whether to allow generic_dist expressions on distributions later is discussed in HS3 #159. | ReservedNamesAndDistributionReferences |
| 6 | Read and write point data as a RooDataSet with one entry | point data (rejected so far) becomes a one-entry 1D RooDataSet; such a data set (one real variable, one unweighted entry) is written as point data with its axis, also for the constraint data of config().exportConstraintData. The provisional uncertainty is ignored with a warning. | PointData |
| 7 | Data without axes: the single variate of the paired distribution | An in-line number in data, or point data without axes, is the value of the single variate of the paired distribution; rejected if that can't be determined. In-line numbers become a point data set <distribution>_data. "data": [0], RooFit's old "no data" placeholder, keeps that meaning in documents before 0.3 in exactly this form (and, until the last commit, in documents RooFit wrote); a 0 in a longer array is a value. | DataWithoutAxes |
| 8 | Check data axes against domains and paired distributions | No fixed (value) axes in data sets; the axis of point data must be the variate of the paired distribution; a paired data axis and an analysis-domain axis for the same variate must give the same range (validator: error for ≥ 0.3, warning otherwise). | DataAxesAgainstDomains |
| 9 | Require the constraints of HistFactory modifiers in the likelihood | constraints of a modifier add no term in 0.3: each named distribution must contribute exactly once to every likelihood with the channel; ≥ 0.3 documents that don't are rejected. RooFit's export already lists them. Older documents: constraints are still added implicitly. | HistFactoryConstraintsListedOnce |
| 10 | Don't derive the staterror gammas from the errors in HS3 0.3 | For ≥ 0.3, the gammas with named constraints keep range and constness from the document and only get the uncertainty that their constraint encodes as initial error; they are configured from the sample errors only in older documents. Gammas without a constraint are left free in any version (master 25dc4e91aa6). RooFit's export writes fixed gammas as constant with a null constraint. | StatErrorFromDocument |
| 11 | Write a model without data with "data": null | A ModelConfig without matching data is written as a pure model, a likelihood with "data": null, instead of "data": [0], and read back as a ModelConfig without data. "data": [0] is still read as "no data" in documents before 0.3; any other 0 is a value. A pure model writes its constraint terms to aux_distributions also with config().exportConstraintData. | PureModelLikelihood |
| 12 | Lognormals in the parametrization of RooFit as array components | A RooLognormal in RooFit's default parametrization (median, shape) is written with mu/sigma naming the functions log(median)/log(shape). It could not be a component of an array_dist, so config().exportArrayDist and config().exportConstraintData had no effect on such constraints. It now can; the suffix convention is in two functions that the standalone and the array code share. | ArrayDistOfLognormalsInRooFitParametrization |
| 13 | Valid names for functions of literal constants | The helper function of a literal constant was named 1.2_lognormal_log or -0.1_exponential_inverted, which are not identifiers. The value is now spelled as one (const_1p2_lognormal_log, const_m0p1_exponential_inverted), with all digits needed to read it back unchanged (before: six). Names of the form const_<number> are reserved for this. The old names are still read. | FunctionsOfLiteralConstantsHaveValidNames |
| 14 | Don't write helper objects that nothing refers to | The RooProdPdf that holds the components of an imported array_dist together was written as a product_dist when arrays were switched off; read back, it kept the constraints from ever being collected into arrays again. Objects that RooFit creates to represent something it has no class for now carry the attribute hs3_helper: they are only written if something refers to them (or the HS3 object they stand for is written), and are otherwise ignored by the export. Not specific to arrays. | HelperObjects |
| 15 | Test the auxiliary measurements of HistFactory models | New test program testHS3AuxiliaryMeasurements: a three-channel HistFactory workspace with partially overlapping constraints (Gaussian, Poisson, and log-normal in two variants) is written in all four combinations of exportArrayDist × exportConstraintData and read back. Checks the layout, one array per constraint type, the workspace, a likelihood scan (fixed and profiled), toys, and every pair of layouts in sequence. | testHS3AuxiliaryMeasurements (51 tests) |
| 16 | Remove the unused writeBound() from the document writer | Commit 1 removed the last callers of writeBound() in HS3Writer.cxx but left the definition, which fails builds with -Werror (dev=ON) on -Wunused-function. Fix on top instead of in commit 1, to avoid rewriting the history; commits 1–15 therefore don't build on their own with dev=ON. | builds with the CI flags of dev=ON |
| 17 | Accept data axes with a fixed "value" in documents before 0.3 | Commit 8 rejected a data axis with value in documents of any version, but ROOT 6.34 wrote the observable of a data set like this (e.g. the top-quark mass likelihood on HEPData, INSPIRE 2894561). The parser now records it and the validator reports it: error for ≥ 0.3, warning otherwise. The value is not used, as before commit 8. | DataAxesAgainstDomains (extended) |
| 18 | Accept histosys modifiers of the same name in documents before 0.3 | The validator (already in master) rejects two histosys modifiers of the same name in a sample. ROOT wrote these for a parameter that interpolates a sample more than once (e.g. two VH likelihoods on HEPData, INSPIRE 2905253, ROOT 6.37). Now a warning before 0.3. They are read as one parameter with stacked effects: the parameter enters the interpolation once per modifier (only the histogram objects of the repeated modifier get a counter in their names). The export combines them into one modifier as before. Still an error for ≥ 0.3. | HistFactoryHistoSysOfTheSameNameInOlderDocuments |
| 19 | Don't split a formula into modifiers if that makes the channel invalid | The HistFactory export writes a RooFormulaVar factor of a sample that is a product as one modifier per factor. A parameter that occurs twice (b*b), or that the sample already has as a normfactor, became two normfactors of the same name, and the export failed (e.g. the ttbar/Z likelihoods on HEPData, INSPIRE 2689657, which could be imported but not written again). The export now checks the channel after splitting; if it is invalid for any reason and valid with the formulas of the channel as custom modifiers, they are written as custom modifiers. | FormulaIsNotSplitIfThatMakesTheChannelInvalid |
| 20 | Count the contributions of a constraint through its data | The exactly-once check of commit 9 counted how often a constraint is listed. It now counts through the paired data: a term once per entry of its data set, a component of a combined_dist through the component of the paired combined data with the same key (nothing if that is missing or empty). A region without data plus the measurement as its own term is one contribution (with a warning); a region without data and no measurement is rejected. Reported in the comments of this PR. | HistFactoryConstraintContributionsCountData |
| 21 | Constraints with data as components of the combined distribution | Export: with exportConstraintData, an array of constraints of a model that is a RooSimultaneous is a component of the combined_dist, with its data set as a component of the combined data set (before: a separate likelihood term). A channel that consists of constraint terms only is written once, as that channel, with the observed values from its global observables if its data is empty. A component of an array is never referred to by its own name. Marked in misc.ROOT_internal.auxiliary_channels. Import: by default, marked components are read as constraint terms with global observables, as before. EXPERIMENTAL config().importConstraintsAsChannels: they stay components of the RooSimultaneous with a one-entry data set, and HistFactory channels are built without them. A distribution that is a component without data and a term with data is read as the term (RooFit left it out of the likelihood before), with a warning. | AuxiliaryMeasurementAsRegionOfTheModel, ConstraintsAsChannels, layout tests adapted |
| 22 | Describe the layout of constraint data in the configuration | Comment of config().exportConstraintData. | – |
| 23 | Constraints back into their channels on import, and two fixes | Import: a constraint term with a global observable becomes a factor of every channel that is a product and uses its parameters, instead of an external constraint of the ModelConfig (the export takes them out of the channels; they did not come back, so the pdf was no longer the sampling distribution of those measurements: in the reported ATLAS Higgs workspace, 19 of 517 global observables were unreachable after a round trip). Penalty terms without an observation and constraints of non-product channels stay external. Export: the observable of a Gaussian constraint is determined before any pdf is written (it could be written with x/mean in the other order than its data set). Experimental import: an observation shared by two likelihoods gets one data set per combined data set. | GaussianConstraintObservableBeforeItsChannel, AuxiliaryObservationSharedByTwoLikelihoods; ConstraintDataOfProductConstraints changed |
| 24 | Wrap channels that are no products with their constraints on import | A component of a combined_dist that is no product (e.g. a single Gaussian) is wrapped in a RooProdPdf <channel>_with_constraints with the constraint terms of its parameters, so that the pdf of the model is the sampling distribution of its auxiliary measurements for such models too; RooFit takes the constraints out of the product when it builds a likelihood, as for a HistFactory channel. The name of the component changes once, in the first round trip. A global observable is recognized by nothing else in the model depending on it; an array of constraints goes into a channel as a whole. | ConstraintsStayInTheSamplingDistribution |

Not changed, by decision: the interpolation combinations that FlexibleInterpVar can't evaluate
(add/poly6/poly1, mult/poly6/poly1 for normsys) are still rejected, which HS3 0.3 requires of a reader that
can't evaluate them.

Behaviour changes users may notice

  • Documents with hs3_version 0.3 or later are checked more strictly. They are rejected for:

  • - a mixture_dist without extended but with one coefficient per summand;
    - a reserved object name;
    - a generic expression that refers to a distribution (see HS3
    #159
    for allowing it in generic_dist later);
    - HistFactory constraints that the likelihood doesn't list exactly once;
    - a data axis whose range contradicts the domains of the analysis.
  • HistFactory staterror gammas of ≥ 0.3 documents are no longer fixed or ranged from the sample errors.

  • mixture_dist with "extended": false and one coefficient per summand is now not extendable.

  • Export:

  • - unbounded data axes omit the bound;
    - landau_dist writes mu;
    - one-entry data sets are written as point data;
    - a ModelConfig without data is written with "data": null (commit 11);
    - log-normal constraints of HistFactory models in RooFit's default parametrization are collected into an
    array_dist and follow config().exportConstraintData (commit 12);
    - functions of literal constants are named const_<number>_<suffix> (commit 13); a parameter named
    const_<number> that needs such a function can't be exported;
    - with config().exportConstraintData, arrays of constraints are components of the model's combined_dist, and
    their data sets (now named <combined data>_<array>) components of the combined data set (commit 21);
    - with config().exportArrayDist = false, the product that held an imported array_dist together is no longer
    written as a product_dist, unless something uses it; its components are written on their own (commit 14).

    Changed tests and reference data

  • MixtureDistExtendedFlag (commit 3): its last case expected a warning for "extended": false; it now checks that

  • the mixture is not extendable and has the normalized shape. New cases for the missing flag.
  • Commit 9:

  • - tutorials/roofit/roofit/rf515_hfJSON.json, and the hand-written 0.3 documents of
    HistFactoryArrayDistConstraints, HistFactoryArrayDistExport, HistFactoryConstraintTermsInLikelihood
    (twoChannelHistFactoryJSON()) and HistFactoryConstraintAlsoExternal: their likelihoods now list the
    constraints in aux_distributions.
  • Commit 11:

  • - a hand-written document of ObservablesWithoutData uses "data": null instead of [0];
    - HistFactoryConstraintTermsInLikelihood imports a combined data set for its RooSimultaneous, so that the
    likelihood has data and the test still covers the data sets of constraint terms; expected data names adjusted.

  • StatErrorFromDocument (commit 10), changed in the rebase onto master 3aa99aad3f4: it expected the unconstrained

  • gamma of a bin without uncertainty to be fixed in a document before 0.3. Master 25dc4e91aa6 leaves unconstrained
    gammas free in any version, so the test now expects that, and fixes the gamma by hand before the round trip that
    checks that a fixed gamma is written as fixed.
  • ConstraintDataOfProductConstraints (commit 23): it expected a constraint of a product to be an external constraint

  • of the ModelConfig after a round trip. It now expects it to be a factor of the model again, and no external
    constraint.
  • Commits 12–15 change no existing test. Known limitation, unchanged: a workspace with

  • Measurement::AddLogNormSyst() can't be exported (NormSysWithFunctionAsParameter).

    Checklist:

  • tested changes locally

  • updated the docs (if necessary)
  • Rebased again onto master 3aa99aad3f4, which includes 25dc4e91aa6 ("Fix HistFactory constraints, gammas and
    older-document import"). Commit 10 conflicted with its new configuration of the gammas and was merged as described
    in the table; the other conflicts were mechanical. At the tip, testRooFitHS3 (194 tests) and
    testHS3AuxiliaryMeasurements (51 tests) pass, again with the HS3 library compiled from the branch against an
    existing ROOT build, not through CMake: the new hs3cpp object library of master is not exercised by this. The 283
    HS3 documents of the 17 records that HEPData lists under analysis:hs3 (all written by ROOT, HS3 0.1.90 and 0.2)
    were surveyed: none has a staterror without a constraint type, so none is affected by the gamma changes. 44 of them
    (at least one per resource) were imported before and after the rebase with identical variables; the three that
    failed to import are fixed by commits 17–18. With commit 19, all 283 documents are imported, exported and imported
    again without error, checked with the elective test of #24228 (run against the HS3 library of this branch); that
    test lists four of them as expected failures on master, which have to be removed there or here, whichever is merged
    second.

    Commits 20–24 (auxiliary measurements as regions, reported in the comments): at the tip, testRooFitHS3 199 tests
    and testHS3AuxiliaryMeasurements 63 tests pass (same private build), and all 283 HS3 documents from HEPData are
    imported, exported and imported again without error. Limitations: a workspace read with
    importConstraintsAsChannels is written without the constraints of its modifiers (same likelihood); without the
    mark in misc, a component with one entry is always read as a channel; RooSimultaneous::generate() can't sample
    such a model in one call, each component can be sampled by itself.

    Before that, rebased onto master 7cc3f1b4474 ("Remove JSON I/O through export keys and factory expressions"): commit 2 now
    changes the C++ importer and exporter of landau_dist that this master commit introduced, instead of the removed
    export keys and factory expressions. After the rebase, testRooFitHS3 was built and run on each of the 15 commits
    (158 tests at commit 1, 170 at the tip, all passing) and testHS3AuxiliaryMeasurements at the tip (51 passing), with
    the HS3 library compiled from the branch against an existing ROOT build, not through CMake. The numbers below are
    from before the rebase.

    Tests run (Linux, GCC 13, RelWithDebInfo, -Droofit=ON -Dtesting=ON) on top of master 27fbb8dd02a:
    testRooFitHS3 157 → 167 tests (10 new), testHistFactory 44, all passing. Every commit was built and tested on its
    own (testRooFitHS3 and testHistFactory). clang-format clean.

    Commits 12–15: testRooFitHS3 167 → 170 tests and the new testHS3AuxiliaryMeasurements (51 tests), all passing;
    testRooFitHS3 was run on each of the commits 12–14. These were tested with the HS3 library and the two test
    programs compiled from the branch against an existing ROOT build of this PR, not through CMake: the new
    ROOT_ADD_GTEST line and a full build of commits 12–15 are untested. testHistFactory doesn't use the HS3 library
    and was not rerun.

    Not run: the PyROOT tests, the rf515_hfJSON.py tutorial (its JSON is covered by TutorialRF515RoundTrip), and the
    optional HS3 test suite.

    AI assistance: Claude Code (claude-opus-5-5) implemented the changes, the tests and this description from a list of
    required changes that the author reviewed, under review of the author. The commits carry
    Assisted-by: claude-code:claude-opus-5-5. Commits 12–24 were written by Claude Code (claude-fable-5-2) from an
    audit of the export layouts and a check of the documents on HEPData that the author directed, and carry
    Assisted-by: claude-code:claude-fable-5-2. It also did the rebases and their conflict resolutions.

    🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: guitargeek Review duration: 3103m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #24201"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%