Re: [ROOT] array of TClonesArray

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Oct 01 2001 - 18:38:07 MEST


Hi Pierpaolo,

I suggest the following:

{
   TList *list = new TList();
   for (Int_t i=0;i<36;i++) {
      TClonesArray *carray = new TClonesArray("myclass",...);
      char name[32];
      sprintf(name,"ftracks%d",i);
      carray->SetName(name);
      list->Add(carray);
   }
  
   TTree T("T","..");
   T.Branch(list);
   T.Print();
}

This special Branch constructor takes a dynamic TList as input.
The TList may contain TClonesArray or any other object.
It is better than hardwired pointers or arrays in the top level class.

Rene Brun

Pierpaolo Righini wrote:
> 
> Hello,
> I have to write a root tree with events containing, each one, many tracks
> that are identical for what concerns the informations contained (i.e. the
> class definition is the same for all of them) but that should be tagged
> differently because they came from different part of the apparatus. So
> I would like to see them splitted using for example the TTree viewer.
> 
> I tried to do an array of TClonesArray with
> 
> TClonesArray *ftrack[36];
> 
> instead of
> 
> TClonesArray *f1track;
> TClonesArray *f2track;
> .......................
> TClonesArray *f36track;
> 
> in my Event class, but it seems not to work properly. Is there the chance
> to do that? Many thanks in any cases.
> 
>    Pierpaolo



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