Fit Problem

I am trying to fit some data which is sin convolved with an exponential. Here is the code that gives me a problem:

TF1 *myfit = new TF1("myfit", "[0]+[1]*exp(-[2]*t-[3])*cos([4]*t-[5])", 50, 1000); myfit->SetParName(0, "c0"); myfit->SetParName(1, "c1"); myfit->SetParName(2, "c2"); myfit->SetParName(3, "c3"); myfit->SetParName(4, "c4"); myfit->SetParName(5, "c5"); myfit->SetParameter(0, -39); myfit->SetParameter(1, 2); myfit->SetParameter(2, 1); myfit->SetParameter(3, -100); myfit->SetParameter(4, 200); myfit->SetParameter(5, 50); myfit->SetLineColor(2); myfit->SetLineWidth(1); er->Fit("myfit");

I get this error when I compile:

Error in <TF1::TF1>: function: myfit/[0]+[1]*exp(-[2]*t-[3])*cos([4]*t-[5]) has 4 parameters instead of 1 Error in <Fit>: function is zombie

Any suggestions would be greatly appreciated.

TF1 *myfit = new TF1(“myfit”, “[0]+[1]*exp(-[2]*x-[3])*cos([4]*x-[5])”, 50, 1000); // variables: x, y, z, t

Thanks! I had named my independent variable t (because I am plotting as a function of time) and didn’t realize that ROOT automatically calls it x, and that t is reserved for a TF4 with x,y,z,t.

Thanks again!

As far as I know, TFormula supports up to 4 dimensions (indicated by x, y, z, t) but no TF4 class exists.