Additional question arised:
Exploring the Roottalk forum, I found very interesting post of Moneta, where he suggested how to overcome the problem of fitting 3D function, here I copy-pasted his code:
void exampleFit3D() {
const int n = 1000;
double x[n], y[n], z[n], v[n];
double ev = 0.1;
// generate the data
TRandom2 r;
for (int i = 0; i < n; ++i) {
x[i] = r.Uniform(0,10);
y[i] = r.Uniform(0,10);
z[i] = r.Uniform(0,10);
v[i] = sin(x[i] ) + cos(y[i]) + z[i] + r.Gaus(0,ev);
}
// fill the fit data
ROOT::Fit::BinData data(n,3);
double xx[3];
for(int i = 0; i < n; ++i) {
xx[0] = x[i];
xx[1] = y[i];
xx[2] = z[i];
data.Add(xx, v[i], ev);
}
TF3 * f3 = new TF3(“f3”,"[0] * sin(x) + [1] * cos(y) + [2] * z",0,10,0,10,0,10);
f3->SetParameters(2,2,2);
ROOT::Fit::Fitter fitter;
ROOT::Math::WrappedMultiTF1 wf(*f3,3);
fitter.SetFunction(wf);
bool ret = fitter.Fit(data);
if (ret) {
ROOT::Fit::FitResult & res = fitter.Result();
res.Print(std::cout);
}
else
cout << “Fit Failed” << endl;
}
Trying to run the code, compiler returned the error:
" error C2440: ‘initializing’ : cannot convert from ‘const ROOT::Fit::FitResult’ to ‘ROOT::Fit::FitResult &’ "
I use MVS C++ 2008 express edition, Wndows 7 and 5.24 ROOT version.
I run my code on Visual Studio using the integrated ROOT libraries.
I would appreciate any suggestions,
Thanks,
Andrey.