TFormula with TF1 from Functor

Hi, I have some C++ functor class with a method that can be used to create a TF1. For example:

  TF1 mytff("mytf1",myinterpolator,&MyInterpolator::Eval,-0.69,0.69,0,"MyInterpolator","Eval");

However I am unable to later use the name “mytf1” to create combined functions (say I wanted to subtract two of these). I get this error:

TF1 f3("f3","2*mytf1",-0.69,0.69)
Error in <TFormula::Compile>:  Empty String
Error in <TF1::TF1>: function: f3/2*mytf1 has 0 parameters instead of 1

When I try simple tests with built-in TFormula expressions (like sin(x), cos(x)), everything works as expected. Is there some peculiarity about TF1s built from functors? I noticed that mytf1.GetTitle() returns an empty string, and apparently fTitle is important for TF1s, is that where the problem lies? I would like to be able to do some mathematical operations with mytf1 and its friends to create new TF1s.

Jean-François

Hi,

It is possible to combines TF1 using their name (as in your example), only if they are built using formula expressions (TFormula).
The solution is to make a new functor object using the previous created TF1

Best Regards

Lorenzo