Non-parametric pdf fitting with roofit

Dear experts
I just have some troubles using RooHistPdf and RooAddPdf. The output shows

[#1] INFO:DataHandling -- RooDataHist::adjustBinning(hist1): fit range of variable x expanded to nearest bin boundaries: [0,10] --> [0,10]
[#1] INFO:DataHandling -- RooDataHist::adjustBinning(hist2): fit range of variable x expanded to nearest bin boundaries: [0,10] --> [0,10]
[#1] INFO:DataHandling -- RooDataHist::adjustBinning(hsum): fit range of variable x expanded to nearest bin boundaries: [0,10] --> [0,10]
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
[#1] INFO:Minization --  The following expressions have been identified as constant and will be precalculated and cached: (sum)
Error in <ROOT::Math::Fitter::SetFCN>: FCN function has zero parameters
[#0] WARNING:Minization -- RooMinimizer::hesse: Error, run Migrad before Hesse!
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:InputArguments -- RooAbsData::plotOn(hist1) INFO: dataset has non-integer weights, auto-selecting SumW2 errors instead of Poisson errors

Macro is attached
Thanks!frac.C (1.4 KB)

The problem is that the function does not have any parameters, as the error message says. This is because when you do this:

RooRealVar frac1("frac1", "frac1", 0.5);

the fraction is constant at 0.5. Use this instead to give frac a range:

RooRealVar frac1("frac1", "frac1", 0.5, 0., 2.);

Thank you! The post really helped me. One more thing concerns me is that how RooFit deals with the histograms errors of RooDataHist when the object RooHistPdf is defined. And would asymmetrical binning after averaging give any effect?

RooFit pays attention to the errors of the data.

What exactly do you mean by asymmetrical binning? Do you mean that the binning is not uniform?

Yes, I mean, binning of RooDataHist is not uniform when I create RooHistPdf. You mention “RooFit pays attention to the errors of the data”. Does it means that RooHistPdf does not consider the error of the RooDataHist?

There is a difference between errors of data (the stuff you fit to) and errors of a model (the stuff you use to fit). The error of the former is correctly taken into account, also when the data come from a RooDataHist. The error of the latter is a systematic uncertainty, and this needs to be taken into account by varying the fit model.

Non-uniform binning should not be a problem. The HistPDF takes care of normalising the bins.

1 Like

Thanks! Your reply helps me a lot!

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