Logo ROOT   6.10/00
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Namespaces
mrt.py File Reference

Namespaces

 mrt
 

Detailed Description

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
1 
2 import sys, string, os
3 from ROOT import TFile, TNtuple
4 
5 
6 ifn = os.path.expandvars("${ROOTSYS}/tutorials/pyroot/aptuple.txt")
7 ofn = 'aptuple.root'
8 
9 print 'opening file', ifn, '...'
10 infile = open( ifn, 'r' )
11 lines = infile.readlines()
12 title = lines[0]
13 labels = string.split( lines[1] )
14 
15 print 'writing file', ofn, '...'
16 outfile = TFile( ofn, 'RECREATE', 'ROOT file with an NTuple' )
17 ntuple = TNtuple( 'ntuple', title, string.join( labels, ':') )
18 
19 for line in lines[2:]:
20  words = string.split( line )
21  row = map( float, words )
22  apply( ntuple.Fill, row )
23 
24 outfile.Write()
25 
26 print 'done'
Author
Wim Lavrijsen

Definition in file mrt.py.