Dear all,
I am developing a c++ code using ROOT to fit a graph with a function. I created a TF1 from a C++ function object (functor) with parameters. Therefore, I coded a C++ class implementing this member function:
class MyFunctionObject : public ClassA {
public:
// use constructor to customize your function object
MyFunctionObject(double D, double E, double F)
{
//ctor
fD = D;
fE = E;
fF = F;
}
double operator() (double *x, double *p) {
// function implementation using class data members
}
};
However, I want the class MyFunctionObject to inherit some parameters set in the constructor of the ClassA.
ClassA::ClassA(double A, double B, double C)
{
//ctor
fA = A; //fA, fB and fC are protected
fB = B;
fC = C;
}
How should I do the get these parameters values? The function to fit the graph looks like this:
const double *ClassA::GetFitParameters(const double *EstimVals, float *X, float *Y)
{
const double *xs=new double[9];
//some code here
MyFunctionObject fobj(....); // create the function object
TF1 * f = new TF1("f",fobj,xmin,xmax,npar); // create TF1 class with n-parameters and range [xmin,xmax]
//some code do the fit
return xs;
}
Regards,
Daniel
ROOT Version: 6.22
Platform: Linux
Compiler: g++