TFileMerger and SetMaxTreeSize

Hi,
I wonder how to use TFileMerger and SetMaxTreeSize… I have a list of files which I’m able to merge with TFileMerger but I’d like to split the output file when it becomes bigger that let’s say 1GB… (my output file is around 35GB). I have only one tree in the input files and I know that hadd can be used instead of the TFileMerger but I don’t understand why using something like

TTree::SetMaxTreeSize(1LL*1024*1024*1024);
TFileMerger m(kFALSE);
m.OutputFile(outfilename,"RECREATE");
for(UInt_t ifile=0; ifile<infilenames.size(); ifile++) {
    cout << "Adding " << infilenames[ifile] << endl;
    m.AddFile(infilenames[ifile]);
}
cout << "Merging..." << endl;
m.Merge();

is not working and the files are not splitted…

Hi,

TFileMerger does not (yet?) support this case (for which there is ambiguity for the general case: how do you ‘split’ the histograms in a file).

Instead try:TChain ch("ntuple"); for(UInt_t ifile=0; ifile<infilenames.size(); ifile++) { cout << "Adding " << infilenames[ifile] << endl; ch.AddFile(infilenames[ifile]); } TFile *of = TFile::Open(outfilename,"RECREATE"); cout << "Splitting..." << endl; TTree *ot = ch.CloneTree(-1); ot->GetDirectory()->GetFile()->Write(); delete ot->GetDirectory()->GetFile();

Cheers,
Philippe.

Thanks but I found the very basic reason is not working (which was really well hided in the documentation here: root.cern.ch/root/html602/TTree … ChangeFile): the file automatic splitting works only for trees in the main directory and my tree was in a sub-directory… so I ended up using something similar to what you suggested…