TFileMerger and SetMaxTreeSize

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

TFileMerger m(kFALSE);
for(UInt_t ifile=0; ifile<infilenames.size(); ifile++) {
    cout << "Adding " << infilenames[ifile] << endl;
cout << "Merging..." << endl;

is not working and the files are not splitted…


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();


Thanks but I found the very basic reason is not working (which was really well hided in the documentation here: … 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…