1

私は 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")

明確にできることを願っています。

4

1 に答える 1

0

I think example.root/sub_dir isn't a TFile (it is a directory in a file).

So I would change it to

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

which works for me.

于 2016-04-07T15:31:09.067 に答える