Very big root file

Hallo,
I am trying to write a very big root file in a standalone c++ program. I ran a test with a relative smaller root file (1.2GB), which didn’t show me any problem. Then I turned to a real running, which wanted to produce a 30 GB large root file. Then I got an 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(...) you should do: TFile *f = new TFile(...) TTree *T = new TTree(...) Error in <TTree::Fill>: Failed filling branch:chan000_rR_rO_rD.value, nbytes=-1 ...[i](repeats of the last row)[/i]

I thought, it could be the max size problem. So I tried to find any flag for creating a large root file, which didn’t success. For the TTree object stored in the TFile I already set fSetTreeSize to 160GB, which is far beyond the size of the file to be produced. The error message alway came up when the size of the file is exceeding 7.5 GB.
Is that the way I can use TFile? Or I just missed some flag? What can I do? I really appreciate if somebody could help me out of the error! Thanks a lot in advance!

Simon Lu

Hi,

Did you follow the advise in the error message? Your symptoms clearly indicates that your TTree object is not attached to a TFile and thus is held completely in memory (and also that you have around 8Gb of ram + swap).

Do you create the TTree object after the creation of the output TFile object (and/or do you have a myoutputfile->cd(); just before the TTree creation). Alternatively you can use mytree->SetDirectory(myoutputfile);

Cheers,
Philippe.

Hi,
Thank you very much for your reply. The problem is solved by using mytree->SetDirectory(myoutputfile); after creation of the tree.
But the thing is a little bit bizarre. I did create the TTree object AFTER I created a TFile object. And I did use myoutputfile->cd() before the creation of the tree. And if I run a test program, which produces a root file smaller than 7.5 GB, it won’t invoke any error. Your guess is very precise, I do have 8GB ram. Now I just wonder, what causes the error? My supposition is that the error occurs when the ram is running out. Is there a way that I can let the tree store its recorders automatically after a certain amount and remove the residues in ram?
Anyway, the program error is solved, and thank you so much!

Hi,

[quote] I did create the TTree object AFTER I created a TFile object. And I did use myoutputfile->cd() before the creation of the tree. [/quote]Humm … strange indeed. The TTree always attach themselves to the current directory (there must have been yet another file creation or cd in between the 2).

[quote]Is there a way that I can let the tree store its recorders automatically after a certain amount and remove the residues in ram? [/quote]Yes, by attaching the TTree to file (which you did by call SetDirectory).

Cheers,
Philippe.

That already helps a lot! Thanks again!
sincerely,

Simon Lu