18from ROOT
import TFile, TTree, addressof, gROOT
41 staff = ROOT.staff_t()
46 f =
TFile(
"staff.root",
"RECREATE")
47 tree =
TTree(
"T",
"staff data from ascii file")
48 tree.Branch(
"staff", staff,
"Category/I:Flag:Age:Service:Children:Grade:Step:Hrweek:Cost")
49 tree.Branch(
"Divisions", addressof(staff,
"Division"),
"Division/C")
50 tree.Branch(
"Nation", addressof(staff,
"Nation"),
"Nation/C")
53 fname = os.path.join(str(ROOT.gROOT.GetTutorialDir()),
"io",
"tree",
"cernstaff.dat")
54 with open(fname)
as file:
55 for line
in file.readlines():
57 staff.Category =
int(t[0])
58 staff.Flag =
int(t[1])
60 staff.Service =
int(t[3])
61 staff.Children =
int(t[4])
62 staff.Grade =
int(t[5])
63 staff.Step =
int(t[6])
64 staff.Hrweek =
int(t[7])
65 staff.Cost =
int(t[8])
78if __name__ ==
"__main__":
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
A TTree represents a columnar dataset.