Dear all,
I’m using the following code to create a TTree in a *.root file.
[code]import ROOT
from ROOT import *
import numpy
f = ROOT.TFile(“datatree.root”,“RECREATE”)
m = numpy.array([0.,0.,0.,0.,0.])
for part in [‘detector_A’,‘detector_B’,‘detector_C’,‘detector_D’]:
tree = ROOT.TTree(part,"%s PARTITION"%part)
for mod in range(1,65):
branch = tree.Branch(part+"_m%02i"%mod,m,“channel/D:time/D:constant/D:constant_db/D:deviation/D”)
tree.Write()
del tree
f.Close()
[/code]
Now, I should be able to fill the tree by doing the following.
f = ROOT.TFile("datatree.root","UPDATE")
tree = f.Get("detector_A")
m = numpy.array([2.,0.,2.,0.,2.])
branch = tree.Branch("detector_A_m10",m,"channel/D:time/D:constant/D:constant_db/D:deviation/D")
branch.Fill()
tree.Write()
f.Write()
f.Close()
However, it seems my “data” [2,0,2,0,2] is not stored in the tree, when I inspect it with the TBrowser. Why does it not work?
Any help is most welcomed,
Marco