00001 #include "GravityBin2D.h" 00002 00003 Anaphe::AIDA_Histogram_native::GravityBin2D::GravityBin2D(): 00004 Anaphe::AIDA_Histogram_native::GravityBin1D(), 00005 m_sumOfWeightTimesCoord( 0 ) 00006 {} 00007 00008 00009 bool 00010 Anaphe::AIDA_Histogram_native::GravityBin2D::reset() 00011 { 00012 m_sumOfWeightTimesCoord = 0; 00013 return Anaphe::AIDA_Histogram_native::GravityBin1D::reset(); 00014 } 00015 00016 00017 bool 00018 Anaphe::AIDA_Histogram_native::GravityBin2D::scale( double factor ) 00019 { 00020 m_sumOfWeightTimesCoord *= factor; 00021 return Anaphe::AIDA_Histogram_native::GravityBin1D::scale( factor ); 00022 } 00023 00024 00025 bool 00026 Anaphe::AIDA_Histogram_native::GravityBin2D::increment( const Anaphe::AIDA_Histogram_native::GravityBin2D& otherBin ) 00027 { 00028 m_sumOfWeightTimesCoord += otherBin.m_sumOfWeightTimesCoord; 00029 return Anaphe::AIDA_Histogram_native::GravityBin1D::increment( static_cast< const Anaphe::AIDA_Histogram_native::GravityBin1D& >( otherBin ) ); 00030 } 00031 00032 00033 bool 00034 Anaphe::AIDA_Histogram_native::GravityBin2D::increment( int extraEntries, 00035 double extraHeight, 00036 double extraError, 00037 double extraCentreX, 00038 double extraCentreY ) 00039 { 00040 m_sumOfWeightTimesCoord += extraCentreY * extraHeight; 00041 return Anaphe::AIDA_Histogram_native::GravityBin1D::increment( extraEntries, extraHeight, extraError, extraCentreX ); 00042 } 00043 00044 00045 bool 00046 Anaphe::AIDA_Histogram_native::GravityBin2D::set( int entriesNew, 00047 double heightNew, 00048 double errorNew, 00049 double centreXNew, 00050 double centreYNew ) 00051 { 00052 m_sumOfWeightTimesCoord = centreYNew * heightNew; 00053 return Anaphe::AIDA_Histogram_native::GravityBin1D::set( entriesNew, heightNew, errorNew, centreXNew ); 00054 } 00055 00056 00057 double 00058 Anaphe::AIDA_Histogram_native::GravityBin2D::centreOfGravityY() const 00059 { 00060 const double theHeight = height(); 00061 if ( theHeight == 0 ) { 00062 return 0; 00063 } 00064 else { 00065 return ( m_sumOfWeightTimesCoord / theHeight ); 00066 } 00067 }