Re: [ROOT] How to get branch data from tree friends?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sun Sep 15 2002 - 22:07:36 MEST


Hi Christian,

The "friend" system is currently exploited by TTree::Draw only.
In case you make the loop yourself, you have to:
 - set the branch addresses for all the Trees
 - call TTree::GetEntry for each tree

Rene Brun

On Sat, 14 Sep 2002, cstrato wrote:

> Dear Rooters
> 
> Suppose, that I have filled many trees with one branch each for:
> class MyClass: public TObject {
>     TString   fName;
>     Int_t     fNum;
>     Double_t  fValue;
> }
> 
> Now I add all trees to the first tree as friends:
>     TTree *tree = (TTree*)file->Get("T0");
>     for (Int_t i=1; i<numtrees; i++) {
>        tree->AddFriend("T[i]");  //pseudocode
>     }
> 
> How do I get the values for the different branches, so that:
>     Int_t entries = (Int_t)(tree->GetEntries());
>     for (Int_t i=0; i<entries; i++) {
>        tree->GetEntry(i);
>        for (Int_t k=0; i<numtrees; i++) {
>          // pseudocode:
>           name[i][k]  = myclass("T[k]")->GetName();     <===???
>           num[i][k]   = myclass("T[k]")->GetNumber();   <===???
>           value[i][k] = myclass("T[k]")->GetValue();    <===???
>        }
>     }
> 
> Thank you in advance for your help.
> 
> Best regards
> Christian
> _._._._._._._._._._._._._._._._
> C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
> V.i.e.n.n.a       A.u.s.t.r.i.a
> _._._._._._._._._._._._._._._._
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:09 MET