我在做中微子研究,需要我通过叠加直方图来进行数据分析。我们正在使用根。我目前正在尝试将下面的代码从C++转换为PyRoo:
#include "TFile.h"
#include "TH1F.h"
#include "TCanvas.h"
#include "TString.h"
void myscript()
{
//get a histogram named vtx_0 from the file 5A_data
TFile* file = TFile::Open("5A_data");
TH1F* hist = file->Get("vtx_0");
TCanvas* canvas = new TCanvas("c1", "Dynamic Filling Example", 200, 10, 700,500);
hist->Draw();
}
这是我到目前为止用python重新编写的代码:
from ROOT import TFile, TH1F, TCanvas, TString
def myscript():
#get vtx_0 from 5A_data
TFile file1 = open("5A_data")
TH1F hist =
我接触过Python有限。上面的Python代码主要是通过查看各种在线示例创建的,因此我甚至不确定我目前所写的内容是否正确。
TH1F* hist = file->Get("vtx_0");
怎么做到的?在
变量声明不需要类型,下面的内容可能会让您开始:
引用:
相关问题 更多 >
编程相关推荐