Dear ROOT experts,
I am trying to fill a TTree in a pyroot function.
I have found the nice recommendations of the page root.cern/doc/v628/classTTree.html
I tried the basic pyroot example and it works out of the box.
But, when trying to do this in a function, I am facing segmentation-violation crashes.
I tried by passing the tree as argument:
#! /usr/bin/env python
###############################################
import array
from ROOT import TTree
###############################################
def fill_tree(tree):
n = array.array('f', [ 1.5 ])
tree.Branch('floatb', n, 'floatb/F')
tree.Fill()
return
tree = TTree("tree", "tree")
fill_tree(tree)
tree.Print()
tree.Scan()
or considering the tree as the result of the function:
#! /usr/bin/env python
###############################################
import array
from ROOT import TTree
###############################################
def fill_tree():
tree = TTree("tree", "tree")
n = array.array('f', [ 1.5 ])
tree.Branch('floatb', n, 'floatb/F')
tree.Fill()
return tree
t = fill_tree()
t.Print()
t.Scan()
Do I miss something?
Thanks for your help,
Benjamin
ROOT Version: 6.22.06
Platform: CC IN2P3