Hi Rene,
I’m not complaining about the collections not being merged, that’s fine. I also agree that the logical thing to do with unmergeable objects is to store a different cycle for each original.
But, that’s not what’s happening. Let’s look at the below (and attached) sample. Sorry if it has become a bit long. (ROOT v5.18.00 by the way.)
The first step creates two files, each with a TClonesArray of two TObjStrings, stored with kSingleKey.
[code]{
// test_hadd_1.C
gROOT->Reset();
TClonesArray a(“TObjString”);
new(a[0]) TObjString(“one”);
new(a[1]) TObjString(“two”);
TClonesArray b(“TObjString”);
new(b[0]) TObjString(“three”);
new(b[1]) TObjString(“four”);
TFile f_a(“test_hadd_a.root”, “RECREATE”);
a.Write(“merge_this”, TObject::kSingleKey);
f_a.Close();
TFile f_b(“test_hadd_b.root”, “RECREATE”);
b.Write(“merge_this”, TObject::kSingleKey);
f_b.Close();
}[/code]
root -b -q test_hadd_1.C
root [0]
Processing test_hadd_1.C...
Then we hadd them:
hadd test_hadd_comb.root test_hadd_a.root test_hadd_b.root
Target file: test_hadd_comb.root
Source file 1: test_hadd_a.root
Source file 2: test_hadd_b.root
Target path: test_hadd_comb.root:/
Unknown object type, name: TObjStrings title: An array of clone objects
And then we have a look at the hadded file:
[code]{
// test_hadd_2.C
gROOT->Reset();
TFile f(“test_hadd_comb.root”, “READ”);
TIter next(f->GetListOfKeys());
TKey* key = 0;
while (key = (TKey*)next()) {
TObject* obj = key->ReadObj();
std::cout << “Key " << key->GetName() << "'" << " with cycle " << key->GetCycle() << std::endl; std::cout << " points to a " << obj->IsA()->GetName() << " called
" << obj->GetName() << “’”
<< " with title `” << obj->GetTitle() << “’”
<< std::endl;
} // while
f.Close();
}[/code]
root -b -q test_hadd_2.C
root [0]
Processing test_hadd_2.C...
Key `merge_this' with cycle 2
points to a TObjString called `two' with title `Collectable string class'
Key `merge_this' with cycle 1
points to a TObjString called `one' with title `Collectable string class'
So what it did was unpack the first TClonesArray it saw, store the entries as single TObjStrings and then forget all about the second TClonesArray.
Jeroen
test_hadd_2.C (505 Bytes)
test_hadd_1.C (429 Bytes)