Hello

I’m trying to run a complex fit using RooFit, but I’m running into severe performance problems.

I have two samples using the same fit model structure, with the only difference being that in one of the samples the range of a variable (x in the example below) is reduced (due to acceptance there are no events there).

The core of the model is essentially (in pseudocode):

```
pdf_sig = RooProdPdf([pdf_sx(sx), pdf_m(m), pdf_physics(x, a | sx, m), <other>])
pdf_bkg = RooProdPdf([<various bkg pdf>])
fit_model = RooAddPdf([pdf_sig, pdf_bkg], [N_sig, N_bkg])
```

The fit completes fine in the full range sample, but when ran on the limited range sample it seems to be extremely slow.

In the logs I see mentions of numerical integrals:

```
[#1] INFO:NumericIntegration -- RooRealIntegral::init(SUBPROD_pdf_sx_NORM[sx]_X_pdf_physics_Int[a,x|NormalizationRangeFor<subrange>]_Norm[a,x]_X_pdf_m_NORM[m]_Int[sx,m|NormalizationRangeFor<subrange>]) using numeric integrator RooAdaptiveIntegratorND to calculate Int(sx,m)
```

which may be the problem, since they probably depend on x and a and thus change at each event (and `pdf_physics`

is very much not meant to be integrated in `sx`

and `m`

, hence the numerical integral).

What are those exactly? I think they come from `RooAbsOptTestStatistics`

and are related to the `RooAddPdf`

coefficients but I’m not sure about the details.

Currently I’m fitting each sample on its own, but eventually they are supposed to go into a `RooSimultaneous`

, using `SplitRange`

.

Can anything be done to make the fit faster, possibly avoiding those integrals?