Root files merging script (for file size > 100GB) does not close the root file

Dear Experts,

I have 10 root files each of size ~12 GB and I want to merge them to make a single file for analysis. All of them have the same tree and leaves structure. As hadd has a file size limitation, I was writing a script that merges all the root files successfully but it did not close the merged root file at the end. Could anyone take a look at it? Any help will be appreciated.

int root_ttree_merger(int file1 = 1, int file2 = 2, int file3 = 3, int file4 = 4, int file5 = 5,
                       int file6 = 6, int file7 = 7, int file8 = 8, int file9 = 9, int file10 = 10,
                  char const *InNamePrefix = "scan_40ring",
                  char const *OutNamePrefix = "Mod_40ring_180s" ) 
  {
  TTree::SetMaxTreeSize (1LL*1024*1024*1024*1024);   //1 TB
  TFileMerger merger (kFALSE, kFALSE);            
  merger.OutputFile(Form("%s.root", OutNamePrefix));

  cout << endl;

  for (Int_t ifile = file1; ifile <= (Int_t) file10; ++ifile)    // 10 root files
  {
    TString name = Form("%s%i.root", InNamePrefix, ifile);
    cout << "| Adding " << name << endl;

    if (!merger.AddFile(name))
      return false;
  }

// Let us print the time taken to merge these root files

  cout << "|\n";
  gSystem->Exec ("echo '| Submission Date: ' `date`");
  cout << "|\n|---> Merging files into: " << Form("%s.root", OutNamePrefix) << endl;

  merger.Merge();

  cout << "|\n";
  gSystem->Exec ("echo '| Completed Date: ' `date`");
  cout << endl;

  return 0;
}

This code pattern “works” for me (or so it seems). The only way that I would guess the output file might end up not closed is if there is some error during the merging or the process die expectantly.

yes, the code works for merging root files of size <100 GB but when the merged root file became more than 100 GB it does not exit properly (it just sits idle), as a result, the merged root file will not close! I didn’t see any other errors! So, do you have any idea why is that?