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