读取文件,查看链接:Treehttps://mp.csdn.net/mp_blog/creation/editor/130395443
TTree *tree = 0;
TFile *f = TFile::Open("test.root","READ");
f->GetObject("T",tree);
newtree = tree->CloneTree();
newtree->Print();
newtree->Scan("");
float x1,x2,y1,y2;
newtree->SetBranchAddress("x", &x1);
newtree->SetBranchAddress("y", &y1);
newtree->Branch("x2", &x2);
newtree->Branch("y2", &y2);
for (int i = 0; i< 10000; i++)
{
newtree->GetEntry(i);
x2 = x1 * x1;
y2 = y1 * y1;
newtree->GetBranch("x2")->Fill();
newtree->GetBranch("y2")->Fill();
}
newtree->Print();
newtree->Scan("");