问题描述
我正在尝试编写 PyROOT 宏来打开 TTree 并从中读取数据,但该树包含一些特定于我的协作框架的类。
我加载树并尝试像这样读取数据:
mctree = mcfile.Get("MC")
totevents=mctree.GetEntries()
for event in mctree:
print event.PVeto.TMCVEvent.fHits.fChannelId
如果我不手动包含任何依赖项,则会出现错误:
TypeError: requested class 'ROOT::TPVetoMCEvent' does not exist
所以我包含了定义 TPVetoMCEvent
的类,以及这个类所依赖的类 (MCVRootIO
),但最终我得到了错误:
RuntimeError: (file "include/MCVRootIO.hh",line 11) cannot open file "globals.hh"
我试过了
ROOT.gInterpreter.ProcessLine('#include "/cvmfs/geant4.cern.ch/geant4/10.3.ref01/x86_64-slc6-gcc49-opt/include/Geant4/globals.hh"')
但它仍然给我同样的错误。
完整代码为:
ROOT.gInterpreter.ProcessLine('#include "/cvmfs/geant4.cern.ch/geant4/10.3.ref01/x86_64-slc6-gcc49-opt/include/Geant4/globals.hh"')
ROOT.gInterpreter.ProcessLine('#include "include/MCVRootIO.hh"')
ROOT.gSystem.Load('src/MCVRootIO.cc')
ROOT.gInterpreter.ProcessLine('#include "PVeto/include/PVetoRootIO.hh"')
ROOT.gSystem.Load('PVeto/src/PVetoRootIO.cc')
#get TTree from file
mcfile = TFile("MCData.root")
mctree = mcfile.Get("MC")
totevents=mctree.GetEntries()
for event in mctree:
print event.PVeto.TMCVEvent.fHits.fChannelId
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)