How to create a Tree in a file?

I want to create a Tree in a new file, but now I only can create the new file and there is no tree in this file,like this:
image
This is my main code:

TFile fout("nin.root","recreate");
TTree tree("tree","p");
tree.Branch("tof1",&tof1,"tof1/F");//and other branches
for(i=0;i<events;i++)
{
  tree.Fill();
}
fout.Close();

I don’t know where’s the problem.

You have to Write the tree to the file (e.g. tree.Write();), or Write the file itself (e.g. fout.Write();); see examples here.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.