[RF][HS3] Follow the HS3 0.3 specification fixes (HS3 #154) #24201
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
guitargeek
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_version0.3 or later, and older documents are read as before, usually with a warning. The codefor 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.
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
nullundefined); RooFit wrotenull, 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 writesmu;meanis 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
falsewith one coefficient per summand: honoured (built from the normalized coefficientsc_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,ifelseor 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/RooGenericPdfdepending on a pdf,RooTFnBindingwith a pdf, the transformation helpers ofRooLognormal/RooExponential). Whether to allowgeneric_distexpressions on distributions later is discussed in HS3 #159. |ReservedNamesAndDistributionReferences|| 6 | Read and write point data as a RooDataSet with one entry |
pointdata (rejected so far) becomes a one-entry 1DRooDataSet; such a data set (one real variable, one unweighted entry) is written aspointdata with its axis, also for the constraint data ofconfig().exportConstraintData. The provisionaluncertaintyis 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 |
constraintsof 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 anullconstraint. |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 toaux_distributionsalso withconfig().exportConstraintData. |PureModelLikelihood|| 12 | Lognormals in the parametrization of RooFit as array components | A
RooLognormalin RooFit's default parametrization (median, shape) is written withmu/sigmanaming the functionslog(median)/log(shape). It could not be a component of anarray_dist, soconfig().exportArrayDistandconfig().exportConstraintDatahad 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_logor-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 formconst_<number>are reserved for this. The old names are still read. |FunctionsOfLiteralConstantsHaveValidNames|| 14 | Don't write helper objects that nothing refers to | The
RooProdPdfthat holds the components of an importedarray_disttogether was written as aproduct_distwhen 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 attributehs3_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 ofexportArrayDist×exportConstraintDataand 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()inHS3Writer.cxxbut 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 withdev=ON. | builds with the CI flags ofdev=ON|| 17 | Accept data axes with a fixed "value" in documents before 0.3 | Commit 8 rejected a data axis with
valuein 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
histosysmodifiers 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
RooFormulaVarfactor 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 anormfactor, became twonormfactors 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_distthrough 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 aRooSimultaneousis a component of thecombined_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 inmisc.ROOT_internal.auxiliary_channels. Import: by default, marked components are read as constraint terms with global observables, as before. EXPERIMENTALconfig().importConstraintsAsChannels: they stay components of theRooSimultaneouswith 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/meanin 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;ConstraintDataOfProductConstraintschanged || 24 | Wrap channels that are no products with their constraints on import | A component of a
combined_distthat is no product (e.g. a single Gaussian) is wrapped in aRooProdPdf<channel>_with_constraintswith 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
FlexibleInterpVarcan't evaluate(
add/poly6/poly1,mult/poly6/poly1fornormsys) are still rejected, which HS3 0.3 requires of a reader thatcan't evaluate them.
Behaviour changes users may notice
hs3_version0.3 or later are checked more strictly. They are rejected for:- a
mixture_distwithoutextendedbut 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_distlater);- HistFactory constraints that the likelihood doesn't list exactly once;
- a data axis whose range contradicts the domains of the analysis.
mixture_distwith"extended": falseand one coefficient per summand is now not extendable.- unbounded data axes omit the bound;
-
landau_distwritesmu;- one-entry data sets are written as
pointdata;- 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_distand followconfig().exportConstraintData(commit 12);- functions of literal constants are named
const_<number>_<suffix>(commit 13); a parameter namedconst_<number>that needs such a function can't be exported;- with
config().exportConstraintData, arrays of constraints are components of the model'scombined_dist, andtheir data sets (now named
<combined data>_<array>) components of the combined data set (commit 21);- with
config().exportArrayDist = false, the product that held an importedarray_disttogether is no longerwritten 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 thatthe mixture is not extendable and has the normalized shape. New cases for the missing flag.
-
tutorials/roofit/roofit/rf515_hfJSON.json, and the hand-written 0.3 documents ofHistFactoryArrayDistConstraints,HistFactoryArrayDistExport,HistFactoryConstraintTermsInLikelihood(
twoChannelHistFactoryJSON()) andHistFactoryConstraintAlsoExternal: their likelihoods now list theconstraints in
aux_distributions.- a hand-written document of
ObservablesWithoutDatauses"data": nullinstead of[0];-
HistFactoryConstraintTermsInLikelihoodimports a combined data set for itsRooSimultaneous, so that thelikelihood 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 master3aa99aad3f4: it expected the unconstrainedgamma of a bin without uncertainty to be fixed in a document before 0.3. Master
25dc4e91aa6leaves unconstrainedgammas 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 constraintof the ModelConfig after a round trip. It now expects it to be a factor of the model again, and no external
constraint.
Measurement::AddLogNormSyst()can't be exported (NormSysWithFunctionAsParameter).Checklist:
Rebased again onto master
3aa99aad3f4, which includes25dc4e91aa6("Fix HistFactory constraints, gammas andolder-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) andtestHS3AuxiliaryMeasurements(51 tests) pass, again with the HS3 library compiled from the branch against anexisting ROOT build, not through CMake: the new
hs3cppobject library of master is not exercised by this. The 283HS3 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,
testRooFitHS3199 testsand
testHS3AuxiliaryMeasurements63 tests pass (same private build), and all 283 HS3 documents from HEPData areimported, exported and imported again without error. Limitations: a workspace read with
importConstraintsAsChannelsis written without theconstraintsof its modifiers (same likelihood); without themark in
misc, a component with one entry is always read as a channel;RooSimultaneous::generate()can't samplesuch 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 nowchanges the C++ importer and exporter of
landau_distthat this master commit introduced, instead of the removedexport keys and factory expressions. After the rebase,
testRooFitHS3was built and run on each of the 15 commits(158 tests at commit 1, 170 at the tip, all passing) and
testHS3AuxiliaryMeasurementsat the tip (51 passing), withthe 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 master27fbb8dd02a:testRooFitHS3157 → 167 tests (10 new),testHistFactory44, all passing. Every commit was built and tested on itsown (
testRooFitHS3andtestHistFactory). clang-format clean.Commits 12–15:
testRooFitHS3167 → 170 tests and the newtestHS3AuxiliaryMeasurements(51 tests), all passing;testRooFitHS3was run on each of the commits 12–14. These were tested with the HS3 library and the two testprograms compiled from the branch against an existing ROOT build of this PR, not through CMake: the new
ROOT_ADD_GTESTline and a full build of commits 12–15 are untested.testHistFactorydoesn't use the HS3 libraryand was not rerun.
Not run: the PyROOT tests, the
rf515_hfJSON.pytutorial (its JSON is covered byTutorialRF515RoundTrip), and theoptional 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 anaudit 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