Hello,
I’ve maybe a trivial problem, but I’m not able to solve it…
I’m trying to fit a TGraphError with a user-defined function, but the fit seems to not work.
Here is a part of my code:
Double_t func(Double_t *x, Double_t *par)
{
Double_t result=0;
result=(par[2]/(x[0]-par[3]))+par[0] + par[1]*x[0];
return(result);
}
and then in the main function I have:
Double_t range_min=0;
TF1 *f1=new TF1(“f1”,func,range_min,17000,4);
TGraphErrors *gr=new TGraphErrors(npicchi,min,t,smin,dt);
gr->Fit(“f1”,“R”);
and I always get something like this:
FCN=0 FROM MIGRAD STATUS=CONVERGED 171 CALLS 172 TOTAL
EDM=0 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 100.0 per cent
EXT PARAMETER APPROXIMATE STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 0.00000e+00 1.41421e+00 0.00000e+00 0.00000e+00
2 p1 0.00000e+00 1.41421e+00 0.00000e+00 0.00000e+00
3 p2 0.00000e+00 1.41421e+00 0.00000e+00 0.00000e+00
4 p3 0.00000e+00 1.41421e+00 0.00000e+00 0.00000e+00
even if I simply define a linear function as a user-defined function.
Where am I wrong?
Thanks a lot for your help
Cheers
Paola