class TreeReader(IReader): """ Read data from a TTree ROOT class inside a ROOT TFile. data is each entry of the TTree """ def __init__(self,fname,tname): """ Read data from a TTree ROOT class inside a ROOT TFile. data is each entry of the TTree """ IReader.__init__(self,fname) self.tname = tname self.tfile = None self.ttree = None self.rtree = None return def eof(self): """ end of file """ return (self.rtree.ientry >= self.rtree.nentries) def open(self): """ open the file, get the tree """ self.tfile = TFile(self.fname) self.ttree = self.tfile.Get(self.tname) self.rtree = RTree(self.ttree) #print 'TFile Reader ',self.tfile return def read(self): """ read and returns the next entry of the tree as a dictionary """ data = self.rtree.getentry() return data def close(self): """ close the file """ self.tfile.Close() return