Virtual branches in TTree?

Hi,

Imagine you have two quantities a and b in a TTree, and you would like to draw a+b. That’s straightforward to do.

But one can imagine more complicated formulas, and also one can imagine that a person who reads the TTree doesn’t know which formula is to be used. In that case, it would be nice if a virtual branch could be stored in the TTree which contains the formula, so that you can draw c to obtain a+b.

The way I mean this is like views in relational database systems, such that the value of c is not stored in the tree, but computed on the fly.

Does such functionality exist?

Thanks,
Peter

I believe that TTree::SetAlias would suit your purposes.

http://root.cern.ch/root/html/TTree.html#TTree:SetAlias

HI,

Thanks, that looks promising. It also appears that the alias definitions are stored when the TTree is written. Very good! :slight_smile:

When doing Scan("*"), the aliases don’t appear. Is it possible to change that, or will I have to write my own Scan method to do that?

Thanks,
Peter