TTree::SetAlias with TMath::Min, TMath::Max issue

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

@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.

@pcanal still waiting for your wisdom here :slight_smile:

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

See also https://github.com/root-project/root/pull/3797

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.