Re: TObjArray

Fons Rademakers (rdm@pcsalo.cern.ch)
Fri, 7 May 1999 19:27:11 +0200 (METDST)


Hi Deng,

objects in ROOT containers can be sorted according to the
Compare() method. This method is inherited from TObject and
should be overridden by your track class. The same Compare()
can be used for different sorts by using some static class
data member that can be used as selector. Coding Compare()
is fairly trivial, for an example see TObjString::Compare().

Cheers, Fons.

>
> I have a task. By using STL, it can be implemented easily. I am thinking
> of moving to Root.
>
> In STL, I use "vector" to store my collection of tracks. then I can
> (generic algorithm) "sort" the vector in ascending order of start radius
> of tracks.
>
> In Root, How should I do? I noticed that there is a class TObjArray which
> can store my tracks. But I am not sure if the method
> TObjArray::sort(Int_t upto=kMaxInt) is what I want.
>
> Thanks for any hint.
>
> -----------------------------------------------------------------
> Wensheng Deng Phone: (516) 344-1052
> P.O.Box 825 Fax :
> Upton, NY 11973, USA Email: deng@cnr2.kent.edu
> =================================================================
>
>
>
>
>
>
>
>
>
>
>
>
>

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