Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

GravityBin1D.cpp

Go to the documentation of this file.
00001 #include "GravityBin1D.h"
00002 #include <cmath>
00003 
00004 Anaphe::AIDA_Histogram_native::GravityBin1D::GravityBin1D():
00005   m_entries( 0 ),
00006   m_sumOfWeights( 0 ),
00007   m_sumOfWeightTimesCoord( 0 ),
00008   m_sumOfSquaredWeights( 0 )
00009 {}
00010 
00011 
00012 bool
00013 Anaphe::AIDA_Histogram_native::GravityBin1D::reset()
00014 {
00015   m_sumOfSquaredWeights = m_sumOfWeightTimesCoord = m_sumOfWeights = m_entries = 0;
00016   return true;
00017 }
00018 
00019 bool
00020 Anaphe::AIDA_Histogram_native::GravityBin1D::scale( double factor )
00021 {
00022   m_sumOfWeights *= factor;
00023   m_sumOfWeightTimesCoord *= factor;
00024   m_sumOfSquaredWeights *= factor * factor;
00025   return true;
00026 }
00027 
00028 bool
00029 Anaphe::AIDA_Histogram_native::GravityBin1D::increment( const Anaphe::AIDA_Histogram_native::GravityBin1D& otherBin )
00030 {
00031   m_entries += otherBin.m_entries;
00032   m_sumOfWeights += otherBin.m_sumOfWeights;
00033   m_sumOfWeightTimesCoord += otherBin.m_sumOfWeightTimesCoord;
00034   m_sumOfSquaredWeights += otherBin.m_sumOfSquaredWeights;
00035   return true;
00036 }
00037 
00038 bool
00039 Anaphe::AIDA_Histogram_native::GravityBin1D::increment( int extraEntries,
00040                                                         double extraHeight,
00041                                                         double extraError,
00042                                                         double extraCentre )
00043 {
00044   m_entries += extraEntries;
00045   m_sumOfWeights += extraHeight;
00046   m_sumOfWeightTimesCoord += extraCentre * extraHeight;
00047   m_sumOfSquaredWeights += extraError * extraError;
00048   return true;
00049 }
00050 
00051 bool
00052 Anaphe::AIDA_Histogram_native::GravityBin1D::set( int entriesNew,
00053                                                   double heightNew,
00054                                                   double errorNew,
00055                                                   double centreNew )
00056 {
00057   m_entries = entriesNew;
00058   m_sumOfWeights = heightNew;
00059   m_sumOfWeightTimesCoord = centreNew * heightNew;
00060   m_sumOfSquaredWeights = errorNew * errorNew;
00061   return true;
00062 }
00063 
00064 double
00065 Anaphe::AIDA_Histogram_native::GravityBin1D::error() const
00066 {
00067   return std::sqrt( m_sumOfSquaredWeights );
00068 }
00069 
00070 
00071 double
00072 Anaphe::AIDA_Histogram_native::GravityBin1D::centreOfGravityX() const
00073 {
00074     return ( ( m_sumOfWeights == 0 ) ? 0 : ( m_sumOfWeightTimesCoord / m_sumOfWeights ) );
00075 }

Generated on Tue Nov 19 12:32:17 2002 for AIDA_Histogram_native by doxygen1.2.16