【问题标题】:How to read branches in pyroot and make plots?如何读取 pyroot 中的分支并制作绘图?
【发布时间】:2015-03-26 19:02:22
【问题描述】:

我对 Python 和 pyroot 完全陌生,我想在 pyroot 中编写一个小脚本作为练习。我的根文件有一个子目录,您可以在其中找到一些树,其中一些包含一些分支。我想做的是绘制变量图。假设分支是 tree1 中的 x、y、z,并且想要绘制 x 与 z 的图。 example.root-->sub_dir-->tree3,tree2,tree1-->x,y,z 等

这是我目前所拥有但不起作用的:

#!/usr/bin/env python
import ROOT
c1=ROOT.TCanvas("mycanvas","mycanvas",600,600)
c1.SetGrid( )
f=ROOT.TFile("example.root/sub_dir")
t=f.Get("tree1")
t.Draw("x:z")

希望我能澄清一下。

【问题讨论】:

    标签: python branch pyroot


    【解决方案1】:

    我认为example.root/sub_dir 不是TFile(它是文件中的目录)。

    所以我会改成

    f=ROOT.TFile("example.root")
    t=f.Get("subdir/tree1")
    

    这对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      • 2021-11-10
      • 2016-12-13
      • 2012-04-02
      • 2012-03-17
      相关资源
      最近更新 更多