Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:57

0001 #ifndef __RUNNINGMEAN_H__
0002 #define __RUNNINGMEAN_H__
0003 
0004 
0005 
0006 /** 
0007 This is the abstract running mean parent class. 
0008 
0009 We have two different running mean classes derive from it, a "real"
0010 (mathematically correct) running mean value, and a "pseudo" value of the running
0011 mean, which is a lot more efficient and fully adequate for most monitoring purposes.
0012 
0013 
0014 These classes are meant to monitor lots of  values (such as all channels 
0015 of a given detector) simultaneously; In the constructor you specify the 
0016 "width" (how many channels) and the depth of the running mean. 
0017 
0018 This class is meant to be lightweight, so there is not much in the way of 
0019 bounds checking of the input data going on. 
0020 
0021 */
0022 
0023 
0024 
0025 class runningMean {
0026 
0027 public:
0028   runningMean();
0029   virtual ~runningMean();
0030 
0031 
0032   /// the getMean(i) funtion returns the current mean value of channel i 
0033   virtual double getMean(const int /*ich*/) const = 0;
0034   virtual double getReference(const int /*ich*/) const;
0035   virtual int getNumberofChannels() const {return NumberofChannels;};
0036 
0037   /// Reset will reset the mean values (not the references)
0038   virtual int Reset() = 0;
0039 
0040   /**Add will add a new list of readings. It is your responsibility 
0041      to provide an approriate array of readings. (Typically you can get 
0042      the array of int's from the Packet object's fillIntArray function).
0043    */ 
0044   virtual int Add (const int /*iarr*/[]) = 0;
0045   virtual int Add (const float /*farr*/[]) = 0;
0046   virtual int Add (const double /*darr*/[]) = 0;
0047 
0048   // provide an externAl, ready-made array of the means (e.g, from the
0049   // database) to be used as a reference
0050   int setRefArray(const double /*darr*/[]);
0051 
0052   // set the reference for individual channels
0053   int setRefChannel(const int /*channel*/, const double /*refvalue*/);
0054 
0055   // establish thecurrent mean values as the reference
0056   int setAsReference();
0057 
0058   double getPercentDeviation(const int /*channel*/) const;
0059 
0060  protected:
0061 
0062   int NumberofChannels = 0;
0063   double * refArray;
0064 
0065 
0066 };
0067 #endif
0068 
0069