Get integral in a range

Hi all, I am using RooFit to fit a data histogram and I want to obtain the number of signal and background events in a small range around the invariant mass peak but fit in all the range. For what I read in the documentation this should be done with .createIntegral, but I don quite understand how it works because of the normalizations.

The model that I am using is an Hypatia for the signal and polynomial for the background and it would be nice to obtain the events in a range defined by something like abs(D_M-1869.65)<20.

model = RooAddPdf("model", "model", RooArgList(Hypatia,Poly), RooArgList(nsig, nbkg))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Hi @caetano.eirea ,
sorry for the late reply, this fell through the cracks.
We need @moneta or @jonas here, let’s ping them.

Cheers,
Enrico

Hi,

assuming the variable (RooRealVar) representing your observable is x, you can use createIntegral as following (using Python)

x.setRange("subrange",xmin,xmax)  
ig = pdf.createIntegral(x,x,"subrange")
ntot = model.expectedEvents(ROOT.RooArgSet(x))  # this should be nsig+nbkg
print('number of events in range =', ig.getVal()*ntot )

Cheers

Lorenzo

Yes that seems alright, I came to the same conclusion but I got confused with how the normalization set worked in this function.

Thank you very much for the help @moneta @eguiraud.