Roofit normalization

Dear All,

I’m asking roofit to retrieve the normalization of a RooGaussian after a fit.
Everything seems ok but, if I perform a simple integral on the same histogram in the same interval I got a number that is half of the one from roofit. Clearly I’m doing a mistake somewhere…

  1. My Macro (attached) run with the command:
    .x Total_fit.C(“comp_epsilonPlots.root”,“allEpsilon_EBnw”,false,true,true)
    and it does:
    a) create a PDF:
    RooAddPdf model1(“model”,“sig+bkg”,RooArgList(gaus,bkg),RooArgList(Nsig,Nbkg));
    a) after the fit create a Range
    x.setRange(“sobRange”,mean.getVal()-2.*sigma.getVal(), mean.getVal()+2.sigma.getVal());
    [#1] INFO:Eval – RooRealVar::setRange(x) new range named ‘sobRange’ created with bounds [0.104727,0.14857]
    b) and integrate:
    integralSig = gaus.createIntegral(x,NormSet(x),Range(“sobRange”));
    and the Number of events should be: integralSig->getVal()*Nsig.getVal())
    That is 0.954507 * 312218 = 298014

!! If I do the itegral in the same range manually:
root [5] allEpsilon_EBnw->FindBin(0.104727)
(Int_t) 51
root [6] allEpsilon_EBnw->FindBin(0.14857)
(Int_t) 72
root [7] allEpsilon_EBnw->Integral(51,72)
(Double_t) 1.263420e+05
The value is very different from: 298014

The input file is attached.

Thanks a lot,
Total_fit.C (9.66 KB)

Can you please attach your input file or add a link to your file, so we can run your macro to reproduce this problem



Here you can find the input file: … .root?dl=0
As I said it run with:
.x Total_fit.C(“comp_epsilonPlots.root”,“allEpsilon_EBnw”,false,true,true)
Please let me know If I have to add some more details.

Thanks a lot,

Hi Luca,

Thanks for the file. I could reproduce the problem. It is clear the reported number of entries from the fit seems to be wrong. I have tried with a simple ROOT Fit and I get the right number of Nsig and Nbkg.
I will investigate it

Best Regards



Thank you for the file. I could reproduce this problem and I will investigate it. I have tried a simple ROOT fit and I get the correct number of entries. So, there are some problems with the returned values from the fit.



Thanks a lot,
I wait for some news!

Thanks again,

rHi ,

The poblem is in the way you build your NLL. If you want to fit for the normalisation you need to add the Extended option:

RooNLLVar nll("nll","log likelihood var",*model,dh, RooFit::Extended(true));

otherwise the number of signal events is not fitted. You are fitting only the shape of the distributions and you are getting an arbitrary number.

I would suggest to create in the future the NLL directly from the pdf, by doing

RooAbsReal * nll = model->createNLL(dh);

In this way the NLL is automatically built with the NLL option

Best Regards


Thanks a lot!!