Number of events in multiple (independent) ranges

I am trying to modify rf204_extrangefit.C so that I can view the number of events of the background pdf in two separate ranges (independently from each other). I’ve tried to “doubly extend” a pdf with multiple nBck parameters, but the fitting goes crazy. i.e.

RooExtendPdf esig("esig","extended signal p.d.f",sig,nsig,"signalRange") ;

  RooExtendPdf ebkg1("ebkg1","extended background p.d.f",bkg,nbkg,"signalRange") ;

  RooExtendPdf ebkg("ebkg","extended background p.d.f",ebkg1,nbkgB,"bkgRange") ;


RooAddPdf  model("model","(g1+g2)+a",RooArgList(ebkg,esig)) ;

Where I would like to find the number of background events in the bkgRange and the number of background events in the signalRange, but not the summation of the two (this is just an example, in general I would like to be able to find the number of background events in n ranges, where the sum of the ranges does not necessarily span the entire fitting area).

I’ve tried to directly use integration, but this gets tricky with the errors. Thanks for any help!


You cannot extend a pdf twice, this also doesn’t map a well defined concept in statistics.

For what you want, I think the direct integration method, is the simplest wayo to do what you want. If you use ROOT 5.26, you can make use of automatic error propagation, so that doesn’t be tricky.

What you should do is that you first fit the pdf to the data and save the fit results

RooFitResult* r = model.fitTo(data,Save()) ;

Then you define the fraction integral you are interested in

RooAbsReal* fracRange = bkg.createIntegral(x,x,“myRange”) ;

Then you can get the fraction and its error as follows

Double_t f = fracRange->getVal() ;
Double_t ferr = fracRange->getPropagatedError(*r) ;


thanks so much, worked great!