Build ROOT Ntuple from other source.
This program reads the `aptuple.txt' file row by row, then creates the Ntuple by adding row by row.
opening file /builddir/build/BUILD/root-6.10.00/documentation/doxygen/../../builddir/tutorials/pyroot/aptuple.txt ...
writing file aptuple.root ...
done
3 from ROOT
import TFile, TNtuple
6 ifn = os.path.expandvars(
"${ROOTSYS}/tutorials/pyroot/aptuple.txt")
9 print 'opening file', ifn,
'...'
10 infile =
open( ifn,
'r' )
11 lines = infile.readlines()
13 labels = string.split( lines[1] )
15 print 'writing file', ofn,
'...'
16 outfile = TFile( ofn,
'RECREATE',
'ROOT file with an NTuple' )
17 ntuple =
TNtuple(
'ntuple', title, string.join( labels,
':') )
19 for line
in lines[2:]:
20 words = string.split( line )
21 row = map( float, words )
22 apply( ntuple.Fill, row )
- Author
- Wim Lavrijsen
Definition in file mrt.py.