betaFeedback

WorksPhysics and Astronomy

SysVar: Consistent and scalable treatment of systematic uncertainties in template-based analyses

Abstract

Propagating systematic uncertainties from correction weights into templates generated from simulated data while preserving correlations in the signal extraction variables becomes increasingly challenging as analyses scale in size. SysVar's lightweight API hides most of the bookkeeping complexity of applying correction weights, building systematic variations, and histogramming nominal and varied templates. This streamlines workflows that are otherwise error-prone but essential for high-precision measurements. Correlations are preserved by propagating the full covariance across the analysis and compressing it into a small set of orthogonal eigenvariations, each defining an ordinary shape nuisance parameter. In this work, we demonstrate SysVar's workflow and impact by combining two independent pseudo-measurements that benefit from consistently correlated systematic uncertainties encoded in the template shapes. SysVar is open-source, pip-installable, and experiment-agnostic.

Introduction

In a typical high-energy physics measurement, the observed data is a mixture of several physical processes, isolated through a template fit [1] against simulation. This simulation is reweighted to match data, through efficiency, resolution or physics-motivated corrections and such reweighting introduces systematic uncertainties. These corrections are typically measured in bins of auxiliary variables, such as particle momentum or angle. Whatever correlations exist between their bins must be preserved once the corresponding uncertainties reach the templates, where they are implemented as nuisance parameters.

Frameworks built on the HistFactory model [2], such as pyhf [3, 4], support nuisance parameters that are fully correlated or fully uncorrelated across the bins of the signal-extraction variable, but nothing in between. Reproducing a partial correlation therefore requires decomposing it by hand into nuisance parameters the framework supports. This means tracking which correction acts on which bins and combining correlated sources into a single covariance, which becomes impractical once the number of corrections, channels and templates grows. The common approximation is instead to treat such correlations as either full or absent, since that is what these frameworks support directly. This generally does not hold as we show in § 2.

SysVar addresses this by sampling correlated variations of the correction weights, building the resulting covariance across the full analysis, and compressing it through an eigendecomposition into a small set of orthogonal eigenvariations. Each eigenvariation defines an ordinary, fully correlated shape nuisance parameter that a standard fitting framework can use, with native output for cabinetry [5] and pyhf. Analyses are defined declaratively rather than through procedural code, and every intermediate step of the propagation remains inspectable. Although developed for Belle II, nothing about the package is experiment-specific.

The rest of this document is organized as follows. We introduce a synthetic dataset illustrating why this propagation is non-trivial in § 2. We describe the method itself in § 3. We demonstrate its impact on a toy combination of two measurements in § 4. We discuss its usage and computational cost in § 5 and § 6, and conclude in § 7.

Dataset and problem

For demonstration purposes, we generate a synthetic dataset representing a generic decay X→YZX \to YZ.

Each event is labelled as either signal or background and carries two quantities. The fit observable MM is the invariant mass of the XX system. The calibration variable cc stands for the quantity in which an auxiliary calibration is measured, for instance the momentum of the decay product YY. This is deliberately not the observable used in the fit. We denote the iith bin of an observable OO by bOib_{O_i}, and its partial contribution from template tt by bOitb^t_{O_i}.

Whether an event is signal or background depends on cc, but only weakly. The dependence is far too weak to separate the two processes in a fit. It instead stands in for the hidden relations between the composition of a sample and the variables in which its corrections are binned, relations that are in practice rarely understood in detail. Generating the labels independently of cc would be the unrealistic choice. The correction would then factor out of the fit observable, and the effect under study would disappear by construction.

The correction under study is an efficiency calibration measured in two bins of cc, denoted bc1b_{c_1} and bc2b_{c_2}, with per-bin uncertainties at the percent level. Every event is reweighted by the calibration weight of the bin it falls into. Signal and background are given different shapes in MM, which is what allows them to be separated in the fit. Figure 1 shows the effect. The correction shifts the normalisation of both templates and changes their shape differently for signal and background, because the two processes populate the calibration bins differently.

Figure 1. Stacked signal and background templates in the fit observable MM, after applying the calibration weights (top), and the ratio of the yield with and without the calibration weight in each bin, shown separately for the two templates (bottom).

So far this is only a statement about central values. The actual difficulty is that the calibration’s own uncertainties are, in general, partially correlated: they are derived from auxiliary measurements, and even statistically independent control samples share backgrounds and systematic uncertainties. The auxiliary measurement therefore delivers a covariance, parametrised here by ρC=ρ(bC1,bC2)\rho_C = \rho(b_{C_1}, b_{C_2}), for which we take an illustrative value of 0.1.

This covariance does not stay in the space of the calibration once propagated through the reweighting. Each template bin receives contributions from both calibration bins, so ρC\rho_C re-emerges as a correlation between bins of the fit observable, crossing templates and template types alike. The result is the dense 6×66 \times6 matrix ρT(bMitb,bMjta)\rho_T(b_{M_i}^{t_{b}}, b_{M_j}^{t_{a}}) of Figure 2a, with t∈{sig,bkg}t \in\{\mathrm{sig}, \mathrm{bkg}\}.

Figure 2. (a) Correlation matrix ρT\rho_T induced across the six bins of the analysis (three bins of MM for each of the two templates) by a correction whose two calibration bins are correlated with ρC=0.1\rho_C = 0.1. (b) Induced correlation ρT\rho_T between the first signal bin and each of the remaining five bins, as a function of ρC\rho_C, with all other inputs held fixed.

This relation is neither linear nor universal. Figure 2b scans ρT\rho_T between the first signal bin and each of the other five across the full range of ρC\rho_C. The pairs respond very differently, from nearly insensitive to swinging between −0.6-0.6 and +1+1, and all remain large and positive already at ρC=0\rho_C = 0, so treating them as uncorrelated is not conservative but wrong.

Method for propagating the correction uncertainties into templates

The correlations described in § 2 cannot be written in closed form. They depend on how the events of each template distribute across the bins of every correction. SysVar instead propagates them by sampling. The propagation happens in four stages. SysVar builds the covariance of the correction weights, draws correlated variations from it, rebuilds the templates for each variation, and turns the resulting covariance into a basis a fitting framework can use.

Sampling

All uncertainty sources acting on a correction are collected into a single covariance matrix, and NνN_\nu variations, or toys, are drawn from the multivariate Gaussian it defines, reproducing any correlation the auxiliary measurement reported. If several objects in an event receive a weight from the same correction (say, two leptons with the same identification efficiency) in the same bin, SysVar applies the same toy’s values to all of them. Varying each independently would treat the correction bins as independent within the event, defeating the purpose of the correlated draw.

Building the covariance.

Each variation gives a re-histogrammed set of templates. Let NvIN_{vI} be the content of bin II in variation vv, with composite index I=(c,s,i)I = (c, s, i) labelling bin ii of template ss in channel cc. Let ΓvI=NvI−NˉI\Gamma_{vI} = N_{vI} - \bar{N}_{I} be its shift from the mean over variations. The covariance of the systematic source over the whole analysis is

CsystIJ=1Nv−1∑v=1NvΓvIΓvJ.(1)C_{\mathrm{syst}}^{IJ} = \frac{1}{N_v - 1} \sum_{v=1}^{N_v} \Gamma_{vI}\Gamma_{vJ}. \tag*{(1)}

II and JJ range over channels, templates and bins together, so this is a single covariance over the full analysis space rather than one matrix per template. It is shown, in normalised form, in Figure 2a.

Change of basis.

A covariance is not something a template fit can use directly. Frameworks built on the HistFactory model, such as pyhf, represent a systematic as a nuisance parameter whose bin-to-bin behaviour is either fully correlated, with one parameter driving every bin together, or fully uncorrelated, with one parameter per bin, and nothing in between. Diagonalising the covariance,

Csyst=VUVT=(VU)(VU)T=Γ′Γ′T,Γ′=VU,(2)C_{\mathrm{syst}} = VUV^{T} = \left(V\sqrt{U}\right)\left(V\sqrt{U}\right)^{T} = \Gamma^{\prime}\Gamma^{\prime T}, \qquad\Gamma^{\prime} = V\sqrt{U}, \tag*{(2)}

where VV is the matrix of eigenvectors of CsystC_{\mathrm{syst}} and UU the diagonal matrix of its eigenvalues, turns each eigenvector into an eigenvariation. Each eigenvariation is a single coherent, orthogonal shift of every bin that sets the size of an ordinary, fully correlated shape nuisance parameter’s effect. Retaining every eigenvariation reproduces CsystC_{\mathrm{syst}} exactly, so nothing is approximated at this stage.

Truncation.

Without truncation, the number of shape nuisance parameters would equal the dimension of the template space, one per bin. This is rarely necessary, because the eigenvalues of CsystC_{\mathrm{syst}} typically fall off by orders of magnitude within the first few dozen directions, well short of that full dimension, so a small subset already reproduces the covariance to a chosen precision. SysVar adds eigenvariations in order of decreasing eigenvalue and stops once the largest residual entry of Csyst−Csyst′C_{\mathrm{syst}} - C_{\mathrm{syst}}^{\prime}, normalised to the largest entry of CsystC_{\mathrm{syst}}, drops below a user-set threshold. A criterion based on the accumulated trace is available as an alternative. Figure 3 shows this convergence for a large analysis.

Figure 3. Convergence of the truncation for a large analysis with 1750 template-space bins, as eigenvariations are added in decreasing eigenvalue order. The largest residual entry of Csyst−CsystnomC_{\mathrm{syst}} - C_{\mathrm{syst}}^{\mathrm{nom}}, normalised to the largest entry of CsystC_{\mathrm{syst}}, drops below the 10−810^{-8} precision threshold after 44 eigendirections.

This criterion is a statement about the covariance rather than the measurement, and is best read as a starting point rather than a guarantee. It should be validated case by case. Add the retained eigenvariations to the fit one at a time until the uncertainty on the parameter of interest stops moving. If it has not stopped moving by the last saved one, the requested precision was too loose and the eigendecomposition should be repeated with a tighter one.

How many directions are retained is itself informative. A fully correlated correction collapses onto one dominant eigendirection, an uncorrelated one onto one per weight, and the partially correlated case in between, the one that motivates SysVar, needs a number that cannot be anticipated. For the dataset of § 2, whose correction has only two calibration bins, the covariance has rank two, and SysVar retains exactly two eigendirections.

The retained eigenvariations are written out as the up and down template shifts that cabinetry [5] and pyhf expect for a shape nuisance parameter, so the output feeds directly into the signal-extraction fit.

Impact on measurement combinations

The case where a consistent treatment matters most is the one where a systematic uncertainty is shared between measurements that are otherwise independent. To illustrate it we built a toy combination along the lines of Ref. [6], in which Belle II and LHCb pseudo-measurements of the lepton flavour universality ratios R(D(∗))=B(B→D(∗)τν)/B(B→D(∗)ℓν)R(D^{(*)}) = \mathcal{B}(B \to D^{(*)}\tau\nu)/\mathcal{B}(B \to D^{(*)}\ell\nu) are brought together.

The setup uses four reconstruction channels, an R(D)R(D) and an R(D∗)R(D^{*}) channel for each experiment, built on the fit model of Ref. [6]. For details on the signal-extraction variables and templates we refer the reader to that reference. That study does not include systematic uncertainties, so for this demonstration we introduce a single shared source of our own. Three background branching-fraction corrections, BF1\mathrm{BF}_{1}, BF2\mathrm{BF}_{2} and BF3\mathrm{BF}_{3}, are assumed to be partially correlated, as shown in Table 1.

BF1\mathrm{BF}_{1}BF2\mathrm{BF}_{2}BF3\mathrm{BF}_{3}
BF1\mathrm{BF}_{1}110.050.05−0.35-0.35
BF2\mathrm{BF}_{2}0.050.05110.100.10
BF3\mathrm{BF}_{3}−0.35-0.350.100.1011

Table 1. Correlation assumed between the three background branching-fraction corrections.

Two ways of arriving at a combined result are then compared. The conventional one fits each experiment separately and averages the outcomes afterwards, with the shared systematic declared fully correlated between them. This is an assumption that can only be applied to the final uncertainties, since neither fit knows anything about the other’s templates. The alternative is a single fit over all four channels in which the shared uncertainty enters through the eigenvariations built from the common covariance, so that it acts on the shapes of the templates in both experiments at once, and its correlations are carried through the fit rather than imposed on the results.

Figure 4 shows the two. The contours are of comparable size, but they are not centred on the same point. The combined fit sits lower in R(D∗)R(D^*) than the post-fit average. The reason is that a correlation asserted between two final uncertainties acts only on their sizes, whereas propagating the shared source through the templates lets it act on their shapes. Where a common background is pulled in one direction by the data of one experiment, the correlated shape uncertainty transmits that constraint to the other, and the signal yields respond accordingly.

Figure 4. Toy combination of Belle II and LHCb pseudo-measurements of R(D)R(D) and R(D∗)R(D^*), normalised to their Standard Model values. The filled contours are the two individual pseudo-measurements. The dashed contours compare a post-fit average in which the shared branching-fraction uncertainty is assumed to be fully correlated between the experiments with a simultaneous fit in which the same uncertainty is propagated into the template shapes by SysVar. All contours are at 68% confidence level. Relative to the post-fit average, the combined fit’s central value differs by about −4% in R(D∗)R(D^*) (roughly 0.4σ\sigma) and by less than 0.5% in R(D)R(D) (about 0.03σ\sigma).

This comparison is illustrative rather than predictive. It comes from a single pseudo-dataset, so the exact size and direction of the shift belong to that realisation. What it does show is that the two treatments are not equivalent. Once experiments share a systematic source, the choice of how to correlate it is a modelling decision that moves the combined central value, and propagating the source through the template shapes replaces a correlation imposed afterward with one that the fit itself can act on.

Usage

Everything described in § 3 is reached through two function calls. A helper function attaches the nominal correction weights, read from a CSV file or a Python dictionary, to the events. Another one then samples the variations, rebuilds the templates, forms the covariance of Equation (1) and returns the eigenvariations. The sampling, histogramming and bookkeeping are all handled internally.

Convenience like this can come at the price of opacity, which SysVar avoids by construction. It is organised by class composition with only shallow inheritance. Each stage, from the uncertainty models and corrections through the variations and templates to the eigenecomposition, is a self-contained object held by the next stage rather than derived from it. The object returned by eigendecompose keeps every intermediate reachable, from the covariance and eigenvariations down to the individual varied templates, each with its own plotting methods and complemented by further visualisation entry points in the API. SysVar streamlines the workflow without hiding it. Every step can be inspected.

What the analyst writes is a declaration, not code. Channels, templates and systematic sources are entries in a single configuration object, in Python, YAML or JSON, that lives in one place, can be version-controlled and diffed like any other input, and grows by adding entries rather than writing procedural code. A correction can be included in or excluded from specific channels or templates just as easily, with the resulting combinatorics resolved by SysVar rather than by hand. The retained eigenvariations are written to a ROOT [7] file laid out as cabinetry expects, so the transition to the fit needs no further bookkeeping.

Performance and scaling

Whether this is usable in practice depends on what it costs to run. We measured this with a standalone benchmark that generates a synthetic sample like that of § 2 and times only the SysVar propagation of § 3, scanning a four-dimensional space around a fixed baseline, made up of the size of the event sample, the number of correction bins, the binning of the fit observable, and the number of objects per event that share a correction. Each configuration was repeated 20 times on a single process, recording wall-clock time and peak resident memory.

Figure 5 shows the resulting means. Memory scales as expected for a dataframe-based tool, growing linearly with the event sample and the number of corrected objects per event. Runtime is mild elsewhere but rises steeply with the binning of the fit observable, since diagonalising the covariance of Equation (1) costs O(d3)O(d^{3}), where dd is the dimension of the template space [8]. For typical sample sizes and binnings the propagation costs minutes and a few gigabytes on a single core. What eventually limits the method is not the size of the dataset but the dimension of the template space, and the truncation of § 3 keeps that from propagating into the number of nuisance parameters carried by the fit.

Figure 5. Runtime (top) and peak memory (bottom) of the SysVar stage as each scanned quantity is varied around the baseline, for one, two and four objects per event carrying a weight from the same correction.

Conclusion and outlook

We have presented SysVar, a package for propagating the uncertainties of simulation correction weights into template-based analyses while preserving their correlations. Using a synthetic dataset, we demonstrated how a correction with partially correlated per-bin uncertainties induces a dense correlation structure across the fit templates that neither a fully correlated nor an uncorrelated treatment reproduces. We described how SysVar builds the corresponding covariance and compresses it into a small set of orthogonal eigenvariations, each defining an ordinary nuisance parameter. We showed its impact on a toy combination of two measurements sharing a systematic source, where propagating the shared uncertainty through the template shapes shifted the combined result relative to a conventional post-fit average. The propagation itself runs in minutes on a single core for realistic analyses.

The most significant item on the roadmap is a change to where the eigendecomposition itself takes place. SysVar currently builds the covariance from the varied templates and diagonalises it in the, typically large, template space. A mathematically equivalent alternative is to diagonalise the covariance of the correction weights themselves (a much smaller matrix) and vary the templates directly along its orthogonal eigendirections. This has not been implemented yet. In developing SysVar, corrections were deliberately left untransformed at first, so that every intermediate quantity could be compared one to one against existing, template-level analyses. Having now demonstrated that SysVar reproduces the expected behaviour, attaching the central values of the correction weights and diagonalising the corrections directly is the more straightforward and intuitive approach. Supporting this correction-space eigendecomposition as an additional option is the main development planned, and would in particular reduce the cost of the diagonalisation discussed in § 6.

Beyond this, the API will keep growing to make analyses easier to declare, and its visualisation methods will keep extending. Further performance work will target runtime and memory usage, in particular through parallelisation, which is a promising route for the largest analyses.

SysVar already has a growing base of users within Belle II, where the performance group is encouraging its adoption and has aligned its recommended format for correction weights with the one SysVar expects. Nothing about it, however, is specific to Belle II. Its features are experiment-agnostic, making it equally suited to an external user, or to anyone with access to tuples from more than one experiment who wants to combine them consistently.

References

  1. [1]S. Baker, R.D. Cousins, Clarification of the use of chi-square and likelihood functions in fits to histograms, Nuclear Instruments and Methods in Physics Research 221, 437 (1984). 10.1016/0167-5087(84)90016-4
  2. [2]K. Cranmer, G. Lewis, L. Moneta, A. Shibata, W. Verkerke, Tech. Rep. CERN-OPEN-2012-016, CERN (2012)
  3. [3]L. Heinrich, M. Feickert, G. Stark, pyhf: v0.7.6 (2020)
  4. [4]L. Heinrich, M. Feickert, G. Stark, K. Cranmer, pyhf: pure-python implementation of histfactory statistical models, Journal of Open Source Software 6, 2823 (2021). 10.21105/joss.02823DOI
  5. [5]A. Held, M. Feickert, H. Schreiner et al., scikit-hep/cabinetry: v0.6.0 (2023)
  6. [6]J. Albrecht, F. Bernlochner, M. Colonna, L. Gärtner, A. Mathad, B. Mitreska, M. Prim, I. Tsaklidis, Joint lhcb–belle ii prospects to constrain new physics in B → D(*)τν, The European Physical Journal C 86, 718 (2026). 10.1140/epjc/s10052-026-15908-5DOI
  7. [7]R. Brun, F. Rademakers, ROOT: An object oriented data analysis framework, Nucl. Instrum. Meth. A 389, 81 (1997). 10.1016/S0168-9002(97)00048-X
  8. [8]G.H. Golub, C.F. Van Loan, Matrix Computations, 4th edn. (Johns Hopkins University Press, Baltimore, MD, 2013)

Paper details

vlnc:W_mxazs6ad
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents