RdbStatsAve.cc

00001 // File:  RdbStatsAve.cc
00002 
00003 // --8<--8<--8<--8<--
00004 //
00005 // Copyright (C) 2006 Smithsonian Astrophysical Observatory
00006 //
00007 // This file is part of rdbstats
00008 //
00009 // rdbstats is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 //
00014 // rdbstats is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this program; if not, write to the 
00021 //       Free Software Foundation, Inc. 
00022 //       51 Franklin Street, Fifth Floor
00023 //       Boston, MA  02110-1301, USA
00024 //
00025 // -->8-->8-->8-->8--
00026 
00027 #include "RdbStatsAve.h"
00028 
00029 RdbStatsAve::RdbStatsAve( RDB& irdbtable, const string& name )
00030   throw( Exception ) try : RdbStats( irdbtable, name ) {
00031 
00032     try {
00033 
00034 #ifdef TRACEFCT
00035       TraceFct tf( "RdbStatsAve::RdbStatsAve( RDB&, const string& ) "
00036                    "throw( Exception)" );
00037 #endif
00038 
00039     } catch ( RDBErr& rdbe ) {
00040 
00041       throw Exception( rdbe );
00042 
00043     } catch ( Exception& e ) {
00044 
00045       throw;
00046 
00047     } catch ( exception& e ) {
00048 
00049       throw Exception( e.what( ) );
00050 
00051     }
00052 
00053   } catch ( Exception& E ) {
00054 
00055     // exception thrown by base class is caught here
00056     throw;
00057 
00058   } catch ( exception& e ) {
00059 
00060     // exception thrown by base class is caught here
00061     throw Exception( e.what( ) );
00062 
00063   }
00064 
00065 
00066 int RdbStatsAve::calculate_statistics( ) throw( ) {
00067 
00068 #ifdef TRACEFCT
00069   TraceFct tf( "int RdbStatsAve::calculate_statistics(  ) throw( )" );
00070 #endif
00071 
00072   if ( 0 == this->RdbStats::calculate_statistics( ) )
00073     return 0;
00074 
00075   // normalize the result wrt the average.
00076   double norm_factor = get_absolute_average( );
00077   normalize_results( norm_factor );
00078 
00079   return num_n;
00080 
00081 }