TTree::SetMaxTreeSize and TFile->Close(0

Hi,

I am a little confused about using the TTree::SetMaxTreeSize parameter to cause the automatic generation of new files every certain number of bytes. Do I need to close my file at the end? This is confusing, b/c the file name has changed. Also, when I had a file->Close() statement in the program, it crashed when I use SetMaxTreeSize. However, when I remove the Close() statement all runs fine.

Thank you.

Jon

Hi,
that’s right, the file you started with is not the file you end up with. You can get the TTree’s current file (i.e. the last file at the edn of your fill loop) by calling TTree::GetCurrentFile(). And yes, you should close (delete) this last file when you’re done filling. Root can find out when a file is “full” (deleting the full one, and opening a new one), but it cannot guess when you’re done filling. See the IMPORTANT NOTE (I’m quoting here) for TTree::ChangeFile.
Axel.

Axel,

Thanks. I’d also like to have all my generated file names have a uniform name. For example, as it stands now, the first file name is myfile.root, while subsequent files have the name myfile_1.root, myfile_2.root, etc. Is there a way I can start the whole process so that all files have the number extension. That is, I’d prefer not to have a lone file with no number extension.

Thanks in advance.

Jon

Hi Jon,
I had a quick look at the source - it seems that you can start with a file called “…_1.root”, and call TTree::SetFileNumber(1). You’ll simply skip the 0th file doing that. All files will have a number, even though they are numbered a la fortran.
Axel.