Re: ROOT collections (cont)

Fons Rademakers (Fons.Rademakers@cern.ch)
Tue, 07 Oct 1997 19:58:11 +0200


Pasha Murat wrote:
>
> One more question:
>
> - is it possible to store in any of the collection classes not pointers,
> but the objects themselves (like STL does it)? - reconstruction codes,
> for example, deal with ~n*10**4 hits per event, so by all means I'd try
> to avoid calling 'new' per hit...
>

Objects are either created on the stack or on the heap. The later is done
via "new". Normally stack space is fairly limited so one would never store
n*10**4 hit objects on the stack. The best way to deal with these large
number of recurring objects is by using a TClonesArray to store them in.
See pages 44 and 45 of the just published ROOT tutorial (in part2).

STL classes can store objects (like: vector<hit> vhit) but this is
generally very expensive since each hit in that case is actually passed
by value into the vector (and passing by value causes the hit copy ctor
to be called). Even with STl one would use vector<hit*> or vector<hit&>.

Cheers, Fons.

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910