我想创建类来处理TTree:
from ROOT import *
from Exceptions import *
import os.path
class NTupleHandler:
def __init__(self, fileName, eventType):
if not os.path.isfile(fileName):
raise InputError( fileName)
f = TFile(fileName, 'read')
if f is None:
raise InputError("openError"+fileName)
dir=f.Get(eventType)
if dir is None:
raise InputError("directory Error"+eventType)
tree=dir.Get('particle')
self.tree=tree
self.tree.GetEntriesFast()
print
def getEntry(self):
return self.tree.GetEntriesFast()
但调用函数getEntry i时发生错误:
^{pr2}$如何强迫python记住NtupleHandler.tree?在
如果您想在Python环境中使用根类,那么最好使用rootpy而不是pyroot。在rootpy中,包含树的根文件已经用PyTables转换成HDF5格式。看看你想要的是不是rootpy。在
相关问题 更多 >
编程相关推荐