Re: BRAT 1.13.2 (not the Tiles/Si split)

From: Konstantin Olchanski (olchansk@ux1.phy.bnl.gov)
Date: Tue Jan 30 2001 - 14:31:00 EST

  • Next message: Betty McBreen: "[Fwd: Attention: BRAHMS users]"

    > I've commited several changes to BRAT. Here's a short description:
    > 
    > * Added the statig constant kInvalidValue to BrDataObject. This is a
    >   huge float (1x10^200), so it's good as an invalid/bad value to
    >   return in case of error or something like that. For example, all
    >   the vertex algorithms could use this value if they can't find a
    >   vertex, one can put it as a calibration constant that wasn't
    >   fixable, and so on. The idea is to have it at an unreasonable value
    >   (if you can think of any number in BRAHMS that would ever be that
    >   high, then let me know, and I'll change the sign :-), and a symbolic
    >   name for that unrteasonable value. 
    
    It is generally considered to be "a bad idea" (tm) to mix valid return
    values with error codes and to use "special" values to mean "special"
    things.
    
    In this case, it is also a bug because:
    
    a) 1x10^200 is not  a valid "float" because the biggest "float"
       is around 1x10^38  (see FLT_MAX in "limits.h"),
    b) it is not even a large "double" (~ 1x10^308, see DBL_MAX),
    c) it can be a valid return value for a function that returns,
       for example, the track momentum for tracks with small curvature
       for large momentum tracks (curvature = inverse momentum, q/p).
    d) perfectly good "special" constants are already defined for float
       and double values in limits.h: DBL_MAX (+/- infinity), DBL_MIN, etc.
       Then there are the NaN values which a perfectly good for
       your proposed purposes.
    
    Note: bug (a) causes code like
    
         float val[100];
         ... 10 pages of code
         val[0] = foo.getValue();
         if (val[0] == kInvalidValue)
            panic();
    
    to fail because 1x10^200 will be truncated to a float and
    the comparison will fail. This may or may not be flagged as a warning
    by your compiler.
    
    
    -- 
    Konstantin Olchanski
    Physics Department, Brookhaven National Laboratory, Long Island, New York
    olchansk@bnl.gov
    



    This archive was generated by hypermail 2b29 : Tue Jan 30 2001 - 14:54:12 EST