Hello,
I am trying to use ROOT::Fit::PoissonLLFunction to fit some low statistics histograms. Using directly TH1::Fit is not an options since I need to do a combined (simultaneous) fit of many of such histograms. However, I must be attempting to use ROOT::Fit::PoissonLLFunction not correctly, since I get too large errors (by a factor of ~1.5); while if I use TH1::Fit (on a single histogram), the results look reasonable.
Here is a simplified example of how I use ROOT::Fit::PoissonLLFunction (a full macro is attached as well):
// h1 is a histogram with 100 events with Gaus(2,20) distribution
// f1 is a Gaus function
// xMin = -100.0, xMax = +100.0
ROOT::Fit::Fitter fitter;
const int nPar = f1->GetNpar();
fitter.Config().SetParamsSettings(nPar, f1->GetParameters());
fitter.Config().ParSettings(0).SetLimits(0.0, 20.0*nEvents);
fitter.Config().ParSettings(1).SetLimits(xMin, xMax);
fitter.Config().ParSettings(2).SetLimits(xMin, xMax);
fitter.Config().MinimizerOptions().SetPrintLevel(2);
fitter.Config().SetMinimizer("Minuit2", "Migrad");
TF1 * fitFun = new TF1("fitFun", Gaus, xMin, xMax, nFitFunPar);
ROOT::Math::WrappedMultiTF1 * wf = new ROOT::Math::WrappedMultiTF1(*fitFun, 1);
ROOT::Fit::DataOptions opt;
opt.fUseEmpty = true;
ROOT::Fit::DataRange range;
range.SetRange(xMin, xMax);
ROOT::Fit::BinData * data = new ROOT::Fit::BinData(opt, range);
ROOT::Fit::FillData(*data, h1);
const bool chi2Fit = false;
ROOT::Math::FitMethodFunction * localFitFun = new ROOT::Fit::PoissonLLFunction(*data, *wf);
// also tried to set explicitly weight=0/1 and extended=true/false
fitter.FitFCN(fitter.Config().NPar(), *localFitFun, 0, data->Size(), chi2Fit);
const ROOT::Fit::FitResult result = fitter.Result();
result.Print(cout);
I would really appreciate if somebody could help me to understand how to use PoissonLLFunction correctly.
Thank you,
Siarhei.
TestPLLFit.C (4.06 KB)