Re: [ROOT] TTree filling problem

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Nov 06 2002 - 10:13:34 MET


Hi Ben,

Effectively, when TTree::AutoSave is called very frequently,
GetBytesWritten overestimates the file size.
I have replaced the call to GetBytesWritten by GetEND in
the current CVS version.

Thanks for noticing this problem.

Rene Brun

On Tue, 5 Nov 2002, Ben Speakman wrote:

>   We have had some trouble with the new TTree::ChangeFile() method trying
> split a tree to a separate file before it has reachd the 1.9GB limit.
> This method is called when TFile::GetBytesWritten() exceeds 1.9GB, but
> the value returned by TFile::GetBytesWritten() deviates from the actual
> file size when the tree is written the following way.
>   I create a tree in a file using:
> 
> TFile *fFile = new TFile("file.root","RECREATE");
> TTree *fTree = new TTree("fTree","Tree Name");
> 
>   Then I make some branches using the TTree::Branch(const char* name,
> void* address, const char* leaflist, Int_t bufsize = 32000) method,
> leaving the bufsize to default.
> 
>   A loop runs to fill fTree:
> 
> for(...) {
>   ...set variables
>   TDirectory* savedir = gDirectory;
>   fTree->Fill();
>   fFile->cd();
>   fTree->AutoSave();
>   fFile->SaveSelf();
>   savedir->cd();
>   }
> 
>   In this loop I can watch the file size with fFile->GetBytesWritten(),
> which seems to increase well beyond the actual file size.  This becomes a
> problem when fFile prematurely thinks it is bigger than 1.9GB, and tries
> create the new file_1.root.
> 
>   I have attached a simple script which illustrates the trouble.  When I
> call the routine treesize to fill the tree 1000 times, and save everytime
> the fFile->GetBytesWritten() explodes to 829kB, while the actual file size
> sits at 12kB.
> 
> root [0] .L treesize.C
> root [1] treesize(1,100,1000)
> Output 0.2kB to 0.2kB to 3.9kB to 4.0kB
> 4       file.root
> Output 95.8kB to 95.8kB to 96.5kB to 96.7kB
> 12      file.root
> Output 185.3kB to 185.3kB to 186.1kB to 186.2kB
> 12      file.root
> Output 275.6kB to 275.6kB to 276.4kB to 276.5kB
> 12      file.root
> Output 366.4kB to 366.4kB to 367.2kB to 367.3kB
> 12      file.root
> Output 457.8kB to 457.8kB to 458.6kB to 458.7kB
> 12      file.root
> Output 549.8kB to 549.8kB to 550.6kB to 550.7kB
> 12      file.root
> Output 642.3kB to 642.3kB to 643.1kB to 643.2kB
> 12      file.root
> Output 735.1kB to 735.1kB to 735.9kB to 736.0kB
> 12      file.root
> Output 828.1kB to 828.1kB to 828.9kB to 829.0kB
> 12      file.root
> 
>   Is this manner of using AutoSave improper?  Is there a better way to
> define TTrees to prevent this from happening?
> 
> Thanks,
> Ben Speakman
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:16 MET