Re: [ROOT] Updating gDirectory when Friend trees are added

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Jun 07 2001 - 08:28:18 MEST


Hi malcom,

The default TTree constructor does not append the Tree to the current directory.
You should do one of the two options:
 - TTree *t=new TTree();
   gDirectory->Append(t);
   t->AddFriend("tother","toto.root");
   t->SetName("toto")
or better
 - TTree *t=new TTree("toto","hello toto");
   t->AddFriend("tother","toto.root");


Rene Brun

Malcolm Davidson wrote:
> 
> Hello (my day for ROOT emails)
> 
> I've noticed working with the TTree member function AddFriend() that the
> following code
> 
> TTree *t=new TTree();
> t->AddFriend("tother","toto.root");
> t->SetName("toto")
> 
> does not produce a corresponding entry in gDirectory. I cannot retrieve the
> tree using the
> usual (TTree*)gDirectory->GetList()->FindObject("toto") approach, this
> although the tree now (theoretically) associated with tree "tother".
> 
> Shouldn't an entry to gDirectory be added when this happens ?
> 
> Regards
> 
> Malcolm
> 
> <>------------------------------------------------<>
> Malcolm W. J. Davidson
> CESBIO - UMR 5639 CNES-CNRS-UPS
> 18 Avenue Edouard Belin
> BP 2801
> F-31401 Toulouse Cedex 4  France
> e-mail : davidson@cesbio.cnes.fr
> phone (33)(0)5.61.55.85.84
> fax   (33)(0)5.61.55.85.00
> <>------------------------------------------------<>



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