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.
0.0112590789795
5.15563011169
opening file /mnt/vdb/lsf/workspace/root-makedoc-v608/rootspi/rdoc/src/v6-08-00-patches.build/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.