Re: ROOT and sorting

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jan 04 2000 - 18:49:48 MET


Hi George,
I understand somehow your philosophical problems with Sorting
and Collections. One could imagine to add new functionality
to sort collections in general. However, it is my personal
view that sorting problems are in general tightly connected
to an algorithm and efficiency is always an issue.
For that reason, I would recommend to use a more "conventional"
approach and far more efficient, using for example TMath::Sort.
In attachment, you will find an example of a short macro creating
filling and sorting histograms. You can change the sorting parameter
at your will.

Rene Brun

On Tue, 4 Jan 2000, George Heintzelman wrote:

> 
> > it would be nice if you give an example of inhomogenious collection 
> > you've been trying to sort. Without the example it is hard to see what 
> > is the problem you're trying to solve.
> 
> I'm not precisely trying to solve the problem of sorting inhomogenous 
> lists, though I do think it is a potentially dangerous situation. As I 
> noted, trying to do it is probably bad programming practice, but it is 
> certainly easy to do by accident in Root. If it would hang the system, 
> this is something that should be thought about. There are probably 
> examples of times people would want to do it, though, even though I 
> don't have a concrete one to hand.
> 
> The problem I was really trying to solve was that of having a list of 
> things (say, tracks), and trying to sort them by different criteria at 
> different times. Ie, some users may want to sort them by PID, others by 
> rapidity, others by pt, or by track quality, or by PID followed by any 
> one of those items, etc., etc. I don't expect to be able to know ahead 
> of time what my users might come up with, though I could probably 
> provide some reasonable set for some things that I anticipate being 
> used.
> 
> Right now solving this problem is really clunky in root. You have to 
> either modify the source code for the class or derive a new class (or 
> set of classes) from existing classes for each sort, transfer your 
> objects to this new class, and then sort them. It would be much easier 
> to allow you to sort by a function defined at the time you are calling 
> Sort(). If you modify the source code, you have to use a static 
> variable to define which sorting criterion you want to use right now.
> 
> George Heintzelman
> 
> 
> 
> 
> 
> 





This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:16 MET