Hi,
I’ve been trying for a while to create a TFormula out of a user defined TF1 and so far I’ve come up empty, so I was wondering if there was some way to do it. I’ve managed to create the TF1, both via a lambda expression and via a functor. The two ways are copied below
TF1 *F1 = new TF1(“f”, [&](double* x, double* p){return -potencial.Derivative(x[0]);},xmin,xmax,1);
double Evaluate(double *x, double <em>p){
Spline3Interpolator potencial(ngrid,grid,pot_el);
return -potencial.Derivative(x[0]);
}
PIC Myfunc = this;
TF1 *F1 = new TF1(“f”,Myfunc,&PIC::Evaluate,xmin,xmax,0,“PIC”,“Evaluate”);
Above, PIC is a custom class, potential is a class object and Derivative is a class method.
Both the expressions above, when I evaluate, for example, F1->Eval(1), return the correct value.
How can I proceed to convert this TF1 into a TFormula? Everything I tried resulted in either “Segmentation Violation” or “Error in TFormula::Eval: Formula is invalid and not ready to execute”.
Thank you in advance