Re: [ROOT] Splitting a pointer to a TObject

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Mar 07 2003 - 00:03:13 MET


Hi Carlos,

You certainly misread the documentation of this branch constructor.
Obviously, it does not stop you to use classes and their functions.
It offers a more flexible way to define a general Tree. In this way,
different users can easily add their own objects or collections to
the top collection. A user does not have to inform the master guru
managing the Event class when he/she wants to add/delete a member.
It is an automatic way to get splitting at several levels for
pointers (as in your case).

Rene Brun


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

> On Thu, 6 Mar 2003, Rene Brun wrote:
> 
> >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.
> 
>    Thank you for your answer, Rene. However, avoiding the use of classes
> is not always an easy solution, as they usually contain many methods
> operating on their data members which are needed for the analysis.
>    I could add a new data member which is a dynamic collection of all the
> others and create a branch with this one. But this is not very different
> from manual splitting, especially because the automatic splitting works to
> full degree if the members of the collection are themselves collections.
> Creating this kind of collections of collections for all members of all
> classes in order to allow an automatic splitting can be tedious.
>    Being able to use C++ classes and all their advantages (data members +
> methods) and at the same time being able to stream data members
> succesfully would be interesting. It looks to be a very general problem.
> 
> 
> Carlos
> 
> 
> >
> >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