If this is of any help, rootpy (sitting on top of PyROOT) provides a more pythonic way of creating TTrees:
https://github.com/rootpy/rootpy
rootpy essentially hides the ugliness of using Python’s array.array everywhere for simple types and provides these type wrappers:
https://github.com/rootpy/rootpy/blob/master/rootpy/tree/treetypes.py
that all inherit from array.array but provide several pythonizations to allow treating the objects similarly to basic floats, ints, etc.
On top of this, rootpy implements a TreeModel concept that makes it easier to construct a Tree from a collection of branch types:
https://github.com/rootpy/rootpy/blob/master/examples/tree/model_simple.py
from rootpy.tree import Tree, TreeModel, FloatCol, IntCol
from rootpy.io import root_open
from random import gauss
# calls TFile.Open, but returns a File objects that subclasses TFile and adds many features:
f = root_open("test.root", "recreate")
# define the model
class Event(TreeModel):
x = FloatCol()
y = FloatCol()
z = FloatCol()
i = IntCol()
# all the SetBranchAddress/array.array ugliness is hidden away:
tree = Tree("test", model=Event)
# Tree in rootpy subclasses ROOT's TTree and adds a bunch of features to make it easier to use in Python.
# Similarly with the other subclasses in rootpy. It's still ROOT underneath :)
# fill the tree
for i in xrange(100):
tree.x = gauss(.5, 1.)
tree.y = gauss(.3, 2.)
tree.z = gauss(13., 42.)
tree.i = i
tree.fill()
tree.write()
f.close()
You can also extend this TreeModel concept to construct complex event data models by defining a class hierarchy of simple models:
https://github.com/rootpy/rootpy/blob/master/examples/tree/model_hierarchy.py
I hope this helps! rootpy is a few years old now and covers a lot of ROOT (at least the heavily used portions of it). If you are going to write serious frameworks on top of PyROOT in Python then taking advantage of the pythonizations in rootpy should save you time and headaches. Of course we wouldn’t even be using ROOT in Python without Wim’s hard work on the PyROOT bindings, so thanks to him!