Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
mrt.py File Reference

Detailed Description

View in nbviewer Open in SWAN
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 /github/home/ROOT-CI/build/tutorials/pyroot/aptuple.txt ...
writing file aptuple.root ...
done
import sys, os
from ROOT import TFile, TNtuple, TROOT
ifn = os.path.join(str(TROOT.GetTutorialDir()), 'pyroot', 'aptuple.txt')
ofn = 'aptuple.root'
print('opening file %s ...' % ifn)
infile = open( ifn, 'r' )
title = lines[0]
labels = lines[1].split()
print('writing file %s ...' % ofn)
outfile = TFile( ofn, 'RECREATE', 'ROOT file with an NTuple' )
ntuple = TNtuple( 'ntuple', title, ':'.join( labels ) )
for line in lines[2:]:
words = line.split()
row = map( float, words )
print('done')
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
A simple TTree restricted to a list of float variables only.
Definition TNtuple.h:28
Author
Wim Lavrijsen

Definition in file mrt.py.