Dear experts
I am observing some odd behaviour using TMath::Min/TMath::Max function in Alias definition.
The minimal reproduction of it is to take any TTree (or TChain)
and do something like this
tree->SetAlias("MyForm" , "TMath::Min(A,B)")
tree->Draw("MyForm")
doing so throws :
Error in <TTreeFormula::DefinedVariable>: The substitution of the alias "MyForm" by "TMath::Min(A,B)" failed.
Altough if i do the direct Draw it works.
A fall back is :
tree->SetAlias("MyForm" , "A<B?A:B")
tree->Draw("MyForm")
and it works.
I wonder if there is anything special on the TMath::Min and TMath::Max when used via Aliases .
Thanks in advance,
Renato
_ROOT Version: 6.16.0
_Platform: Any
Compiler: Not Provided
If I try to do
SetAlias(“myForm”, “TMath::Min<Double_t>(A,B)”);
I can draw it.
I am wondering what is going on and if it is expected and how one can identify the TMath functions which needs this special treatment
Axel
May 6, 2019, 6:26am
3
@pcanal what are the limitations of an alias - does it expand as a TTreeFormula
itself?
I have found another weird behaviour.
If i do
tree->SetAlias( "cosAlpha", "TMath::Cos(alpha)")
and i do tree->Draw("xx","..... && cosAlpha>2")
it doesn’t work
If before doing the Draw i expand cosAlpha to the Alias defined it does.
Axel
May 10, 2019, 8:55am
5
@pcanal still waiting for your wisdom here
There is a deficiency in TTreeFormula related to function calls (actually to the use of paranthesis), it does not detect (yet) that this should trigger the avoidance of a shortcut in the code and this lead to use the alias value as a variable. To work around the problem you can use:
tree->SetAlias("MyForm" , "TMath::Min(A,B)+0");
Cheers,
Philippe.
1 Like
Thanks a lot,
In which root release this will be fixed?
It will be fixed in v6.18/00 (to be release soon) and could easily be backported to older release patch branches if needed.
system
Closed
May 25, 2019, 3:26pm
10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.