TTree::SetAlias in PyROOT?

Hi, I recently made an unfortunate breaking change to some code, where some branch names in a TTree were modified slightly. In ROOT I can use TTree::SetAlias so I can access branches using the old name without complicating the code too much, but it looks like in PyROOT the aliases are not available…

In [1]: import ROOT
In [2]: f = ROOT.TFile("outfiles/20150429/run00500/correction2/Proto2Analyzed.root")
In [3]: t = f.Get("Proto2Analyzed")
In [4]: t.GetEntry(0)
Out[4]: 6147
In [5]: t.SetAlias("clu_algo_smoothing","clu_algo0_smoothing")
Out[5]: True
In [6]: t.GetEntry(0)
Out[6]: 6147
In [7]: t.clu_algo0_smoothing
Out[7]: 4
In [8]: t.clu_algo_smoothing
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-bd1d9618bf3a> in <module>()
----> 1 t.clu_algo_smoothing

AttributeError: 'TTree' object has no attribute 'clu_algo_smoothing'

In [9]: t.Scan("clu_algo0_smoothing:clu_algo_smoothing")
************************************
*    Row   * clu_algo0 * clu_algo_ *
************************************
*        0 *         4 *         4 *
...

So with Scan() the alias is valid, but in the TTree object there is no member with the alias name. This is my first time using SetAlias, so I’m not sure if I am doing this right, but is this working as intended?

Thanks,
Jean-François

Jean-François,

never heard of aliases before, and apparently they are not considered when asking for a branch (or leaf) by name directly (for good reasons, probably). Support is now in, in v5-34-00-patches and v6.

You can work around it by replacing TTree.getattr by a version that first does:attr1 = tree.GetAlias(attr) if not attr1: attr1 = attrand then calls the normal TTree.getattr (this is how it works now on the C++ side).

Cheers,
Wim