- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我刚刚开始使用 pyroot 读取根文件,但无法使用 jupyter 笔记本从文件中读取数据。 TBrowser 的外观如下:
我是这样开始的:
import ROOT as root
import numpy as np
f = root.TFile("RealData.root")
myTree = f.Get("tree")
entries = myTree.GetEntriesFast()
到目前为止,它正在工作,如果我打印条目,我会得到文件中正确的完整数量。但我不知道如何从树中读取实际数据(event_number、n_channels 等)。如果我尝试类似 myTree.events
或 myTree.event_number
内核停止工作。我应该怎么做才能从树中读取数据?
最佳答案
通常使用 pyROOT,您可以执行以下操作:
import ROOT as root
import numpy as np
f = root.TFile("RealData.root")
myTree = f.Get("tree")
for entry in myTree:
# Now you have acess to the leaves/branches of each entry in the tree, e.g.
events = entry.events
我对 jupyter 的工作原理了解不够,不知道这是否会导致任何特定问题。您是否尝试过仅使用常规 python 解释器运行相同的脚本?
关于python - 使用 PyRoot 读取根中的 TTree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38819098/
在我的 ROOT 脚本中,我创建了一个 TTree,但我不想保存它。确保 TTree 永远不会保存到 TFile 的最佳方法是什么? 我曾想过为每棵我创建但不需要保存的树创建一个TFile,但感觉应该
我刚刚开始使用 pyroot 读取根文件,但无法使用 jupyter 笔记本从文件中读取数据。 TBrowser 的外观如下: 我是这样开始的: import ROOT as root import
我正在使用 CERN 的 pyROOT 模块做一些工作,我正在尝试将字符串数组存储为二叉树中的叶子。为此,我必须向它传递一个数组,显然,使用的不是列表或字典,而是数组模块。该模块支持标准 C 数组、字
在 PyROOT 中,很容易从树中读取值,即打印叶子 val : file = TFile('file.root') tree = file.Get('tree') for entry in tree
我正在尝试使用 python 简单地定义一个 Root TTree 并给它一个 TBranch。听起来很合理,对吧?我试过: from ROOT import * myvar = int() mytr
我正在尝试从 Cern ROOT TTree 文件中读取数据。我以前没有使用过 root,为此我有点挣扎。我熟悉 C++,因此可以对事物的数组方面进行排序,但我已经在线浏览了几个教程页面,但一无所获。
我正在尝试通过 python 创建一个在根部有分支的树。我有一个 .root 文件,我正在尝试创建分支,这些分支是我的 .root 文件的变量(或数据点)。这是我的尝试: f = ROOT.TFile
将字符串保存到 TTree 之后 std::string fProjNameIn, fProjNameOut; TTree *tTShowerHeader; tTShowerHeader = new
代码应该读取一棵已创建的树,复制其分支名称并为小于或等于 0 的条目记录 0,为所有其他条目记录 1。代码很好地复制了分支,但是当要用它填充的信息填充它们时,每个分支将包含它之前所有分支的所有信息。因
我是编程和 ROOT (CERN) 的新手,所以请放轻松。简单地说,我想将 ~900 MB(11M 行 x 10 列).csv 文件转换为组织良好的 .root TTree。有人可以提供解决此问题的最
我正在尝试使用 pyROOT 在 python 中为 TTree(一个 ROOT 对象)制作过滤器.我从具有多个分支的 TTree 获取信息,其中一些是 C++ 类型 vector , vector或
我是一名优秀的程序员,十分优秀!