2 Build ROOT Ntuple from other source.
3 This program reads the `aptuple.txt' file row by row, then creates
4 the Ntuple by adding row by row.
8 from ROOT
import TFile, TNtuple
14 print 'opening file', ifn,
'...'
15 infile =
open(
'aptuple.txt',
'r' )
16 lines = infile.readlines()
18 labels = string.split( lines[1] )
20 print 'writing file', ofn,
'...'
21 outfile = TFile( ofn,
'RECREATE',
'ROOT file with an NTuple' )
22 ntuple = TNtuple(
'ntuple', title, string.join( labels,
':') )
24 for line
in lines[2:]:
25 words = string.split( line )
26 row = map( float, words )
27 apply( ntuple.Fill, row )