0

我正在尝试编写一个 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

树的结构如下: 树形结构

4

0 回答 0