Using GSLMultiFit for the Fitter

I am trying to perform a 3D fit using nonlinear least squares. I used the example3Dfit.C in tutorials as the base method for the fit, but am having trouble switching my Minimizer.

My main problem is with the following section:

ROOT::Fit::BinData data(n,3);
double xx[3];
for(int i = 0; i < n; ++i) {
xx[0] = R[i];
xx[1] = Phi[i];
xx[2] = z[i];
data.Add(xx, Bmeas[i], ev);
}
TF3 * f3 = new TF3(“f3”,bfield_fit,0,6.28,0,.07,zpos,zbinend,5);
f3->SetParameters(guess[0],guess[1],guess[2],guess[3],guess[4]);

ROOT::Fit::Fitter fitter;
ROOT::Math::WrappedMultiTF1 wf(*f3,3);
fitter.Config().SetMinimizer(“GSLMultiFit”);
fitter.SetFunction(wf);

bool ret = fitter.Fit(data,wf);

When I try to run this fit, I get the error

Error in ROOT::Math::GSLNLSMinimizer::Minimize: Function has not been set

I have tried to set the minimizer function (which I assume I want to be my fit function, the wf referenced above) by using

ROOT::Math::GSLNLSMinimizer test;
test.SetFunction(wf);

and looking through the ROOT:TMath::MinimizerOptions by doing

ROOT:TMath::MinimizerOptions opt

and using opt.Print() and setting the minimizer via opt.SetMinimizer(). None of these affect the error output. I’m confused as to why setting my minimizer in fitter.Config().SetMinimizer() doesn’t affect the opt.Print() and why I cannot set a function for my minimizer.

Any help would be appreciated! Thanks in advance.

@moneta can you please help here?

Thank you very much in advance,
Oksana.