Hi I am starting to miograting from PAW to Root, I have a user defined function to fit histo, when I try to fit any histo root says me:
Error: ^ Illegal operator for real number FILE:ffit.C LINE:4
Error: ^ Illegal operator for real number FILE:ffit.C LINE:4
Error: operator ‘/’ divided by zero FILE:ffit.C LINE:4
I am attaching the function that I used in Paw. Can help me to translate it to root?
Thks
gauss5.txt (245 Bytes)
Hi itorres_2003,
Remember that the Fortran expression xy is in C++/Root
TMath::Power(x,y) .
By the way, regardless of language x*(x*(x+a)+b)+c is more accurate
and faster than x3+d*x**2+…
Eddy
Hi Eddy, thanks a lot for your comment.
I have translated my function as shown in the attached file, there is some thing wrong?
ffit.txt (198 Bytes)
The expression
Double_t gauss5 = 5.0par[1]TMath::Exp(-0.5x1^2/par[3]^2)/sqrt(23.1415926)*par[3]+par[4]+par[5]*x1;
should change to
Double_t gauss5 = 5.0par[1]TMath::Exp(-0.5x1x1/par[3]/par[3])/sqrt(2*3.1415926)*par[3]+par[4]+par[5]*x1;