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;
}