Why does this bug occur during Fit fitting

  void plot102() {
  TFile * f = new TFile("spectra.root");
  TCanvas * c = new TCanvas("C","distri",100,100,1600,1200);
  c->DrawFrame(0,0,140,2.5);
  c->SetGrid();
  TH1F * h = (TH1F *)f->Get("h1000");
  TH1F * h1 = (TH1F *)f->Get("h1001");
  TH1F * h102 = new TH1F("h102","C distribution",150,0,150);
  h102->Divide(h1,h);
  h102->SetLineColor(kWhite);
  h102->SetMarkerStyle(20);
  h102->SetMarkerSize(1);
  h102->SetMarkerColor(kBlue);
  h102->Draw("same");
  TF1 * func = new TF1("func","1 + [0] * exp(-x * x * [1] * [1]/(0.1973 * 0.1973))",0,150);
  func->SetParNames("lamda","Radius");
  func->SetParameters(1,5);
  h102->Fit(func,"r");
  c->Print("fig102.jpg");
}

This is the image that will come out


I want to know why it hasn’t been fitted out yet

Dear Sun,

Welcome to the ROOT community.
It is hard to say, your model is not fitting well your data. Perhaps try to change the range in which you are fitting to accommodate your function, which looks like a Gaussian?

Best,
D

Dear Danilo,

Yes, this is half a Gaussian function.
I’ve tried changing the fitting parameters, but it fails. I get the same result and graph. Do you know why "Invaild Fitresult (status = 2) " appears in general? Or what is the meaning of " status = 2 " ?

Best,
S

Hi,

status=2 means that the Hessian is invalid. This is likely caused by the fact that the points closer to 0 have a very large spread. Do you have an uncertainty in the point that you can use for fitting ? If not, maybe you should average neighbouring points (e.g. using a TProfile class) before fitting ?

Lorenzo