RooFit: Dependence of parameter error on parameter range

Dear all,

I have a very simple problem: I fit a weighted histogram with a simple line,
but the error on the slope depends significantly on the allowed range for it.
Here is a minimal piece of code to reproduce the problem and I also attach it as problem.C file:

  double range = 1; 
  TH1::SetDefaultSumw2();
  TH1D * h_first = new TH1D("h_first", "h_first", 10, -1,1);
  TH1D * h_second = new TH1D("h_first", "h_first", 10, -1,1);
  h_first->FillRandom("pol0");
  h_second->FillRandom("pol0");
  TH1D *h_third = (TH1D*)h_first->Clone("h_third");
  h_third->Divide(h_second); 
  
  RooRealVar x("x","x",-1,1);
  RooDataHist data("data","histo", x, h_third);

  RooRealVar m("m", "m", 0, -range, range);
  RooGenericPdf f_p("f_p", "1 + m*x",RooArgSet(m, x));
  
  f_p.fitTo(data, RooFit::SumW2Error(kTRUE));
  RooPlot *xframe = x.frame();
  data.plotOn(xframe,  RooFit::Name("data")) ;
  f_p.plotOn(xframe, RooFit::Name("f_p"));
  f_p.paramOn(xframe, RooFit::Parameters(RooArgSet(m)), RooFit::Layout(0.32, 0.59,0.35));
  xframe->Draw();

Am I missing something?

Thanks in advance,

Francesco
problem.C (789 Bytes)

Update on this,

if I use, as I learned I should in this kind of fits, the Chi2 fit, the fit results are completely wrong ( see attached image).

void problem(double range = 1){
  TH1::SetDefaultSumw2();
  TH1D *h_third;

  TH1D * h_first = new TH1D("h_first", "h_first", 10, -1,1);
  TH1D * h_second = new TH1D("h_first", "h_first", 10, -1,1);
  h_first->FillRandom("pol0");
  h_second->FillRandom("pol0");
  TH1D *h_third = (TH1D*)h_first->Clone("h_third");
  h_third->Divide(h_second); 
  

  RooRealVar x("x","x",0, -1,1);
  RooDataHist data("data","histo", x, h_third);

  RooRealVar m("m", "m", 0, -range, range);

  RooPolynomial f_p("poli","poli",x,RooArgList(m),1);
  f_p.chi2FitTo(data);

  RooPlot *xframe = x.frame();
  data.plotOn(xframe,  RooFit::Name("data")) ;
  f_p.plotOn(xframe, RooFit::Name("f_p"));
  f_p.paramOn(xframe, RooFit::Parameters(RooArgSet(m)), RooFit::Layout(0.32, 0.59,0.35));
  xframe->Draw();
  cout << ">>> m = " <<  m.getVal() << " +- " << m.getError() << endl;
}

Anyone who knows if I am doing some simple mistake or is it a bug?

cheers,

Francesco
problem.pdf (15.6 KB)

Hi Francesco,
What is happening if you use just ROOT, via h->Fit(…).
When using the likelihood fit in TH1::Fit (option “L”), the errors are not correct when the histogram is weighted
(see savannah.cern.ch/bugs/?79754 ).
But in case of a chi2 fit the errors should be fine

Lorenzo

Hi Lorenzo,
thanks for your answer,
if I use the simple TH1::Fit function the fit works very well (I would be very surprised otherwise).
While with the “L” option makes the parameter errors much larger (as expected).
In fact my idea is that this is just a RooFit problem, either because I’m not very expert or because it is a bug.

Summarising there are two distinct problems:

  1. RooFit/ROOT likelihood fits calculate wrongly the parameter errors, and I understand this is a general problem of LL fits whenever you don’t apply error correction at the end.
  2. RooFit chi2 fit seems not able to fit this kind of problems, or am I missing something?

cheers,

Francesco