Minima and Maxima of ntuples

From: Birger Koblitz (koblitz@mail.desy.de)
Date: Fri Dec 03 1999 - 16:50:52 MET


Hi,

I noticed that TNtuple::GetMaximum(Text_t *) takes a significant amount of
time. Obviously it loops over all entries and calculates the maximum. This
is of course very slow. Wouldn't it be possible to calculate this
information while the NTuple is filled? I don't think it is very difficult
to implement and it would be quite usefull, especially if one needs some
bounds e.g. before one wants to fill a histogram with the information of
the ntuple. What was said is of course also true for GetMinimum.
Actually I encountered the problem while porting some kumac from paw where
this seems to be implemented, and I don't think that root should lack
anything paw features, right ;-) ?
So, Rene, would it be possible for you to implement this feature in the
next release?

Cheers,
  Birger

PS: Looking at the source, one actually finds:

 Float_t TTree::GetMinimum(const char *columname)
{

   TLeaf *leaf = GetLeaf(columname);
   if (!leaf) return 0;
   TBranch *branch = leaf->GetBranch();
   Float_t cmin = 1e30;                <============ ?????
   for (Int_t i=0;i<fEntries;i++) {
      branch->GetEntry(i);
      Float_t val = leaf->GetValue();
      if (val < cmin) cmin = val;
   }
   return cmin;
}

obviously there is a bug in the marked line, because it makes assumptions
about the representation of float values on the machine: it assumes
1e30 to be the largest float value which is false on most machines. One
should either initialize with the first entry or with FLOATMAX calculated
in math.h or values.h. Sorry for being pedantic, but numerics is something
to take seriously...



/------------------------------------------------------------\
| Birger Koblitz                    koblitz@mail.desy.de     |
| Max-Planck-Institut fuer Physik                            |
| (Werner Heisenberg-Institut)                               |
| DESY-FH1K                         Tel. (40) 8998-3971      |
| Notkestr. 85                                               |
| D-22603  HAMBURG                                           |
\------------------------------------------------------------/



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:43 MET