Simple fit of an histogram: no convergence?

Dear all,

I do a simple fit of an histogram with three MC-based pdf

See the code below…

  // == Build pdf out of histograms
  int nbin;
  float start, end;
    nbin = 101;
    start = -5;
    end = 500;

  TH1F* hZtautau = new TH1F( "hZtautau", "", nbin, start, end );
  TH1F* hZmumu = new TH1F( "hZmumu", "", nbin, start, end );
  TH1F* hHiggs = new TH1F( "hHiggs", "", nbin, start, end );
// == Filling histo..
...

// == Converting histos to pdf
  RooRealVar massVar ( "massVar", "", start, end );
  RooDataHist* dZtautau = new RooDataHist( "dZtautau", "", RooArgList( massVar ), hZtautau, 1. );
  RooDataHist* dZmumu = new RooDataHist( "dZmumu", "", RooArgList( massVar ), hZmumu, 1. );
  RooDataHist* dHiggs = new RooDataHist( "dHiggs", "", RooArgList( massVar ), hHiggs, 1. );
  RooHistPdf* pdf_Ztautau = new RooHistPdf ( "pdf_Ztautau", "", RooArgSet( massVar ), *dZtautau, 0 );
  RooHistPdf* pdf_Zmumu = new RooHistPdf ( "pdf_Zmumu", "", RooArgSet( massVar ), *dZmumu, 0 );
  RooHistPdf* pdf_Higgs = new RooHistPdf ( "pdf_Higgs", "", RooArgSet( massVar ), *dHiggs, 0 );

// == Total pdf with 3 arguments (events yields)
  RooRealVar n_Ztautau ( "n_Ztautau", "", hZtautau->Integral(), -100., 10000. );
  RooRealVar n_Zmumu ( "n_Zmumu", "", hZmumu->Integral(),-100., 10000. );
  RooRealVar n_Higgs ( "n_Higgs", "", hHiggs->Integral(),-100., 10000. );
  RooAddPdf* pdf_tot = 
    new RooAddPdf( "pdf_tot", "", RooArgList(*pdf_Ztautau, *pdf_Zmumu, *pdf_Higgs), RooArgList(n_Ztautau, n_Zmumu, n_Higgs) );

  // == Retrieve dataset
  TH1F* hAll = new TH1F( "hAll", "", nbin, start, end );
  BuildHist( hAll, var, "all", mass );
  RooDataHist* dAll = new RooDataHist( "dAll", "", RooArgList( massVar ), hAll, 1. );

  // == Fit the dataset
//   n_Ztautau.setConstant();
//   n_Zmumu.setConstant();
  pdf_tot->fitTo( *dAll, SumW2Error(kFALSE) );

// == Plot everybody
  TCanvas* c1 = new TCanvas( "c1", "", 800, 800 );
  RooPlot* frame1 = massVar.frame();

  c1->cd();
  frame1->Draw();
  dAll->plotOn( frame1 );
  pdf_tot->plotOn( frame1 );
  pdf_tot->plotOn( frame1, RooFit::Components(*pdf_Ztautau), RooFit::LineColor(8) );
  pdf_tot->plotOn( frame1, RooFit::Components(*pdf_Zmumu), RooFit::LineColor(6) );
  pdf_tot->plotOn( frame1, RooFit::Components(*pdf_Higgs), RooFit::LineColor(2) );
  frame1->Draw();

  cout << " >>>> Truth... " << endl;
  cout << "n_Ztautau = " <<  hZtautau->Integral() << endl;
  cout << "n_Zmumu = " << hZmumu->Integral() << endl;
  cout << "n_Higgs = " << hHiggs->Integral() << endl;
  cout << " >>>> Fitted... " << endl;
  cout << "n_Ztautau = " << n_Ztautau.getVal() << " +-  " << n_Ztautau.getError() << endl;
  cout << "n_Zmumu = " << n_Zmumu.getVal()  << " +-  " << n_Zmumu.getError() << endl;
  cout << "n_Higgs = " << n_Higgs.getVal()  << " +-  " << n_Higgs.getError() << endl;
  cout << " >>>> Chi2... " << endl;
  cout << frame1->chiSquare(3) << endl;

The output of the fit is
iktp.tu-dresden.de/~prudent/Divers/plot.log

There is obviously something going wrong, the uncertainties on the fit parameters in particular make non sense. It looks like the fit does not converge.
My guess is that these warnings are caused by bins with null content, can that be ? Would there then be a way to bypass that ?

Thanks in advance,
Cheers,

Xavier

Dear Xavier,

This is typical of cases where the PDF evaluates to zero (or negative) while there is a non-zero observation at the same place (for example in a binned fit for a binned model/dataset). The reason doesn’t seem to be due to a parameter of the model in your case but I’d assume that in one bin of the Histograms the entry is zero and there is one or more event in data in this bin. That’s one problem with binned fits when you don’t have a complete control of the histogram templates. How do you handle your templates? Extracted from data? Smoothed one way or another? How do you deal with statistical (data or MC) uncertainties on the templates?

Cheers,

– Gregory