36 f =
TFile(
'staff.root',
'RECREATE' )
37 tree =
TTree(
'T',
'staff data from ascii file' )
38 tree.Branch(
'staff', staff,
'Category/I:Flag:Age:Service:Children:Grade:Step:Hrweek:Cost' )
39 tree.Branch(
'Divisions', AddressOf( staff,
'Division' ),
'Division/C' )
40 tree.Branch(
'Nation', AddressOf( staff,
'Nation' ),
'Nation/C' )
43 fname = os.path.join(os.path.dirname(__file__),
'../tree/cernstaff.dat')
44 for line
in open(fname).readlines():
45 t = filter(
lambda x: x, re.split(
'\s+', line ) )
46 staff.Category = int(t[0])
47 staff.Flag = int(t[1])
49 staff.Service = int(t[3])
50 staff.Children = int(t[4])
51 staff.Grade = int(t[5])
52 staff.Step = int(t[6])
53 staff.Hrweek = int(t[7])
54 staff.Cost = int(t[8])
64 if __name__ ==
'__main__':
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
A TTree object has a header with a name and a title.
def fillTree
a C/C++ structure is required, to allow memory based access