Re: [ROOT] Question about TChain::Add

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Nov 05 2001 - 16:32:27 MET


Hi Thomas,

By definition, a TChain references always the same Tree name. You should do:

TChain c1("Events"); // Tree containing 1000 Events
c1.Add("file1.root");
c1.Add("file2.root");

TChain c2("Events"); // Tree containing one event
c2.Add(&c1);
c2.Add("file3.root");

etc.

Rene Brun




Thomas Bretz wrote:
> 
> Hello rooters,
> 
> I have to chains, which should contain the same files, I tried:
> ------
> TChain c1("Events"); // Tree containing 1000 Events
> c1.Add("file1.root");
> c1.Add("file2.root");
> 
> TChain c2("RunHeaders"); // Tree containing one event
> c2.Add(&c1);
> -----
> c2.GetEntries() results in 1000 instead of one and reading results in
> reading "Events" instead of "RunHeaders".
> 
> I tried the following, too, and this worked:
> ------
> TChain chain("RunHeaders");
> TObject *obj;
> TIter N(c1.GetListOfFiles());
> while ((obj=N()))
>   c2.Add(obj->GetTitle());
> -------
> 
> What is the idea of TChain::Add(TChain *) if not to add all files from
> one chain to the other chain?
> 
> Thanks,
> Thomas.



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:06 MET