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