| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

SimStatistic.h

Go to the documentation of this file.
00001 
00002 //   **************************************************************************
00003 //   *                                                                        *
00004 //   *                      ! ! ! A T T E N T I O N ! ! !                     *
00005 //   *                                                                        *
00006 //   *  This file was created automatically by GaudiObjDesc, please do not    *
00007 //   *  delete it or edit it by hand.                                         *
00008 //   *                                                                        *
00009 //   *  If you want to change this file, first change the corresponding       *
00010 //   *  xml-file and rerun the tools from GaudiObjDesc (or run make if you    *
00011 //   *  are using it from inside a Gaudi-package).                            *
00012 //   *                                                                        *
00013 //   **************************************************************************
00014 
00015 #ifndef SimEvent_SimStatistic_H
00016 #define SimEvent_SimStatistic_H 1
00017 
00018 // Include files
00019 #include "GaudiKernel/boost_allocator.h"
00020 #include <cmath>
00021 #include <map>
00022 #include <ostream>
00023 
00024 // Forward declarations
00025 
00026 namespace DayaBay 
00027 {
00028 
00029   // Forward declarations
00030   class SimStatistic;
00031   
00032 
00042   class SimStatistic
00043   {
00044   public:
00045 
00047     SimStatistic() : m_count(0),
00048                      m_sum(0),
00049                      m_squaredsum(0) {}
00050   
00052     virtual ~SimStatistic() {}
00053   
00055     double mean() const;
00056   
00058     double rms() const;
00059   
00061     void increment(double x);
00062   
00064     SimStatistic& operator+=(const DayaBay::SimStatistic& rhs);
00065   
00067     SimStatistic operator+(const DayaBay::SimStatistic& rhs) const;
00068   
00070     std::ostream& fillStream(std::ostream& s) const;
00071   
00074   double count() const;
00075   
00078   void setCount(double value);
00079   
00082   double sum() const;
00083   
00086   void setSum(double value);
00087   
00090   double squaredsum() const;
00091   
00094   void setSquaredsum(double value);
00095   
00096   
00097   #ifndef GOD_NOALLOC
00099     static void* operator new ( size_t size )
00100     {
00101       return ( sizeof(SimStatistic) == size ? 
00102                boost::singleton_pool<SimStatistic, sizeof(SimStatistic)>::malloc() :
00103                ::operator new(size) );
00104     }
00105   
00109     static void* operator new ( size_t size, void* pObj )
00110     {
00111       return ::operator new (size,pObj);
00112     }
00113   
00115     static void operator delete ( void* p )
00116     {
00117       boost::singleton_pool<SimStatistic, sizeof(SimStatistic)>::is_from(p) ?
00118       boost::singleton_pool<SimStatistic, sizeof(SimStatistic)>::free(p) :
00119       ::operator delete(p);
00120     }
00121   
00124     static void operator delete ( void* p, void* pObj )
00125     {
00126       ::operator delete (p, pObj);
00127     }
00128   #endif
00129   protected:
00130 
00131   private:
00132 
00133     double m_count;      
00134     double m_sum;        
00135     double m_squaredsum; 
00136   
00137   }; // class SimStatistic
00138 
00139   inline std::ostream& operator<< (std::ostream& str, const SimStatistic& obj)
00140   {
00141     return obj.fillStream(str);
00142   }
00143   
00144 } // namespace DayaBay;
00145 
00146 // -----------------------------------------------------------------------------
00147 // end of class
00148 // -----------------------------------------------------------------------------
00149 
00150 // Including forward declarations
00151 
00152 inline double DayaBay::SimStatistic::count() const 
00153 {
00154   return m_count;
00155 }
00156 
00157 inline void DayaBay::SimStatistic::setCount(double value) 
00158 {
00159   m_count = value;
00160 }
00161 
00162 inline double DayaBay::SimStatistic::sum() const 
00163 {
00164   return m_sum;
00165 }
00166 
00167 inline void DayaBay::SimStatistic::setSum(double value) 
00168 {
00169   m_sum = value;
00170 }
00171 
00172 inline double DayaBay::SimStatistic::squaredsum() const 
00173 {
00174   return m_squaredsum;
00175 }
00176 
00177 inline void DayaBay::SimStatistic::setSquaredsum(double value) 
00178 {
00179   m_squaredsum = value;
00180 }
00181 
00182 inline double DayaBay::SimStatistic::mean() const 
00183 {
00184 
00185         return m_sum/m_count;
00186       
00187 }
00188 
00189 inline double DayaBay::SimStatistic::rms() const 
00190 {
00191 
00192         return sqrt((m_squaredsum - m_sum*m_sum/m_count)/(m_count));
00193       
00194 }
00195 
00196 inline void DayaBay::SimStatistic::increment(double x) 
00197 {
00198 
00199         m_count+=1.0;
00200         m_sum += x;
00201         m_squaredsum += x*x;
00202       
00203 }
00204 
00205 inline DayaBay::SimStatistic& DayaBay::SimStatistic::operator+=(const DayaBay::SimStatistic& rhs) 
00206 {
00207 
00208         m_count+=rhs.m_count;
00209         m_sum += rhs.m_sum;
00210         m_squaredsum += rhs.m_squaredsum;
00211         return *this;
00212       
00213 }
00214 
00215 inline DayaBay::SimStatistic DayaBay::SimStatistic::operator+(const DayaBay::SimStatistic& rhs) const 
00216 {
00217 
00218         SimStatistic res;
00219         res.m_count = m_count + rhs.m_count;
00220         res.m_sum =   m_sum +   rhs.m_sum;
00221         res.m_squaredsum = m_squaredsum + rhs.m_squaredsum;
00222         return res;
00223       
00224 }
00225 
00226 
00227 #endif 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:31:28 2011 for SimEvent by doxygen 1.4.7