Dear experts,

I would like to know how many events Roofit used to renormalize the PDF when plotted, or I want to get directly the normalization factor. I don’t know how to get this information, and I explain below the case I am dealing with, which is not trivial.

I have a simple TDCPV example, using a `RooBCPGenDecay`

to model the signal, and a simple gaussian for the background. I combined them using `RooAddPdf`

:

```
# Background PDF
mgBkg = r.RooRealVar("mgBkgB", "mg", 0)
sgBkg = r.RooRealVar("sgBkg1", "sg2", 4.3)
bkgPDF = r.RooGaussian("bkgPDF", "gauss", dt, mgBkg, sgBkg)
# BCPGenDecay model
BCPGenDecayPDF = r.RooBCPGenDecay("BCPGenDecayPDF", "BCPGenDecayPDF", dt, q, tau, dm, w, Agen, Sgen, dw, effR, signalRes, r.RooBCPGenDecay.DoubleSided)
# Combined PDF
combinedPDF = r.RooAddPdf("combinedPDF", "combinedPDF", r.RooArgList(BCPGenDecayPDF, bkgPDF), r.RooArgList(fsig))
```

Now, I generate from this combination 100000 events, which depend on the flavor `q`

(a category, `B0`

or `B0bar`

):

```
nevents = 100000
data_set = combinedPDF.generate(r.RooArgSet(dt, q), nevents)
```

and then I only plot the `B0`

category:

```
frame = dt.frame(nbins)
data_set.plotOn(frame, Cut="q==q::B0", MarkerColor=r.kBlue)
combinedPDF.plotOn(frame, Slice=(q, "B0"), Components="BCPGenDecayPDF", LineStyle=r.kDashed, LineColor=r.kGreen)
combinedPDF.plotOn(frame, Slice=(q, "B0"), Components="bkgPDF", LineStyle=r.kDashed, LineColor=r.kRed)
```

Now, the renormalization used by the `Slice`

method of `plotOn`

is trivial for the gaussian background component, but not for the CP asymmetry part.

For the background component, which doesn’t depend on the flavor, I get the correct normalization value with:

```
q.setLabel("B0")
xlim = (dt.getMin(), dt.getMax())
x = np.linspace(*xlim, 10000)
for i in range(len(x)):
var.setVal(x[i])
bkgPDF.getVal(var)*norm
```

with

```
norm = n_expected_events_for_bkgPDF * bin_width / bkgPDF_integral
= (n_B0_events * (1 - f_sig)) * bin_width / 1
= (nevents/2 * (1 - f_sig)) * bin_width / 1
```

This was tested and works wonderfully.

For `BCPGenDecayPDF`

, this is not trivial, as we don’t have

```
n_expected_events_for_BCPGenDecayPDF = nevents/2 * f_sig
```

The dependencies on the miss-tagging `w`

, the asymmetry parameters `A`

and `S`

or the misstag rate `dw`

makes `n_expected_events_for_BCPGenDecayPDF`

go a bit higher or lower. All those parameters are fixed before using the same method to get the correct values for the gaussian background, and somehow it is always a bit off by a factor between 0.8 and 1.1 from my tests.

I tried to get information on normalization using `combinedPDF.getComponents()`

, or I tried to get information of the `RooPlot`

output when I plot `BCPGenDecayPDF`

(`plot.getHist(plot.nameOf(1))`

returns a null pointer, or `plot.getFitRangeNEvt()`

returns 10000) without any success.

Any suggestions on how to get this correct normalization factor?

Best regards