Skip to content

[HS3] Add structured interpolation support for HistFactory modifiers#22844

Open
Phmonski wants to merge 1 commit into
root-project:masterfrom
Phmonski:feat/hs3-export-interpolation-information
Open

[HS3] Add structured interpolation support for HistFactory modifiers#22844
Phmonski wants to merge 1 commit into
root-project:masterfrom
Phmonski:feat/hs3-export-interpolation-information

Conversation

@Phmonski

Copy link
Copy Markdown
Contributor

Summary

This PR adds bidirectional RooFit support for the structured interpolation representation introduced in hep-statistics-serialization-standard/hep-statistics-serialization-standard#103.

RooFit now exports interpolation behavior using the descriptive HS3 {type, in, out} structure instead of RooFit-specific integer codes. Import remains backward compatible with legacy integer interpolation fields and files relying on the previous implicit defaults.

Main changes

  • Add an internal structured interpolation descriptor with validated type, in, and nullable out fields.
  • Add class-specific mappings for FlexibleInterpVar and PiecewiseInterpolation.
  • Export a channel-level default_interpolation, selected from the most common interpolation behavior across normsys and histosys modifiers.
  • Omit modifier-level interpolation when it matches the channel default.
  • Emit an explicit structured interpolation object for modifiers that differ from the default.
  • Prefer {type: mult, in: poly6, out: exp} when frequencies are tied, followed by deterministic descriptor ordering.
  • Omit default_interpolation when a channel has no eligible modifiers.
  • Compare duplicate modifiers by interpolation behavior rather than their raw RooFit codes, allowing semantic aliases such as FlexibleInterpVar codes 4 and 5.
  • Add a PiecewiseInterpolation constructor accepting one interpolation code per parameter. This allows mixed histosys interpolation codes and repeated parameters to round-trip faithfully.

No interpolation mathematics or persistent class data layouts are changed.

Supported mappings

HS3 interpolation PiecewiseInterpolation FlexibleInterpVar
{add, poly1, null} 0 0
{mult, exp, null} 1 1
{add, poly2, poly1} 2; legacy 3 alias 2; legacy 3 alias
{add, poly6, poly1} 4 unsupported
{mult, poly6, exp} 5 4 or 5; imported canonically as 4
{mult, poly6, poly1} 6 unsupported

The class-dependent interpretation is important because RooFit code 4 has different semantics in PiecewiseInterpolation and FlexibleInterpVar.

Import compatibility

Interpolation is resolved in the following order:

  1. Modifier-level structured object or legacy integer.
  2. Channel-level default_interpolation.
  3. The legacy class-specific implicit code 4.

Structured objects must contain all three fields, including an explicit "out": null where appropriate. Malformed, unknown, and class-unsupported interpolation descriptions produce contextual errors identifying the channel, sample, and modifier.

RooFit exports only the new structured representation.

Tests

The tests cover:

  • Every supported mapping and legacy alias.
  • Canonicalization of legacy aliases.
  • Modal channel defaults and deterministic ties.
  • Explicit modifier overrides.
  • Channels without eligible modifiers.
  • Mixed histosys codes in one PiecewiseInterpolation.
  • Numerical round trips at interior, anchor, and extrapolation points.
  • Legacy integer fields and implicit defaults for both modifier classes.
  • Malformed, unknown, and class-unsupported interpolation objects.
  • Duplicate-modifier canonicalization using semantically equivalent codes.
  • Repeated parameters with per-entry PiecewiseInterpolation codes.
    @cburgard @stalbrec

@github-actions

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 17h 51m 52s ⏱️
 3 874 tests  3 874 ✅ 0 💤 0 ❌
79 716 runs  79 716 ✅ 0 💤 0 ❌

Results for commit ad9e6ac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants