# TChain of multiple TTree with different alias formulas

I have a few TTrees (in separate TFile’s) that contain aliases. The alias formula changes from TFile to TFile, but the alias name remains the same. It appears that formula this is not entirely carried over if I try to TChain each of these trees together.

e.g.
TTree #1 in TFile=“file1.root”:

``T->SetAlias("blah","branch1*1.0+branch2*2.0");``

TTree #2 in TFile=“file2.root”:

``T->SetAlias("blah","branch1*1.5-branch2*2.5");``

Now chain the two trees together…

``````TChain *ch = new TChain("T");

Drawing blah from the TChain, ends up using just the first alias that I defined in TTree #1.

Hmph. Is the only solution to get rid of the aliases all together and just define a new TBranch using the alias formula, when I fill each TTree?

I’d rather use aliases because it allows me to check the formula used in each TTree…

Hi,

This sounds indeed like a nice feature. To implement this, one would need to rework the TTree::Draw mechanism. Currently the Formula is compiled only once (this is a slow operation) at the start of the query. We would need to introduce a check and possible recompilation after each file has been loaded. …
So this is a good idea but might take some time to get implemented.

Cheers,
Philippe.