TF1 with member function of C++ class


I have defined my own interpolation classes and want to use them with TF1 (primarily for plotting). I followed the examples on the page: as shown below.

Instead of having a member function called Evaluate, I overloaded the () operator. However, when I try the example example as shown below (simply replacing Evaluate with operator()) I am getting compile errors. I wanted to verify that this method is correct in order to user a member function with TF1.

Below, I copy the information from the ROOT web page:

E - A member function with parameters of a general C++ class

A TF1 can be created in this case from any member function of a class which has the signature of (double * , double *) and returning a double.

class MyFunction {

double Evaluate() (double *x, double *p) {
// function implementation

MyFunction * fptr = new MyFunction(…); // create the user function class
TF1 * f = new TF1(“f”,fptr,&MyFunction::Evaluate,0,1,npar,“MyFunction”,“Evaluate”); // create TF1 class.



If your member function is the operator() (double *x, double *p), you can use the mode “D” as described in

for creating the TF1. If it does not work, please post your code fragment