Re: [ROOT] Splitting a pointer to a TObject

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Mar 06 2003 - 23:09:42 MET


Hi Carlos,

Instead of using the "conventional" Event-like class,
with hardwired data members, I recommend a dynamic collection of TObject*.
This is much more flexible. One can easily add a new object or collection
to the list of collections for the Event.

TTree has several Branch constructors. Look at the following:
TTree::Branch(TCollection *list, Int_t bufsize, Int_t splitlevel, const 
char *name)

This constructor answers your problem/question. see the documentation
of this class that includes an example of use.
    http://root.cern.ch/root/htmldoc/src/TTree.cxx.html#TTree:Branch

Rene Brun


On Thu, 6 Mar 2003, 
Carlos Muņoz Camacho wrote:

> 
> Hi,
> 
>    Consider a class TEvent containing a pointer to an object
> TDetectorAEvent, which contains itself TClonesArrays and some other
> objects. Everything inherit from TObject. If we write a tree with a TEvent
> in a branch and set maximum splitting, TDetectorAEvent will not split
> because it is not an object itself but a pointer (and even if it is an
> object only splits one level). This behaviour is documented. Only pointers
> to TClonesArray work. The workarounds I can think of are:
> 
> 1.- Manual splitting of TEvent, which may be extremely tedious if TEvent
> contains many data members.
> 
> 2.- Remove the pointer to the object and use an object itself. This allows
> at least one level of splitting, but having objects themselves and not
> pointers does not allow dynamic allocation.
> 
> Are there any other, more interesting, solutions ? Will splitting of
> pointers to TObjects be supported in a near future ? Thanks!
> 
> ROOT 3.03/08 in RedHat 7.2
> 
> Carlos Muņoz
> SPhN/CEA-Saclay
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET