from ctypes import c_double, c_int
from ROOT import TFile, TTree,TCanvas
guan = TFile("guan.root", "recreate")
ming = TTree("ming", "This is my first tree")
i = c_int(1)
a = c_double(2.2)
b = c_double(0.0)
ming.Branch("i", i, "i/I") # "i" 为分支的名称,i为地址(c_int本身就是地址),"i/I"为i的类型
ming.Branch("a", a, "a/D")
ming.Branch("b", a, "b/D")
for j in range(100):
i = j
a = i * 0.1
b = a * a * 9
ming.Fill()
ming.Write()
ming.Scan()
C++ code
TFile *guan = new TFile("guan1.root","recreate");
TTree *ming = new TTree("ming", "This is my first tree");
int i = 1;
double a = 2.2;
double b = 0.0;
ming->Branch("i",&i,"i/I");
ming->Branch("a",&a,"a/D");
ming->Branch("b",&a,"b/D");
for(int j=0;j<100;j++){
i=j;
a=(double)i*0.1;
b=a*a/3;
ming->Fill();
}
ming->Write();
ming->Scan()
As you can see, I use the Scan function in both pyroot code and C++ code, but I found that connecting jupyter lab in wsl with vscode in windows will cause a stuck state, have you ever encountered it? If you do, I hope you can tell me how to solve it.
This only allows you to view the root file generated by python, not C++. Here is the root file generated by c++.
guan.root is generated by pyroot, guan1.root is generated by C++.
analy.zip
pyroot code
C++ code
As you can see, I use the Scan function in both pyroot code and C++ code, but I found that connecting jupyter lab in wsl with vscode in windows will cause a stuck state, have you ever encountered it? If you do, I hope you can tell me how to solve it.