14from ROOT
import TFile, TNtuple
17ifn = os.path.expandvars(
"${ROOTSYS}/tutorials/pyroot/aptuple.txt")
20print 'opening file', ifn,
'...'
21infile =
open( ifn,
'r' )
22lines = infile.readlines()
24labels = string.split( lines[1] )
26print 'writing file', ofn,
'...'
27outfile =
TFile( ofn,
'RECREATE',
'ROOT file with an NTuple' )
28ntuple =
TNtuple(
'ntuple', title, string.join( labels,
':') )
31 words = string.split( line )
32 row = map( float, words )
33 apply( ntuple.Fill, row )
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
A simple TTree restricted to a list of float variables only.