Aliases with array branches

Hi all,

I have a TTree with several array branches, and I’d like to make aliases out of them.
Say I have two array branches px and py, I define a pT alias as:


This new variable works fine if I want to sum over it. This is

T->Scan("Sum$(pt)") T->Scan("Sum$(sqrt(px**2+py**2))")

give identical results. But it doesn’t work if I want to access individual values:

T->Scan("pt[3]") T->Scan("sqrt(px[3]**2+py[3]**2)")

The former gives the error message

How should I define the alias so it is equivalent to “(px[3]^2+py[3]^2)” instead?



[quote]How should I define the alias so it is equivalent to “(px[3]^2+py[3]^2)” instead?[/quote]This is currently not supported. Aliases are (for now) uses strictly as string replacements. However this is indeed a very useful use case and we will keep in mind when redesign TTreeFormula to use cling (just in time C++ compilation rather than ad-hoc interpretation).