Dear ROOT experts,
I have one particular problem while trying to merge files. I have two files, each of them has one THnSparseD and TH1F. Those histograms in both files have same name and binning. The sizes of files are 142.5 MBytes and 75 MBytes respectively.
When I try to merge these files via hadd, it fails with std::bad_alloc error. Same happens when I try to use TFileMerger class. I also tried to add them via this simple macro, but it fails as soon as I try to add the sparses together.
[code]#include “TH1.h”
#include “THnSparse.h”
void merger1(){
TFile * in1 = TFile::Open(“test1.root”);
TFile * in2 = TFile::Open(“test2.root”);
in1->ls();
in2->ls();
THnSparseD * sparse1 = (THnSparseD *)in1->Get(“sparse”);
THnSparseD * sparse2 = (THnSparseD *)in2->Get(“sparse”);
TH1F * hEvents = (TH1F *)in1->Get(“hEvents”);
TH1F * hEvents2 = (TH1F *)in2->Get(“hEvents”);
hEvents->Add(hEvents2);
//Macro fails at this step
sparse1->Add(sparse2);
TFile out(“test.root”, “RECREATE”);
sparse1->Write();
hEvents->Write();
out.Close(“R”);
}[/code]
I guess that this is probably a memory issue, however I am not sure what can be done to prevent it. I tried merging on both Linux and Windows machines, with different amount of RAM, but with no success. I was wondering if there could be a workaround for this problem. The version of the ROOT I’m using is v5-34-07@49362