I would like to create a new TTree based on information in an existing TTree. (I plan to add it as a friend later.) However, the created TTree ends up with 0 entries:
In [1]: import ROOT
In [2]: infile = ROOT.TFile.Open('../DVnTuples.root')
In [3]: intree = infile.Get('X2LcpLcpTree/DecayTree')
In [4]: outfile = ROOT.TFile.Open('../test.root', 'update')
In [5]: outtree = ROOT.TTree('testtree', 'testing testing 123')
In [6]: from array import array
In [7]: mytest = array('f', [0])
In [8]: mybranch = outtree.Branch('mytest', mytest, 'mytest/F')
In [9]: for ientry in xrange(intree.GetEntries()):
...: intree.GetEntry(ientry)
...: mytest[0] = intree.X_ENDVERTEX_X
...: mybranch.Fill()
...:
In [10]: outfile.cd()
Out[10]: True
In [11]: outtree.Write('', ROOT.TObject.kOverwrite)
Out[11]: 388
In [12]: outtree.GetEntries()
Out[12]: 0L
What am I doing wrong? I suspect it has something to do with telling outtree
what entry it should be on, but this is the method shown in the tutorials…
ROOT Version: 6.17/01
Platform: macOS
Compiler: Not Provided