1 Introduction

Precision analyses of semileptonic b-hadron decays typically rely on detailed numerical Monte Carlo (MC) simulations of detector responses and acceptances. Combined with the underlying theoretical models, these simulations provide MC templates that may be used in fits, to translate experimental yields into theoretically well-defined parameters. This translation though can become sensitive to the template and its underlying theoretical model, introducing biases whenever there is a mismatch between the theoretical assumptions used to measure a parameter and subsequent theoretical interpretations of the data.

Such biases are known to arise in the analyses of semileptonic decays of b hadrons, in particular, for the measurements of the CKM element \(|V_{cb}|\), and in the ratio of semitauonic vs. semileptonic decays to light leptons, (see e.g. Refs. [1, 2] and Ref. [3], respectively),

$$\begin{aligned} R(H_c) = \frac{\varGamma (H_b\rightarrow H_c\tau \bar{\nu })}{\varGamma (H_b\rightarrow H_c l\bar{\nu })}\,, \qquad l = \mu , \,e\,, \end{aligned}$$
(1)

where \(H_{b,c}\) denote b- and c-flavor hadrons. To avoid this, the size of these biases need to be either carefully controlled when experiments quote their results by reversing detector effects, or they can be avoided by using dedicated MC samples for each theoretical model the measurement is confronted with. In this paper we present the newly developed tool, Hammer (Helicity Amplitude Module for Matrix Element Reweighting), designed expressly for the latter purpose.

Semitauonic b hadron decays have long been known to be sensitive to new physics [4,5,6,7,8,9,10], and were first constrained at LEP [11]. At present, the measurements of the \(R(D^{(*)})\) ratios show about a \(3\sigma \) tension with SM predictions, when the D and \(D^*\) modes are combined [12]. In the future, much more precise measurements of semitauonic decays are expected, not only for the \(B\rightarrow D^{(*)}\tau \bar{\nu }\) channels, but also for the not yet studied decay modes, \(\varLambda _b\rightarrow \varLambda _c\tau \bar{\nu }\), \(B_s\rightarrow D_s^{(*)}\tau \bar{\nu }\), as well as involving excited charm hadrons in the final state.

All existing measurements of \(R(D^{(*)})\) rely heavily on large MC simulations to optimize selections, provide fit templates in discriminating kinematic observables, and to model resolution effects and acceptances. Both the \(\tau \) and the charm hadrons have short lifetimes and decay near the interaction point and measurements rely on reconstruction of the ensuing decay cascades. To reconstruct the decay products, often complex phase space cuts and detector efficiency dependencies come into play, and the measurement of the full decay kinematics is impossible due to the presence of multiple neutrinos. In addition, depending on the final state, a significant downfeed with similar experimental signatures from misreconstructed excited charm hadron states can be present. Isolation of semitauonic decays from other background processes and the light-lepton final states, then requires precise predictions for the kinematics of the signal semitauonic decay.Footnote 1 Often the limited size of the available simulated samples, required to account for all these effects, constitutes a dominant uncertainty of the measurements, see e.g. [1, 2, 13].

In the literature on the \(R(D^{(*)})\) anomaly, it has become standard practice to reinterpret the experimental values of \(R(D^{(*)})\) in terms of NP Wilson coefficients, even though all current ratio measurements were determined assuming the SM nature of semitauonic decays. However, NP couplings generically alter decay distributions and acceptances. Therefore, they modify the signal and possibly background MC templates used in the extraction, and thus affect the measured values of \(R(D^{(*)})\). This may introduce biases in NP interpretations: preferred regions and best-fit points for the Wilson coefficients can be incorrect; an instructive example of this is provided in Sec 2.3.

Consistent interpretations of the data with NP incorporated requires dedicated MC samples, ideally for each NP coupling value considered, which would permit directly fitting for the NP Wilson coefficients. This approach is sometimes referred to as ‘forward-folding’, and is naively a computationally prohibitively expensive endeavour. Such a program is further complicated because none of the MC generators current used by the experiments incorporate generic NP effects, nor do they include state-of-the-art treatments of hadronic matrix elements.

In this paper we present a new software tool, Hammer, that provides a solution to these problems: A fast and efficient means to reweight large MC samples to any desired NP, or to any description of the hadronic matrix elements. Hammer makes use of efficient amplitude-level and tensorial calculation strategies, and is designed to interface with existing experimental analysis frameworks, providing detailed control over which NP or hadronic descriptions should be considered. The desired reweighting can be implemented either in the event weights or in histograms of experimentally reconstructed quantities (both further discussed in Sect. 3). The only required input are the event-level truth-four-momenta of existing MC samples. Either the event weights and/or histogram predictions may be used, e.g., to generate likelihood functions for experimental fits. Some of the main ideas of Hammer were previously outlined in Refs. [14, 15].

In Sect. 2 we demonstrate the capabilities of Hammer by performing binned likelihood fits on mock measured and simulated data sets, that are created using the Hammer library, and corrected using an approximate detector response. In Sect. 3 a brief overview of the Hammer library and its capabilities are given. Section 4 provides a summary of our findings. Finally, Appendix A provides a detailed overview of the Hammer application programming interface.

2 New physics analyses

We consider two different analysis scenarios:

  1. 1.

    In order to explore what biases may arise in phenomenological studies if NP is present in Nature, we perform an illustrative \(R(D^{(*)})\) toy measurement. This involves carrying out SM fits to mockups of measured data sets, that are generated for several different NP models. The recovered \(R(D^{(*)})\) values are then compared to their actual NP values.

  2. 2.

    To demonstrate using a forward-folded analysis to assess NP effects without biases, we carry out fits to (combinations of) NP Wilson coefficients themselves, with either the SM or other NP present in the mock measured data sets.

The setting of these analyses is a B-factory-type environment. We focus on leptonic \(\tau \) decays, but the procedures and results in this work are equally adaptable to the LHCb environment, and other \(\tau \) decay modes or observables. In our example we focus on kinematic observables important for the separation of signal from background and normalization modes. Fits using angular information may also be implemented, see e.g. Refs. [16, 17] for an example.

We emphasize that the derived sensitivities shown below are not intended to illustrate projections for actual experimental sensitivities per se. Such studies are better carried out by the experiments themselves.

2.1 MC sample

The input Monte Carlo sample used for our demonstration comprises four distinct sets of \(10^5\) events: one for each of the two signal cascades \(B \rightarrow D (\tau \rightarrow e\nu \nu )\nu \), \(B \rightarrow (D^* \rightarrow D\pi ) (\tau \rightarrow e\nu \nu ) \nu \) and for the two background processes, \(B \rightarrow D e\nu \) and \(B \rightarrow (D^* \rightarrow D\pi ) e\nu \). These are generated with EvtGen R01-07-00 [18], using the Belle II beam energies of 7 GeV and 4 GeV. The second B meson decay, often used for identifying or ‘tagging’ the \(B\bar{B}\) event and constraining its kinematic properties, are not included in the current analysis for simplicity, but can be incorporated in a Hammer analysis straightforwardly.

In each cascade, the \(b \rightarrow c l \nu \) decay is generated equidistributed in phase space (“pure phase space”), instead of using SM distributions. This reduces the statistical uncertainties that can otherwise arise from reweighting regions of phase space that are undersampled in the SM to NP scenarios in which they are not.Footnote 2

2.2 Reweighting and fitting analysis

Hammer is used to reweight the MC samples into two-dimensional ‘NP generalized’ histograms (see Sect. 3), with respect to the reconstructed observables \(| \mathbf {p}^*_{\ell }|\) and \(m^2_{\text {miss}}\), the light lepton momentum in the B rest frame and the total missing invariant mass of all neutrinos, respectively. Both variables are well-suited for separating signal from background decays involving only light leptons. In the cascade process of the leptonic \(\tau \) decay in \(B \rightarrow D^{(*)} \tau \nu \), the signal lepton carries less momentum than the lepton from prompt \(B \rightarrow D^{(*)} \ell \nu \) decays. Similarly, the missing invariant mass of \(B \rightarrow D^{(*)} \ell \nu \) decays peaks strongly near \(m_\nu ^2 \simeq 0\), in contrast to \(B \rightarrow D^{(*)} \tau \nu \) in which the multiple neutrinos in the final state permit large values of \(m^2_{\text {miss}}\).

The \(B \rightarrow D^{(*)}\) processes are reweighted to the BLPR form factor parametrization [19], which includes predictions for NP hadronic matrix elements using HQET [20,21,22,23] at \(\mathcal {O}(1/m_{c,b},\, \alpha _s)\).

Charged particles are required to fall in the Belle II angular acceptance of \(20^\circ \) and \(150^\circ \), and leptons are required to have a minimum kinetic energy of 300 MeV in the laboratory frame. An additional event weight is included to account for the slow pion reconstruction efficiencies from the \(D^* \rightarrow D\pi \) decay, based on an approximate fit to the pion reconstruction efficiency curve from BaBar data [1, 24]. The analysis assumes that the second tagging B meson decay was reconstructed in hadronic modes, such that its four-momentum, \(p_{B_\mathrm{tag}}\), is accessible. In conjunction with the known beam four-momentum \(p_{e^+ \, e^-}\), the missing invariant mass can then be reconstructed as \(m^2_{\text {miss}} \equiv (p_{e^+ \, e^-} - p_{B_\mathrm{tag}} - p_{D^{(*)}} - p_\ell )^2\), and the four-momentum of the reconstructed lepton can be boosted into the signal B rest frame. A Gaussian smearing is added to the truth level \(m^2_{\text {miss}}\) with a width of 0.5 GeV\(^2\) to account for detector resolution and tagging-B reconstruction. No additional correction is applied to \(|\mathbf {p}^*_{\ell }|\). Higher dimensional histograms including the reconstructed \(q^2\) and the \(D^* \rightarrow D\pi \) helicity angle may also be incorporated, but are omitted here for simplicity.

Hammer can be used to efficiently compute histograms for any given NP choice. The basis of NP operators is defined in Table 1, with respect to the Lagrangian

$$\begin{aligned} \mathcal {L} = \frac{4 G_F}{\sqrt{2}}\, V_{cb}\, c_{XY}\big (\bar{c}\, \varGamma _X\, b\big )\big (\bar{\ell }\, \varGamma _Y\, \nu \big )\,, \end{aligned}$$
(2)

where \(\varGamma _{X(Y)}\) is any Dirac matrix and \(c_{XY}\) is a Wilson coefficient. We shall generally write explicit Wilson coefficients as \(c_{XY} = S_{qXlY}\), \(V_{qXlY}\), \(T_{qXlY}\), where the S, V, T denotes the Lorentz structure, and X, Y = L, R denotes the chirality. In this simplified analysis, we assume that NP only affects the \(b \rightarrow c \tau \nu \) decays, and not the light-lepton modes.

In order to carry out Wilson coefficient fits, we wrap the Hammer application programming interface with a gammaCombo [25] compatible class. This allows one to use Hammer ’s efficient reweighting of histogram bins to generate the relevant quantities required to calculate a likelihood function for the binned observables of interest. We then carry out a fully two-dimensional binned likelihood fit in \(|\mathbf {p}^*_{\ell }|\) and \(m^2_{\text {miss}}\), assuming Gaussian uncertainties. The fit uses \(12 \times 12\) bins with equidistant bin widths for \(|\mathbf {p}^*_{\ell }| \in (0.2,\, 2.2)\) GeV and \(m^2_{\text {miss}} \in (-2,\, 10)\) GeV\({}^{2}\). The fits determine either \(R(D^{(*)})\), or the real and imaginary parts of Wilson coefficients. The preferred SM coupling is determined simultaneously, in order to remove explicit dependence on \(|V_{cb}|\).

Table 1 The \(b \rightarrow c \ell \nu \) operator basis and coupling conventions. Also shown are the identifying Wilson coefficient labels used in Hammer. The normalization of the operators is as in Eq. (2)

We construct an Asimov data set [26] assuming the fractions and total number of events in Table 2, following from the number of events in Ref. [1, 24]. In the scans, the total number of events corresponds to an approximate integrated luminosity of \(5 \, \text {ab}^{-1}\) of Belle II collisions. We assume events are reconstructed in two categories targeting \(B \rightarrow D \, \tau \bar{\nu }\) and \(B \rightarrow D^* \tau \bar{\nu }\). A fit for the real and imaginary parts of a single Wilson coefficient plus the (real) SM coupling thus has \(2 \times 12 \times 12 - 3 = 285\) degrees of freedom.

Table 2 The Asimov data set components. The fractions were motivated by Refs. [1, 24]

A sizable downfeed background from \(D^*\) mesons misreconstructed as a D is expected in the \(B \rightarrow D \, \tau \bar{\nu }\) channel via both the \(B \rightarrow D^* \, \tau \bar{\nu }\) and \(B \rightarrow D^* \, \ell \bar{\nu }\) decays. This is taken into account by partitioning the simulated \(B \rightarrow D^*\tau \nu \) and \(B \rightarrow D^*\ell \nu \) events into two samples: One with the correct \(m^2_{\text {miss}} = (p_B - p_{D^*} - p_\ell )^2\) and the other with the misreconstructed \(m^2_{\text {miss}} = (p_B - p_{D} - p_\ell )^2\), which omits the slow pion. This downfeed reduces the sensitivity for the case that NP couplings induce opposite effects on the \(B \rightarrow D \tau \bar{\nu }\) versus \(B \rightarrow D^* \tau \bar{\nu }\) total rates or shapes. In addition to semileptonic processes, we assume the presence of an irreducible background from secondaries (i.e., leptons from semileptonic D meson decays), fake leptons (i.e., hadrons that were misidentified as leptons) and semileptonic decays from higher charm resonances (i.e., \(D^{**}\) states). The irreducible background is modeled in a simplified manner by assuming 10 background events in each of the \(12 \times 12\) bins, totaling overall 1440 events per category.

Figure 1 shows the impact on the fit variables of three benchmark models that we use to investigate the effects of new physics:

  1. i)

    The \(R_2\) leptoquark model, which sets \(S_{qLlL} \simeq 8 \, T_{qLlL}\) (including RGE; see, e.g., Refs. [27, 28]);

  2. ii)

    A pure tensor model, via \(T_{qLlL}\);

  3. iii)

    A right-handed vector model, via \(V_{qRlL}\) .

For the ratio plots in Fig. 1, we fix the NP Wilson coefficients to specific values to illustrate the shape changes they induce in \(|\mathbf {p}^*_{\ell }|\) and \(m^2_{\text {miss}}\). The \(R_2\) leptoquark model and tensor model exhibit sizable shape changes. The right-handed vector model shows only an overall normalization change for \(B \rightarrow D \, \tau \bar{\nu }\), with no change in shape compared to the SM, because the axial-vector \(B \rightarrow D\) hadronic matrix element vanishes by parity and angular momentum conservation. For \(B \rightarrow D^*\), both vector and axial vector matrix elements are nonzero, so that introducing a right-handed vector current leads to shape and normalization changes.

Figure 2 shows the projections of the constructed Asimov data set, as well as the distributions expected for the three NP models. The latter have the same couplings as those shown in Fig. 1.

Fig. 1
figure 1

The ratios of differential distributions with respect to the SM, as functions of \(|\mathbf {p}^*_{\ell }|\) and \(m^2_{\text {miss}}\), for various Wilson coefficient working points. For more details see text

Fig. 2
figure 2

The \(B \rightarrow D \, \tau \bar{\nu }\) (top) and \(B \rightarrow D^* \tau \bar{\nu }\) (bottom) distributions in \(|\mathbf {p}^*_{\ell }|\) and \(m^2_{\text {miss}}\) in the Asimov data set. The number of events correspond to an estimated number of reconstructed events at Belle II with \(5 \, \text {ab}^{-1}\)

Fig. 3
figure 3

Top: Illustrations of biases from fitting an SM template to three NP ‘truth’ benchmark models: the 2HDM type II with \(S_{qRlL} = -2\) (left), \(S_{qRlL} = 0.75i\) (middle), and the \(R_2\) leptoquark model with \(S_{qLlL} = 8 \, T_{qLlL} = 0.25 + 0.25 i\) (right). The orange dot corresponds to the predicted ‘true value’ of \(R(D^{(*)})\) for the NP model, to be compared to the recovered 68%, 95% and 99% CLs of the SM fit to the NP Asimov data sets (with uncertainties estimated to correspond to \(\sim 5\) ab\(^{-1}\)) in shades of red. Bottom: The best fit regions for the 2HDM and \(R_2\) model Wilson coefficients obtained from fitting \(R(D^{(*)})\) NP predictions to the recovered \(R(D^{(*)})\) CLs for each NP model. The shades of red denote CLs as in the top row. The best fit (true value) Wilson coefficients are shown by black (orange) dots

2.3 \(R(D^{(*)})\) biases from new physics truth

Many NP analyses and global fits to the \(R(D^{(*)})\) measurements – together with other potentially template-sensitive observables, including \(q^2\) spectra – have been carried out by a range of phenomenological studies (see, e.g., Refs. [27,28,29,30,31,32,33,34,35,36,37,38,39]). As mentioned above, the standard practice has been to fit NP predictions to the world-average values of \(R(D^{(*)})\) (and other data) to determine confidence levels for allowed and excluded NP couplings. However, because the \(R(D^{(*)})\) measurements use SM-based templates, and because the presence of NP operators can strongly alter acceptances and kinematic distributions, such analyses can lead to incorrect best-fit values or exclusions of NP Wilson coefficients.

To illustrate such a bias, we fit SM MC templates to NP Asimov data sets, that are generated with Hammer for three different NP ‘truth’ benchmark points: the 2HDM Type II with \(S_{qRlL} = -2\), corresponding to \(\tan \beta / m_{H^+} \simeq 0.5\) GeV\(^{-1}\); the same with \(S_{qRlL} = 0.75i\); and the \(R_2\) leptoquark model with \(S_{qLlL} = 8 \, T_{qLlL} = 0.25 + 0.25\, i\). (These models and couplings are for illustration; our goal here is only to demonstrate the type of biases that may plausibly be presumed to occur.) We replicate the fit of all existing measurements, allowing the normalizations of the D and \(D^*\) modes (and the light leptonic final states) to float independently, without imposing e.g. their predicted SM relationship. This fit leads to a best-fit ellipse in the R(D) – \(R(D^*)\) plane.

In Fig. 3 we show the recovered values, \(R(D^{(*)})_{\text {rec}}\), obtained from this procedure, and compare them to the actual predictions of the given NP truth benchmark point, \(R(D^{(*)})_{\text {th}}\). For ease of comparison, we normalize the \(R(D^{(*)})\) values against the SM predictions for \(R(D^{(*)})_{\text {SM}}\). The resulting recovered best fit ratios, defining \(\hat{R}(D^{(*)}) = R(D^{(*)})/R(D^{(*)})_{\mathrm {SM}}\)

$$\begin{aligned} \text {2HDM }(-2): ~&\hat{R}(D)_{\text {rec}} = 1.35(7)\,,&\hat{R}(D)_{\text {th}} = 1.66 \\&\hat{R}(D^*)_{\text {rec}} = 0.96(2)\,,&\hat{R}(D^*)_{\text {th}} = 0.92 \\ \text {2HDM }(0.75i):~&\hat{R}(D)_{\text {rec}} = 1.24(7)\,,&\hat{R}(D)_{\text {th}} = 1.48 \\&\hat{R}(D^*)_{\text {rec}} = 1.01(2)\,,&\hat{R}(D^*)_{\text {th}} = 1.02 \\ {R_2:~}&\hat{R}(D)_{\text {rec}} = 1.24(7)\,,&\hat{R}(D)_{\text {th}} = 1.48 \\&\hat{R}(D^*)_{\text {rec}} = 0.92(2)\,,&\hat{R}(D^*)_{\text {th}} = 0.85\,. \end{aligned}$$

For two NP models, the recovered ratios from fitting the Asimov data set exclude the truth \(R(D^{(*)})_{\text {th}}\) values at \(\gtrsim 4\sigma \), and the other at \(3\sigma \). The recovered ratios show deviations from the SM comparable in size (but in some cases a different direction) to the current world average \(R(D^{(*)})\), and much smaller than the deviations expected from the truth \(R(D^{(*)})_{\text {th}}\) values. This illustrates the sizable bias in the measured \(R(D^{(*)})\) values that may be presumed to ensue from carrying out fits with an SM template, if NP actually contributes to the measurements. We emphasize that the degree to which a particular NP model is actually affected by this type of bias – including the size and direction of the bias – may be sensitive to the details of the experimental framework and is therefore a question that can only be answered within each experimental analysis.

We also show in Fig. 3 the equivalent bias arising from a naïve fit of the \(R(D^{(*)})\) NP prediction that attempts to recover the complex Wilson coefficient. This is done by parametrizing \(R(D^{(*)})_{\text {th}} = R(D^{(*)})[c_{XY}]\), and fitting this expression to the recovered \(R(D^{(*)})_{\text {rec}}\) values. Explicitly, one calculates CLs in the Wilson coefficient space via the two degree of freedom chi-square \(\chi ^2 = \varvec{v}^T \sigma _{R(D^{(*)})}^{-1} \varvec{v}\), with \( \varvec{v} = \big (R(D)_{\text {th}} - R(D)_{\text {rec}}\,, R(D^*)_{\text {th}} - R(D^*)_{\text {rec}}\big )\). The resulting best fit Wilson coefficient regions similarly exclude the truth values.

Thus, the allowed or excluded regions of NP couplings determined from fits to the \(R(D^{(*)})\) measurements must be treated with caution, as these fits do not include effects of the NP distributions in the MC templates. Similarly, results of global fits should be interpreted carefully when assessing the level of compatibility with specific NP scenarios.

2.4 New physics Wilson coefficient fits

Instead of considering observables like \(R(D^{(*)})\), for phenomenological studies to be able to properly make interpretations and test NP models, experiments should provide direct constraints on NP Wilson coefficients themselves. For example, this could be done with simplified likelihood ratios that profile out all irrelevant nuisance parameters from, e.g., systematic uncertainties or information from sidebands or control channels, or by other means.

As an example, we now use Hammer to perform such a fit for the real and imaginary parts of the NP Wilson coefficients, using the set of three NP models in Sect. 2.2 as templates. These are fit to the same two truth benchmark scenarios as in Fig. 4: a truth SM Asimov data set; and a truth Asimov data set reweighted to the 2HDM Type II with \(S_{qRlL} = -2\).

Figure 4 shows in shades of red the 68%, 95% and 99% confidence levels (CLs) of the three NP model scans of SM Asimov data sets. For the SM truth benchmark, the corresponding best fit points are always at zero NP couplings. The derived CLs then correspond to the expected median exclusion of the fitted NP coupling under the assumption the SM is true.

Fig. 4
figure 4

The 68%, 95% and 99% CL allowed regions of the three models under consideration, from fitting the SM (red) and 2HDM type II (yellow and with \(S_{qRlL} = -2\)) Asimov data sets. (Top) \(R_2\) leptoquark model with \(S_{qLlL} = 8 T_{qLlL}\); (middle) NP in the form of a left-handed tensor coupling; (bottom) NP in the form of a right-handed vector coupling

We further show in shades of yellow the same fit CLs for the 2HDM truth benchmark Asimov data set. These latter fits illustrate a scenario in which NP is present, but is analyzed with an incomplete or incorrect set of NP Wilson coefficients. Depending on the set of coefficients, we see from the \(\varDelta \chi ^2\) of the best fit points that the new physics might be obfuscated or wrongly identified. This underlines the importance for LHCb and Belle II to eventually carry out an analysis in the full multi-dimensional space of Wilson coefficients, spanned by the operators listed in Table 1.

3 The Hammer library

In this section we present core interface features and calculational strategies of the Hammer library. Details of the code structure, implementation, and use, can be found in the Hammer manual [40]; here we provide only an overview.

3.1 Reweighting

We consider an MC event sample, comprising a set of events indexed by I, with weights \(w_I\) and truth-level kinematics \(\{q\}_I\). Reweighting this sample from an ‘old’ to a ‘new’ theory requires the truth-level computation of the ratio of the differential rates

$$\begin{aligned} r_I = \frac{ d \varGamma ^{\text {new}}_I/d \mathcal {PS}}{d \varGamma ^{\text {old}}_I/d \mathcal {PS}}\,, \end{aligned}$$
(3)

applied event-by-event via the mapping \(w_I \mapsto r_I w_I\). The ‘old’ or ‘input’ or ‘denominator’ theory is typically the SM plus (where relevant) a hadronic model — that is, a form factor (FF) parametrization. (It may also be composed of pure phase space (PS) elements, see App. A.2.) The ‘new’ or ‘output’ or ‘numerator’ theory may involve NP beyond the Standard Model, or a different hadronic model, or both.

Historically, the primary focus of the library is reweighting of \(b \rightarrow c\ell \nu \) semileptonic processes, often in multistep cascades such as \(B \rightarrow D^{(*,**)}(\rightarrow DY)\, \tau (\rightarrow X\nu ) \bar{\nu }\). However, the library’s computational structure is designed to be generalized beyond these processes, and we therefore frame the following discussion in general terms, before returning to the specific case of semileptonic decays.

3.2 New Physics generalizations

The Hammer library is designed for the reweighting of processes via theories of the form

$$\begin{aligned} \mathcal {L} = \sum _\alpha c_\alpha \, \mathcal {O}_\alpha \,. \end{aligned}$$
(4)

where \(\mathcal {O}_\alpha \) are a basis of operators, and \(c_\alpha \), are SM or NP Wilson coefficients (defined at a fixed physical scale; mixing of the Wilson coefficients under RG evolution, if relevant, must be accounted for externally to the library). We specify in Table 1 the conventions used for various \(b \rightarrow c\ell \nu \) four-Fermi operators and other processes included in the library.

The corresponding process amplitudes may be expressed as linear combinations \(c_\alpha \mathcal {A}_\alpha \). They may also be further expressed as a linear sum with respect to a basis of form factors, \(F_i\), that encode the physics of hadronic transitions (if any).Footnote 3 In general, then, an amplitude may be written in the form

$$\begin{aligned} \mathcal {M}^{\{s\}}\big (\{q\}\big ) = \sum _{\alpha , i} c_\alpha \, F_i\big (\{q\}\big ) \, \mathcal {A}^{\{s\}}_{\alpha i}\big (\{q\}\big )\,, \end{aligned}$$
(6)

in which \(\{s\}\) are a set of external quantum numbers and \(\{q\}\) the set of four-momenta.Footnote 4 The object \(\mathcal {A}_{\alpha i}\) is an NP- and FF-generalized amplitude tensor. In the case of cascades, relevant for \(B \rightarrow D^{(*,**)}(\rightarrow DY)\, \tau (\rightarrow X\nu ) \bar{\nu }\) decays, the amplitude tensor may itself be the product of several subamplitudes, summed over several sets of internal quantum numbers. The corresponding polarized differential rate

$$\begin{aligned} \frac{d\varGamma ^{\{s\}}}{d\mathcal {PS}}&= \!\! \sum _{\alpha , i, \beta , j} \!\! c_\alpha c_\beta ^\dagger \, F_i F_j^\dagger \!\big (\{q\}\big ) \, \mathcal {A}^{\{s\}}_{\alpha i}\mathcal {A}^{\dagger \{s\}}_{\beta j}\!\big (\{q\}\big ) \,, \nonumber \\&= \!\! \sum _{\alpha , i, \beta , j} \!\! c_\alpha c_\beta ^\dagger \, F_i F_j^\dagger \!\big (\{q\}\big ) \,\mathcal {W}_{\alpha i \beta j}\,, \end{aligned}$$
(7)

in which the phase space differential form \(d\mathcal {PS}\) includes on-shell \(\delta \)-functions and geometric or combinatoric factors, as appropriate.

The outer product of the amplitude tensor, defined as \(\mathcal {W} \equiv \mathcal {A} \mathcal {A}^\dagger \), is a weight tensor. The object \(\sum _{ij} F_i F_j^\dagger \mathcal {W}_{\alpha i \beta j}\) in Eq. (7) is independent of the Wilson coefficients: Once this object is computed for a specific \(\{q\}\) – an event – it can be contracted with any choice of NP to generate an event weight. Similarly, on a patch of phase space \(\varOmega \) — e.g., the acceptance of a detector or a bin of a histogram — the marginal rate can now be written as

$$\begin{aligned} \varGamma ^{\{s\}}_{\varOmega } = \sum _{\alpha , \beta } c_\alpha c_\beta ^\dagger \int _\varOmega d\mathcal {PS}\, \sum _{ij} F_i F_j^\dagger \big (\{q\}\big ) \mathcal {W}^{\{s\}}_{\alpha i \beta j} \big (\{q\}\big )\,. \end{aligned}$$
(8)

The Wilson coefficients factor out of the phase space integral, so that the integral itself generates a NP-generalized tensor. After it is computed once, it can be contracted with any choice of NP Wilson coefficients, \(c_\alpha \), thereafter.

The core of Hammer ’s computational philosophy is based on the observation that this contraction is computationally much more efficient than the initial computation (and integration). Hence efficient reweighting is achieved by

  • Computing NP (and/or FF, see below) generalized objects, and storing them;

  • Contracting them thereafter for any given NP (and/or FF) choice to quickly generate a desired NP (and/or FF) weight.

Table 3 Presently implemented amplitudes in the Hammer library, and corresponding form factor parametrizations. SM-only parametrizations are indicated by a \(*\) superscript. Form factor parametrizations that include linearized variations are denoted with a \(\ddagger \) superscript. These are named in the library by adding a “Var” suffix, e.g. “BGLVar

3.3 Form factor generalizations

Similarly to the NP Wilson coefficients, it is often desirable to be able to vary the FF parameterizations themselves. This can be achieved directly within Hammer by adjusting the choice of FF parameter values for any given parametrization. However, because the impacts of the form-factors depend on the kinematics of an event, they cannot be factored out of the phase-space integral in Eq. (8). Full reweighting to a different choice of form-factor parameters therefore requires full recalculation of each event weight on the phase space patch.

Instead, one might contemplate linearized variations with respect to the FF parameters, that commute with the phase space integration: For instance, variations around a (best-fit) point along the error eigenbasis of a fit to the FF parameters; or FF parametrizations that are linearized with respect to a basis of parameters, such as the BGL parametrization [43,44,45] in \(B \rightarrow D^{(*)} \ell \nu \). To this end, an FF parametrization with a parameter set \(\{\mu \}\) can be linearized around a (best-fit) point, \(\{\mu ^0\}\) so that

$$\begin{aligned} F_{i}\big (\{q\}; \{\mu \}\big ) = F_i\big (\{q\}, \{\mu ^0\}\big ) + \sum _{a} F'_{i,a}\big (\{q\}, \{\mu ^0\}\big )\,e_a\,, \end{aligned}$$
(9)

where ‘a’ is one or more variational indices and \(e_{a}\) is the variation. In the language of the error eigenbasis case, \(F'_{i,a}\) is the perturbation of \(F_i\) in the ath principal component \(e_{a}\) of the parametric fit covariance matrix.

Defining \(\xi _a \equiv (1, e_a)\) and \(\varPhi _{i,a+1} \equiv (F_{i}, F'_{i,a})\), so that Eq. (9) becomes

$$\begin{aligned} \sum _{a} \xi _a \varPhi _{i,a} = F_{i} + \sum _{a'} F'_{i,a'}\,e_{a'}\,, \end{aligned}$$
(10)

then the differential rate

$$\begin{aligned} \frac{d\varGamma ^{\{s\}}}{d\mathcal {PS}}= & {} \!\! \sum _{\alpha , a, \beta , b} \!\! c_\alpha c_\beta ^\dagger \xi _a \xi ^\dagger _b \mathcal {U}^{\{s\}}_{\alpha a \beta b}\,, \nonumber \\ \mathcal {U}^{\{s\}}_{\alpha a \beta b}\equiv & {} \sum _{ij} \varPhi _{i,a} \varPhi _{j,b}^\dagger \big (\{q\}\big ) \mathcal {W}^{\{s\}}_{\alpha i \beta _j} \big (\{q\}\big )\,, \end{aligned}$$
(11)

with \(\mathcal {U}\) an NP- and FF-generalized weight tensor. The \(\xi _a\) are independent of \(\{q\}\) and factor out of any phase space integral just as the Wilson coefficients do. That is, an integral on any phase space patch,

$$\begin{aligned} \varGamma ^{\{s\}}_{\varOmega } = \sum _{\alpha , \beta , a, b} c_\alpha c_\beta ^\dagger \xi _a \xi ^\dagger _b \int _\varOmega d\mathcal {PS}\,\, \mathcal {U}^{\{s\}}_{\alpha a \beta b}\,. \end{aligned}$$
(12)

One may thus tensorialize the amplitude with respect to Wilson coefficients and/or FF linearized variations, to be contracted later with with NP or FF variation choices (the latter within the regime of validity of the FF linearization). Hereafter, the \(\xi _a\) are referred to as ‘FF uncertainties’ or ‘FF eigenvectors’ following the nominal fit correlation matrix example.

3.4 Rates

In certain cases, it is also useful to compute and fold in an overall ratio of rates \(\varGamma ^{\text {old}}/\varGamma ^{\text {new}}\), or the rates themselves, \(\varGamma ^{\text {new}, \text {old}}\), may be required. For example, if the MC sample has been initially generated with a fixed overall branching ratio, \(\mathcal {B}_{\text {new}}\), one might wish to enforce this constraint via an additional multiplicative factor \(\mathcal {B}_{\text {old}}/\mathcal {B}_{\text {new}}\).

The different components computed by Hammer are then:

  1. (i)

    The NP- and/or FF-generalized tensor for \((d \varGamma ^{\text {new}}_I/d \mathcal {PS}) / (d \varGamma ^{\text {old}}_I/d \mathcal {PS})\), via Eq. (11), noting that the denominator carries no free NP or FF variational index. (The ratio \(r_I\) is then itself generally at least a rank-2 tensor.);

  2. (ii)

    The NP- and/or FF-generalized rate tensors \(\varGamma ^{\text {old, new}}\), which need be computed only once for an entire sample. (These rates require integration over the phase space, which is achieved by a dedicated multidimensional Gaussian quadrature integrator.)

3.5 Primary code functionalities

The calculational core of Hammer computes the NP or FF generalized tensors event-by-event for any process known to the library (see Table 3 for a list), and as specified by initialization choices (more detail is provided in Sect. 3.6) and specified form factor parametrizations. This core is supplemented by a wide array of functionalities to permit manipulation the resulting NP- and FF-generalized weight tensors as needed. This may include binning — equivalent to integrating on a phase space patch — the weight tensors into a histogram of any desired reconstructed observables, and/or it may include folding of detector simulation smearings, etc. Such histograms have NP- and FF-generalized tensors as bin entries, and we therefore call them generalized or tensor histograms. Once such NP- and FF-generalized tensor objects are computed and stored, contraction with NP or FF eigenvector choices permits the library to efficiently generate actual event weights or histogram bin weights for any theory of interest.

The architecture of Hammer is designed around several primary functionalities:

  1. 1.

    Provide an interface to determine which processes are to be reweighed, and which (possibly multiple) schemes for form factor parametrizations are to be used. This includes handling for (sub)processes that were generated as pure phase space, and the ability to change the values of the form factor parameters.

  2. 2.

    Parse events into cascades of amplitudes known to the library, and compute their corresponding NP- and/or FF-generalized amplitude or weight tensor, as well as the respective rate tensors, as needed.

  3. 3.

    Provide an interface to generate histograms (of arbitrary dimension), and bin the event weight tensors — i.e., \(r_I w_I\), as in Eq. (3) — into these histograms, as instructed. This includes functionality for weight-squared statistical errors, functionality for generation of ROOT histograms, as well as extensive internal architecture for efficient memory usage.

  4. 4.

    Efficiently contract generalized weight tensors or bin entries against specific FF variational or NP choices, to generate an event or bin weight. This includes extensive internal architecture to balance speed versus memory requirements.

  5. 5.

    Provide interface to save and reload amplitude or weight tensors or generalized histograms, to permit quick reprocessing into weights from precomputed or ‘initialized’ tensor objects.

Examples of the implementation of these functionalities are shown in many examples provided with the source code.

3.6 Code flow

A Hammer program may have two different types of structure: An initialization program, so called as it runs on MC as input, and may generate Hammer format files; or an analysis program, which may reprocess histograms or event weights that have already been saved in an initialization run. Pertinent details of the elements of the application programming interface mentioned below are provided in Appendix A, with more details in the Hammer manual.

An initialization program has the generic flow:

  1. 1.

    Create a Hammer object.

  2. 2.

    Declare included or forbidden processes, via and .

  3. 3.

    Declare form factor schemes, via and .

  4. 4.

    (Optional) Add histograms, via .

  5. 5.

    (Optional) Declare the MC units, via .

  6. 6.

    Initialize the Hammer class members with .

  7. 7.

    (Optional) Change FF default parameter settings with , or (if not SM) declare the Wilson coefficients for the input MC via .

  8. 8.

    (Optional) Fix Wilson coefficient (Wilson coefficient and/or FF uncertainty) choice to special choices in weight calculations (histogram binnings), via ( and/or ).

  9. 9.

    Each event may contain multiple processes, e.g., a signal and tag B decay. Looping over the events:

    1. (a)

      Initialize event with . For each process in the event:

      1. i.

        Create a Hammer object.

      2. ii.

        Add particles and decay vertices to create a process tree, via and .

      3. iii.

        Decide whether to include or exclude processes from an event via and/or .

    2. (b)

      Compute or obtain event observables – specific particles can be extracted with or other programmatic means – and specify the corresponding histogram bins to be filled via .

    3. (c)

      Initialize and compute the process amplitudes and weight tensors for included processes in the event, and fill histograms with event tensor weights – the direct product of include process tensor weights – via .

    4. (d)

      (Optional) Save the weight tensors for each event, with to a buffer.

  10. 10.

    (Optional) Generate histograms with and/or save them with . NP choices are implemented with , FF variations are set with .

  11. 11.

    (Optional) Save the rate tensors, with to a buffer.

  12. 12.

    (Optional) Save an autogenerated bibTeX list of references used in the run with .

By contrast, an analysis program (from a previously initialized sample, stored in a buffer) has the generic flow:

  1. 1.

    Create a Hammer object and specify the input file.

  2. 2.

    Load or merge the run header — include or forbid specifications, FF schemes, or histograms — with (after ). One may further declare additional histograms to be compiled (from saved event weight data) via .

  3. 3.

    (Optional) Load or merge saved histograms with , and/or generate desired histograms with . NP choices are implemented with .

  4. 4.

    (Optional) Looping over the events:

    1. (a)

      Initialize event with .

    2. (b)

      If desired, remove processes from an event with .

    3. (c)

      Reload event weights with .

    4. (d)

      Specify histograms to be filled via .

    5. (e)

      Fill histograms with event weights via .

4 Conclusions

Precision measurements of \(b\rightarrow c \tau \bar{\nu }\) decays require large Monte Carlo samples, which incorporate detailed simulations of detector responses and physics backgrounds. The limited statistics due to the computational cost of these simulations are often a leading systematic uncertainty in the measurements, and it is prohibitively expensive to generate fully simulated MC samples for arbitrary NP models or descriptions of hadronic matrix elements.

In this paper we described the Hammer library, and illustrated its utility. Hammer allows the fast and efficient reweighting of existing SM (or phase-space based) MC samples to arbitrary NP models. In addition, Hammer can be used to change form factor parametrizations and/or incorporate uncertainties from form factors into experimental measurements. Hammer provides a computationally fast way for binned fits to generate predictions, and we implement a demonstrative forward-folding fit to constrain NP Wilson coefficients using this feature. Such a fit should be carried out by experimental collaborations in future measurements to provide reliable constraints on NP contributions in semileptonic \(b\rightarrow c \tau \bar{\nu }\) decays. The results will allow people outside the collaborations to make correct interpretations of the data, which has not been possible to date without potentially sizeable biases. To demonstrate this latter point, we carried out toy NP analyses using SM fits to NP Asimov data sets, and showed that sizeable biases can indeed occur. Hammer is open source software and we are looking forward to the experimental results and interpretations it will enable.