Re: Question about TTree's

Rene Brun (Rene.Brun@cern.ch)
Wed, 11 Feb 1998 10:20:59 +0100


Manuel Sanchez Garcia wrote:
>
> Hello Rooters,
>
> My question is the following:
> Is there an easy way to have a tree with many branches, each of them
> having subbranches and so on..?. For example i would like to have one
> branch per element in an array....
>
> At the moment i am doing that by creating the tree by hand. I mean,
> i take a pointer to a branch (let's say b) and add subbranches using:
> b->GetListOfBranches()->Add(newBranch)
>

The automatic split algorithm in TTree::Branch creates
one branch for each data member of the top level object.
- If the data member is itself an object, in turn, new branches
will be created for each member of the sub-object.
- If the data member is a pointer to an object, this object
will be serialized in its branch buffer.
- If the data member is a pointer to a TClonesArray, then each
data member of the class referenced by the TClonesArray will also
go to a separate branch.
An example is given in the Root distribution kit $ROOTSYS/test/Event
where all cases above are used.

You can create yourself your own branch structure.
Last November, we announced the ATLFast package (Atlas fast MonteCarlo).
This package is described at URL:
http://root.cern.ch/root/Atlfast.html
It is a good illustration of a program build with modules (Makers).
Each Maker generates objects or TClonesArrays of objects.
We strongly encourage Root users in the process of building
an event Tree structure to look at the technique used in ATLFast.
In particular, look at the way we save the main object ATLfast
(see ATLFast::Streamer and ATLFMaker::Streamer).

Rene Brun