Problems in estimating the number of entries in a TChain

Hi list,
i have a problem with TChain. I need to merge two different TChains inside one single TChain. In order to do this i’m using the Add() method of the TChain class.

However i’m getting an error in estimating the number of entries of the resulting Chain when using the

Int_t Add(TChain* chain)

method, while using

it works correctly. Of course this becomes a problem when the number of files that needs merging becomes quite big.

TChain *tt = new TChain("t");
tt->Add("/data01/calviani/DST/FIC1/full/data_run8207--IDriv13.root")
tt->Add("/data01/calviani/DST/FIC1/full/data_run8207--IDriv16.root")
tt->GetEntries()

In this case the number of entries is correctly displayed as the sum of the entries of the two TTrees (=23569465).

TChain *t_1 = new TChain("t");
t_1->Add("/data01/calviani/DST/FIC1/full/data_run8207--IDriv13.root")
TChain *t_2 = new TChain("t");
t_2->Add("/data01/calviani/DST/FIC1/full/data_run8207--IDriv16.root")
TChain *tt = new TChain("t");
tt->Add(t_1)
tt->Add(t_2)
tt->GetEntries()

In this case the result of the last command gives a number two order of magnitude greater that the correct sum (2469135780 instead of 23569465), while mantaining the correct value for t_1 and t_2 (11299022 and 12270443)

I’m using ROOT version 5.17/02

What am i doing wrong?

Thanks in advance,
Marco

Simply do:

TChain *t_1 = new TChain("t"); t_1->Add("/data01/calviani/DST/FIC1/full/data_run8207--IDriv13.root",0) TChain *t_2 = new TChain("t"); t_2->Add("/data01/calviani/DST/FIC1/full/data_run8207--IDriv16.root",0) TChain *tt = new TChain("t"); tt->Add(t_1,0); tt->Add(t_2,0); tt->GetEntries() ;

see doc of TChain::Add

Rene

Hi Rene,
maybe i don’t understand correctly, but is the code you wrote the same that i wrote in the second part of my message? Is the one with that i’ve got the error…

m

see the second argument “0” when calling TChain::Add

Rene

Thanks Rene, it worked.

m