首页 > 解决方案 > 与 root_numpy 相比,uproot 中 TTreeMethods.array 的性能较慢

问题描述

我正在使用 root_numpy / uproot 来处理一个 ROOT 文件(包含大约 800 万个事件)。我知道 uproot 只有在大 Tbasket 大小的情况下才能快速,但是,我正在查看一个 TBasket 大小约为 50kB 的分支,并且要读取分支,uproot 需要 70 秒,而 root_numpy 只需要 45 秒,这令人费解,因为我希望完全相反。有没有人对这里出了什么问题以及我该如何解决有任何建议?

这是我的根目录代码:

ttree = uproot.open(file)["TTree"]
array = ttree.array("Branch")

这是我的 root_numpy 代码:

tfile = ROOT.TFile(file,"OLD")
ttree = tfile.Get("TTree")
array = root_numpy.tree2array(ttree,branches="Branch")

标签: uproot

解决方案


推荐阅读