Re: TTree::GetEvent without creating new objects?

Rene Brun (Rene.Brun@cern.ch)
Thu, 30 Oct 1997 16:49:10 +0100


Robert Casties wrote:
>
> Hello rooties!
>
> I just created a TTree with some of my own objects (non-split). Now I want
> to loop through the tree using one object in memory (I generated that
> before).
>
> If I call TTree::GetEvent() first the objects destructor is called and
> then it's constructor and Streamer thus deleting and recreating my object
> for every event.
>
> The BranchAddress seems not to change so the object seems to stay in
> place. But still there are some new and delete's called (I think).
>
> Is there any other entry point or do I have to design my object (which
> contains variable length arrays) such that it does not delete itself?
>

Hi Robert,
When you use the non-split mode, GetEvent will automatically
-delete the object (event) at the address specified in SetBranchAddress
- create a new instance via the default constructor
- fill the event via Streamer.

In split-mode, the original event object is kept (no need to delete it
and rebuilt it). Only sub-objects need to be rebuilt.

I strongly encourage you to use the automatic split method.
It has only advantages. This, however, implies some thinking
on the top level event model to take advantage of the possibility
to read only subsets of one event.
If both methods (split or not), calling GetEvent rebuilds the
event object in memory in the same way and you can use the same
analysis procedure.

Rene Brun