Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pseudoRunningMean Class Reference

#include <OnlMon/blob/main/onlmonutils/pseudoRunningMean.h>

+ Inheritance diagram for pseudoRunningMean:
+ Collaboration diagram for pseudoRunningMean:

Public Member Functions

 pseudoRunningMean (const int, const int)
 
 ~pseudoRunningMean () override
 
 pseudoRunningMean (const pseudoRunningMean &)=delete
 
pseudoRunningMeanoperator= (const pseudoRunningMean &)=delete
 
double getMean (const int) const override
 the getMean(i) funtion returns the current mean value of channel i
 
int Reset () override
 Reset will reset th whole class.
 
int Add (const int[]) override
 
int Add (const float[]) override
 
int Add (const double[]) override
 
- Public Member Functions inherited from runningMean
 runningMean ()
 
virtual ~runningMean ()
 
virtual double getReference (const int) const
 
virtual int getNumberofChannels () const
 
int setRefArray (const double[])
 
int setRefChannel (const int, const double)
 
int setAsReference ()
 
double getPercentDeviation (const int) const
 

Protected Member Functions

int addChannel (const int, const double)
 

Protected Attributes

int depth
 
int current_depth
 
doublearray
 
- Protected Attributes inherited from runningMean
int NumberofChannels = 0
 
doublerefArray
 

Detailed Description

This is the pseudo running mean class.

In order to calculate the "real" (mathematically correct) running mean value of a certain depth d, you will need to store the d most recent entries to the running mean. For large values of d, this can lead to excessive amount of memory allocated.

This pseudo running mean is an approximation of the running mean. It will work very well if you want to monitor values which don't vary too much, and makes it very well-suited for gain monitoring and similar applications, where there are no dramatic changes in the values under normal conditions. It will calculate the new running mean value rn from the existing value ro as

rn = ( ro * (d-1)/d + x ) /d

where x is the new value in the running mean calculation. If there have been less than d readings so far, it will return the actual mean value.

This class is mean to monitor lots of values (such as all channels of a given detector) simultaneously; In the cnstructor you specify the "width" (how many channels) and the depth of the running mean.

This class is meant to be lightweight, so there is not much in the way of bounds checking of the input data going on.

As a simple example, let's assume that you pre-select "laser trigger" events for the EmCal, and you want the running mean of the (144) channels calculated. You could construct a pseudoRunningMean object with 144 channels and depth 50:

{verbatim} pseudoRunningMean *pm = new pseudoRunningMean(144,50); {verbatim}

and the pass your "laser" events and the pm object on to a routine that add the values:

{verbatim} int caculate_running_mean ( event * evt, RunningMean * rm) { int array[144]; Packet *p = evt->getPacket(8002); if (p) { yes, we got the packet, and we ask it now to get channel 57 for us p->fillIntArray(array, 144, &nw); rm->Add(array); delete p; return 0; } return 1; } {verbatim}

Then, outside of your routine, you could ask the pm object for the (pseudo-) running mean value of channel i with

{verbatim} pm->getmean(i); {verbatim}

Definition at line 74 of file pseudoRunningMean.h.

View newest version in sPHENIX GitHub at line 74 of file pseudoRunningMean.h

Constructor & Destructor Documentation

pseudoRunningMean::pseudoRunningMean ( const int  n,
const int  d 
)

Definition at line 3 of file pseudoRunningMean.cc.

View newest version in sPHENIX GitHub at line 3 of file pseudoRunningMean.cc

References array, current_depth, depth, i, n, and runningMean::NumberofChannels.

pseudoRunningMean::~pseudoRunningMean ( )
override

Definition at line 13 of file pseudoRunningMean.cc.

View newest version in sPHENIX GitHub at line 13 of file pseudoRunningMean.cc

References array.

pseudoRunningMean::pseudoRunningMean ( const pseudoRunningMean )
explicitdelete

Member Function Documentation

int pseudoRunningMean::Add ( const int  iarr[])
overridevirtual

Add will add a new list of readings. It is your responsibility to provide an approriate array of readings. (Typically you can get the array of int's from the Packet object's fillIntArray function).

Implements runningMean.

Definition at line 19 of file pseudoRunningMean.cc.

View newest version in sPHENIX GitHub at line 19 of file pseudoRunningMean.cc

References addChannel(), current_depth, depth, i, and runningMean::NumberofChannels.

+ Here is the call graph for this function:

int pseudoRunningMean::Add ( const float  farr[])
overridevirtual

Implements runningMean.

Definition at line 28 of file pseudoRunningMean.cc.

View newest version in sPHENIX GitHub at line 28 of file pseudoRunningMean.cc

References addChannel(), current_depth, depth, i, and runningMean::NumberofChannels.

+ Here is the call graph for this function:

int pseudoRunningMean::Add ( const double  darr[])
overridevirtual

Implements runningMean.

Definition at line 37 of file pseudoRunningMean.cc.

View newest version in sPHENIX GitHub at line 37 of file pseudoRunningMean.cc

References addChannel(), current_depth, depth, i, and runningMean::NumberofChannels.

+ Here is the call graph for this function:

int pseudoRunningMean::addChannel ( const int  channel,
const double  k 
)
protected

Definition at line 62 of file pseudoRunningMean.cc.

View newest version in sPHENIX GitHub at line 62 of file pseudoRunningMean.cc

References array, channel(), current_depth, depth, k, ambiguity_solver_full_chain::x, and y.

Referenced by Add().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double pseudoRunningMean::getMean ( const int  ich) const
overridevirtual

the getMean(i) funtion returns the current mean value of channel i

Implements runningMean.

Definition at line 55 of file pseudoRunningMean.cc.

View newest version in sPHENIX GitHub at line 55 of file pseudoRunningMean.cc

References array, current_depth, and double().

+ Here is the call graph for this function:

pseudoRunningMean& pseudoRunningMean::operator= ( const pseudoRunningMean )
delete
int pseudoRunningMean::Reset ( )
overridevirtual

Reset will reset th whole class.

Implements runningMean.

Definition at line 47 of file pseudoRunningMean.cc.

View newest version in sPHENIX GitHub at line 47 of file pseudoRunningMean.cc

References array, current_depth, i, and runningMean::NumberofChannels.

Member Data Documentation

double* pseudoRunningMean::array
protected

Definition at line 103 of file pseudoRunningMean.h.

View newest version in sPHENIX GitHub at line 103 of file pseudoRunningMean.h

Referenced by addChannel(), getMean(), pseudoRunningMean(), Reset(), and ~pseudoRunningMean().

int pseudoRunningMean::current_depth
protected

Definition at line 102 of file pseudoRunningMean.h.

View newest version in sPHENIX GitHub at line 102 of file pseudoRunningMean.h

Referenced by Add(), addChannel(), getMean(), pseudoRunningMean(), and Reset().

int pseudoRunningMean::depth
protected

Definition at line 101 of file pseudoRunningMean.h.

View newest version in sPHENIX GitHub at line 101 of file pseudoRunningMean.h

Referenced by Add(), addChannel(), and pseudoRunningMean().


The documentation for this class was generated from the following files: