Hadd Error Merging TObjArray

Hi,

I’ve run into an issue merging three or more files (no problem with two) with hadd that contain TObjArrays. It seems that the index values that are computed for the merged array are larger than the inputs and an number of errors are generated:

$ root haddData.C
root [0]
Processing haddData.C...
hadd Target file: output.root
hadd compression setting for all ouput: 1
hadd Source file 1: file1.root
hadd Source file 2: file2.root
hadd Source file 3: file3.root
hadd Target path: output.root:/
Error in <TObjArray::At>: index 20 out of bounds (size: 20, this: 0x7fb774196280)
Warning in <TObjArray::Merge>: object of type TObjString (position 20 in list) not found in list 0. Continuing...
Error in <TObjArray::At>: index 21 out of bounds (size: 20, this: 0x7fb774196280)
Warning in <TObjArray::Merge>: object of type TObjString (position 21 in list) not found in list 0. Continuing...
...
Error in <TObjArray::At>: index 39 out of bounds (size: 20, this: 0x7fb774196280)
Warning in <TObjArray::Merge>: object of type TObjString (position 39 in list) not found in list 0. Continuing...
root [1]

The messages above were created with the following script:

{
   TObjArray array;
   array.SetName("STRINGS");

   for (int i=0;i<20;i++) array.Add(new TObjString(Form("/String %d", i)));


   TFile f("file1.root", "RECREATE");
   array.Write("STRINGS", TObject::kOverwrite | TObject::kSingleKey);
   f.Close();

   TFile f2("file2.root", "RECREATE");
   array.Write("STRINGS", TObject::kOverwrite | TObject::kSingleKey);
   f2.Close();

   TFile f3("file3.root", "RECREATE");
   array.Write("STRINGS", TObject::kOverwrite | TObject::kSingleKey);
   f3.Close();

   gSystem->Exec("rm -f output.root");
   gSystem->Exec("hadd output.root file*.root");
}

Any suggestions?

Thanks

Hi,

This issue has been corrected in the master (and in the upcoming v6.10).

The error messages, in this case, are spurious and can be ignored.

Cheers,
Philippe.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.