Tutorial illustrating how creating a TF1 class using functor or class member functions
can be run with:
root > .x exampleFunctor.C
root > .x exampleFunctor.C+ with ACLIC
double MyFunc (double *x, double *p ) {
}
struct MyDerivFunc {
MyDerivFunc(
TF1 * f): fFunc(f) {}
return fFunc->Derivative(*x);
}
};
struct MyIntegFunc {
MyIntegFunc(
TF1 * f): fFunc(f) {}
double Integral (double *x, double * ) const {
double a = fFunc->GetXmin();
return fFunc->Integral(a, *x);
}
};
void exampleFunctor() {
double xmin = -10; double xmax = 10;
TF1 * f1 =
new TF1(
"f1",MyFunc,xmin,xmax,2);
MyDerivFunc * deriv = new MyDerivFunc(f1);
TF1 * f2 =
new TF1(
"f2",deriv, xmin, xmax, 0);
MyIntegFunc * intg = new MyIntegFunc(f1);
TF1 * f3 =
new TF1(
"f3",intg,&MyIntegFunc::Integral, xmin, xmax, 0);
}
- Author
- Lorenzo Moneta
Definition in file exampleFunctor.C.