Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:52

0001 #ifndef __MBDRUNNINGSTATS_H__
0002 #define __MBDRUNNINGSTATS_H__
0003  
0004 #include <queue>
0005 
0006 /**
0007  * Class to calculate running average and RMS
0008  */
0009 class MbdRunningStats
0010 {
0011 public:
0012   MbdRunningStats(const unsigned int imaxnum = 100);
0013   void Clear();
0014   void Push(double x);
0015 
0016   unsigned int Size() const { return static_cast<unsigned int>(values.size()); }
0017   unsigned int MaxNum() const { return maxnum; }
0018 
0019   double Mean() const;
0020   double Variance() const;
0021   double StandardDeviation() const;
0022   double RMS() const;
0023 
0024 private:
0025   std::queue<int> values;
0026   unsigned int maxnum; // max values in sum
0027   double S1{0.};  // sum of values
0028   double S2{0.};  // sum of squares
0029 };
0030 
0031 #endif // __MBDRUNNINGSTATS_H__