Hello all,
I am trying to minimize a chi square function using ROOT::Math::Minimizer. The chi square function is defined in a class as the override of the () operator. This is then wrapped as a ROOT::Math::Functor. However, I keep running in to the trouble that the () operator is never actually called. I found some code in the documentation about how to do this and it shows the same problem. I have include a small example (altered a bit from the documentation) which illustrates the problem.

#include "Math/Functor.h"
#include <iostream>
class MyFunction {
public:
double operator()(const vector<double> x) const {
cout<<"Hello.\n";
return x[0]+x[1];
}
};
int function(){
// test directly calling the function object
MyFunction myf;
// test from function object
ROOT::Math::Functor f1(myf,2);
double x[] = {1,2};
cout << f1(x) << endl;
return 0;
}

When I run this I would expect the output to be:

However what I get is:

So it looks like the () operator is never called! Overwise the cout statement would appear and the correct value of 3 would be displayed. Has anyone encountered a similar issue?

On a side note, is ROOT::Math::Minimization the most up to date way to do function minimization in root?

Could it be the version of root I am running? I have version 5.28/00f. Also I check the root includes directory and Functor.h is there so I have the right root packages installed.