Error with Likelihood Fit


I’m fitting a signal histogram using two template histograms. This works fine with a chi-squared fit, but when I do a log-likelihood fit, I get an error. My code looks like:

// Function

Double_t ftotal(Double_t *x, Double_t *par) {
Double_t x0 = x[0];
Int_t bin = basis1->GetXaxis()->FindBin(x0);
Double_t trans = par[0]*basis1->GetBinContent(bin);
Double_t longit = par[1]*basis2->GetBinContent(bin);
return trans + longit;

// - Fit Signal with Linear Combination of Basis Histograms

void fithist() {

delete basis1; // - Cleanup from previous run
delete basis2;

TFile f = new TFile(“basis.root”); // - Retrieve Histograms from file
basis1 = (TH1F
basis2 = (TH1F*)f->Get(“basis2”);

TF1 *ftot = new TF1(“ftot”,ftotal,-1,1,2);

TFile *g = new TFile(“signal.root”);
TH1F signal = (TH1F)g->Get(“signal”);

signal.Fit(“ftot”,“L”); // - Fit

The error I get is within TFit. It reads "TH1F::Fit: Abnormal termination of minimization."
Is there another some way to fix this, or another method of using a log-likelihood fit to fit basis histograms to a signal histogram?


Hi Ning,

Looking at hist/src/TH1.cxx:
if (fitResult != 0) {
// Abnormal termination, MIGRAD might not have converged on a
// minimum.
if (!Foption.Quiet) {
Warning(“Fit”,“Abnormal termination of minimization.”);

So you did not converge .

You do not initialize the fit parameters at all ! You get away with it
when your objective function is a chi^2 because this results in
a linear equation that can immediately be solved

In case of using Poisson statistics, the story is different , the solution
equations become non-linear and the procedure is iterative AND
starting point matters !! . I guess that the initial parameters are
now 0 . Look at your plots and put them on something more