Roofit specific: goodness of fit value

Hello,

This question is specific to the roofit modeling toolkit. I would like to compare the goodness of fit of two different composite model PDF’s to data.

I have found examples of how to print a plot of the NLL distribution or to print a summary of the fit results, but is there some way to extract one value for each fit that can be used for this purpose? Could anyone provide a snippet of code to show how it can be done?

Best regards,
Anna

PS Sorry if this sounds like a dumb question, I’m an undergraduate just trying to get started!

Hi,

You can do one of the following two things:

  1. Make sure you save a RooFitResult object of your fit, e.g.

using namespace RooFit ;
RooFitResult* r = pdf.fitTo(*data,Save(kTRUE),Minos(kFALSE)) ;
cout << "nll = " << r->minNll() << endl ;

  1. Alternatively construct the -log(L) explicitly and do the fit through the
    RooMinuit interface.

    RooNLLVar nll(“nll”,“nll”,pdf,data) ;
    RooMinuit m(nll) ;
    m.migrad() ;
    m.hesse() ;

    and query the likelihood valye from nll, which is a regular RooFit function
    object

    cout << " nll = " << nll.getVal() << endl ;

Wouter