Creating new .root file to store a tree


I am trying to generate a new tree from a previous given tree, and when mid-generation I get the error:

This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
   TTree *T = new TTree(...)
   TFile *f = new TFile(...)

Which I understand occurs because my generated tree is stored in memory (not in a TFile), and is getting too big.
The problem is I’m not exactly sure how to implement the creation of the new .root file and storing the generated tree there (keep in mind that I need to store it every once in a while).


The simplest is to open the new file just before creating the new TTree

TFile *f = TFile::Open(outputfilename,"RECREATE");
TTree *tree = new TTree( ....


That seems to be working great!

Thank you!!

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