ROOT gets stuck during fitting a user defined function


I’ve the problem that ROOT sometimes get’s stuck when fitting with my user defined function which contains a numeric integration and looks like this:

[code]Double_t resonance(Double_t *y,Double_t par)
Double_t crosss = 0, lambda;
Double_t vf = 0;
if (par[0] != 0)
lambda = (y[0] - 2
par[0]) / par[1]; //y[0]=sqrt(s)
vf = sqrt(par[0] * par[1]); //par[0]=mr,par[1]=gamma

  static TF1 *f = new TF1("f","sqrt(([2] - 2 * [0]) / [1] - x) / ( x * x + 1)");
  crosss = f->Integral(-1000,lambda);
  crosss = par[2]*crosss * vf / TMath::Pi()+par[3];
  //cout <<lambda<<endl;

return crosss;

Is there a way to tell ROOT to interrupt the fit procedure after a particular number of iterations or something like that?
I know this might not be the smartest way to implement the function… does somebody have a better idea instead of using a TF1 for integration? In principle it even gets worse, cause I need this function convoluted with a Gaussian in addition. That would add another integration… and then fitting really gets slow!

Can somebody help me on this?

Regards and thanks,

Could you send the shortest possible RUNNING script reproducing this problem?


Hi Rene!

I attached the script which I run with ROOT 5.12/00. Whether the fit gets stuck or not strongly depends on the parameter values N and B. Usually it stucks more often when B>N. Actually I don’t know whether there really is an endless loop or I would have to wait much longer.

The last printout on screen is something like:

1 m_{R} 2.31814e+03 6.95443e+02 no limits
2 #Gamma_{R} 6.33272e-01 1.89982e-01 no limits
3 A 2.12923e+00 6.38769e-01 no limits
4 BG 9.19519e+02 2.75856e+02 no limits

** 5 **SET PRINT 0

** 6 **MIGRAD 5000 0.011

and this takes forever.

Cheers and thanks,
testcross.C (1.26 KB)