![]() |
|
|||
File indexing completed on 2025-08-03 08:20:57
0001 #ifndef __FULLRUNNINGMEAN_H__ 0002 #define __FULLRUNNINGMEAN_H__ 0003 0004 /** 0005 This is the full running mean class. 0006 0007 It will calculate the "real" (mathematically correct) running 0008 mean value of a certain depth d, which comes at a price. For many online monitoring 0009 applicatiomns, you will be better off with the "pseudoRunningMean" class, which is 0010 a good approximation of the true running mean value. This class is provided to allow 0011 you to check that your pseudo running mean is a good enough approximation of the true value. 0012 Also, if the series of input values has large variations, the pseudo running mean will 0013 be off by a few percent. 0014 0015 Since you will need to store the d most recent entries to the running 0016 mean this can lead to excessive amount of memory allocated. 0017 0018 0019 This class is mean to monitor lots of values (such as all channels of a given 0020 detector) simultaneously; In the constructor you specify the "width" (how many channels) 0021 and the depth of the running mean. 0022 0023 Since both this fullRunningMean and pseudoRunningMean inherit from the abstract runningMean class, 0024 you can change your choice by just instantiating a different object, as in the following 0025 example (the calculate_running_mean function will accept either class) 0026 0027 \begin{verbatim} 0028 runningMean *pm = new fullRunningMean(144,50); 0029 \end{verbatim} 0030 0031 and the pass your "laser" events and the pm object on to a routine that add the values: 0032 0033 \begin{verbatim} 0034 int calculate_running_mean ( Event * evt, runningMean * rm) 0035 { 0036 int array[144]; 0037 Packet *p = evt->getPacket(8002); 0038 if (p) 0039 { 0040 // yes, we got the packet, and we ask it now to get channel 57 for us 0041 p->fillIntArray(array, 144, &nw); 0042 rm->Add(array); 0043 delete p; 0044 return 0; 0045 } 0046 return 1; 0047 } 0048 \end{verbatim} 0049 0050 Then, outside of your routine, you could ask the pm object for the running mean value 0051 of channel i with 0052 0053 \begin{verbatim} 0054 pm->getmean(i); 0055 \end{verbatim} 0056 0057 0058 0059 */ 0060 0061 0062 0063 0064 #include "runningMean.h" 0065 0066 0067 class fullRunningMean : public runningMean { 0068 0069 public: 0070 fullRunningMean( const int /*NumberofChannels*/, const int /*depth*/); 0071 ~fullRunningMean() override; 0072 0073 // delete copy ctor and assignment operator (cppcheck) 0074 explicit fullRunningMean(const fullRunningMean&) = delete; 0075 fullRunningMean& operator=(const fullRunningMean&) = delete; 0076 0077 /// the getMean(i) funtion returns the current mean value of channel i 0078 double getMean(const int /*ich*/) const override; 0079 0080 /// Reset will reset th whole class 0081 int Reset() override; 0082 0083 /**Add will add a new list of readings. It is your responsibility 0084 to provide an approriate array of readings. (Typically you can get 0085 the array of int's from the Packet object's fillIntArray function). 0086 */ 0087 int Add (const int /*iarr*/[]) override; 0088 int Add (const float /*farr*/[]) override; 0089 int Add (const double /*darr*/[]) override; 0090 0091 protected: 0092 0093 int addChannel(const int /*channel*/, const double /*x*/); 0094 int depth; 0095 int current_depth; 0096 double ** array; 0097 0098 }; 0099 #endif 0100 0101
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |