I am using hadd to concatenate multiple root files (25 MB each). It seems to work fine, but I do not understand the size of my resulting file: concatenating 3 files, I expect my global root file to be aroun 75 MB. But it is 138 MB !!
hadd is able to merge histograms and also TTrees.
The resulting filehould not be bigger than the sum of the 3 files.
Could you post your 3 files somewhee in a public space?
I also join the script I use to generate those root files. It may not be optimal, since I am quite new to ROOT. The fonction Join2Root reads pure ASCII files, fill a tree called “mytree”, and then write it to root files.
BTW, I just discovered TChain and how to use them. So, I have almost no need of a global root file anymore.
I see the same behavior, but in an even more dramatic fashion: I have about 2500 files of around 2 MB each, and I want to add chuncks of 200 files together to make the thing more manageable. In the files I have a couple of histograms, a TNtuple and a Tree with a class similar to the Event sample in the manual.
Using hadd, I get 13 files with a total size of about 22 GB (instead of the original 5 GB) which is obviously quite a problem. I also tried using TChain::Merge to merge my event tree only, but I get the same behavior.
I looked at your 3 files. They contain MEMORY-RESIDENT TREES !!
The current merge procedure in hadd (calling TChain::Merge) is written
for the normal case of disk-resident Trees. hadd could be extended
to support memory-resident Trees, but this will take some work
and it is not in our short/medium term plan. Please use normal disk-resident Trees instead.
A memory resident Tree is created with a code like
TTree *T = new TTRee(“T”,“blabla”);
TFile *f = new TFile(“mytree.root”,“update”);
a disk=residen Tree is created with the inverse
TFile *f = new TFile(“mytree.root”,“update”);
TTree *T = new TTRee(“T”,“blabla”);
That might also be my problem. At the moment, I create my trees and then at the end of my analysis code I write them to a (newly created) file with TTree::Write().
I’ll try changing my code so that the file is opened before tree creation…