RooFit fails to fit dataset from file

Dear RooFit Experts,
I’m having some difficulties as I try to to fit a simple gaussian on data contained in a dataset contained previously in a TFile. The data seems correct, and the RooPlot of it gives a correct distribution. If I try to fit a Gaussian on it, I get a segmentation fault. You can find in attachement the file data.root containing the RooDataSet, and the test.C program/class executable with .x test.C+

Thanks for any help.

Cheers.

S Poss.
test.C (3.68 KB)
data.root (13.5 KB)

Hi,

The problem is clarified by this error message that you should have gotten just before the crash.

[#0] ERROR:InputArguments – RooAbsOptTestStatistic: ERROR maximum of FUNC variable mass is smaller than that of mass in the dataset

(The formatting of the message may be slightly different depending on the ROOT/RooFit version you use)

This means that have have a RooDataSet that defines an observable m[a,b] that you try to fit to a p.d.f F(m,params) where m has a different range[a’,b’] that is larger than [a,b],
which make the fit an ill-defined operation as you’ll have no data in the area b-b’ while
the p.d.f does predict a finite probability for events there. You can fix this by adjusting
the range of your observable m in your p.d.f definition.

Note that the reverse (an observable range defined in the p.d.f that is smaller than that of the daya) is allowed: in that case only the subset of the data that is in the observable range specified by the p.d.f is fitted.

Wouter

Hi Wouter,
What you suggest is indeed what happens… Thanks for the tip. But now I would like to know how I can change the limits of my observables to cope with what is stored in the dataset ? I’ve tryed this :

data = (RooDataSet*)f->Get("data"); double m_massmin, m_massmax; data->getRange(*m,m_massmin,m_massmax); m->setMin(m_massmin); m->setMax(m_massmax);
but it still does not work… Did I miss something ?

Thanks for the help.

Cheers.

S Poss

Hi,

RooDataSet::getRange() retrieves the actual range of observable values for a given observable in the dataset, it doesn’t give you the allowed range of any observable value in the dataset, which is generally different (and always wider). What you want to do is

RooAbsData* d ;
RooRealVar * dataVar = (d->get()->find(var->GetName()) ;
pdfVar->setMin(dataVar->getMin()) ;
pdfVar->setMax(dataVar->getMax()) ;

Wouter