//From TFormula
if (strcmp(name,"x")==0 || strcmp(name,"y")==0 ||
strcmp(name,"z")==0 || strcmp(name,"t")==0 )
{
Error("TFormula","The name \'%s\' is reserved as a TFormula variable name.\n"
"\tThis function will not be registered in the list of functions",name);
} else {
gROOT->GetListOfFunctions()->Add(this);
}
And because of how TFormula::ProcessLinear is implemented.
If I understand the code correctly, for expression with ++, original expression
a ++ b
is parsed into parts and for “sub-expressions” ‘a’ and ‘b’ two TFormula’s with names ‘a’ and ‘b’ are created, so, if you have, 1 ++ x TFormulas with a names ‘1’ and ‘x’ are created. The second is a wrong name.
So, this is simply wrong syntax in your expression?
[quote=“tpochep”]Because of these lines in a TFormula ctor:
//From TFormula
if (strcmp(name,"x")==0 || strcmp(name,"y")==0 ||
strcmp(name,"z")==0 || strcmp(name,"t")==0 )
{
Error("TFormula","The name \'%s\' is reserved as a TFormula variable name.\n"
"\tThis function will not be registered in the list of functions",name);
} else {
gROOT->GetListOfFunctions()->Add(this);
}
And because of how TFormula::ProcessLinear is implemented.
If I understand the code correctly, for expression with ++, original expression
a ++ b
is parsed into parts and for “sub-expressions” ‘a’ and ‘b’ two TFormula’s with names ‘a’ and ‘b’ are created, so, if you have, 1 ++ x TFormulas with a names ‘1’ and ‘x’ are created. The second is a wrong name.
So, this is simply wrong syntax in your expression?[/quote]
It’s not a wrong syntax, I want to use a function like [0] + [1] * x +[2](- 1./(xx)) with linear fitter. If I look at the documentation (root.cern.ch/root/html/TGraph.html#TGraph:Fit):
Example: to fit the parameters of "[0]*x + [1]*sin(x)", create a
TF1 *f1=new TF1("f1", "x++sin(x)", xmin, xmax);
I got the same problem. Apart of the error message it seems to works.
Ah, ok, I agree. In fact, this is not a problem in your case - simply annoying message and the TFormula for sub-expression ‘x’ is not added into the global list of functions.