CFEL - ASG Software Suite  2.5.0
CASS
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cass::pp61 Class Reference

result averaging. More...

#include <operations.h>

+ Inheritance diagram for cass::pp61:
+ Collaboration diagram for cass::pp61:

Public Member Functions

 pp61 (const name_t &name)
 constructor More...
 
virtual void process (const CASSEvent &, result_t &)
 process event More...
 
virtual void loadSettings (size_t)
 load the settings More...
 
- Public Member Functions inherited from cass::AccumulatingProcessor
 AccumulatingProcessor (const name_t &name)
 constructor More...
 
virtual ~AccumulatingProcessor ()
 virtual destructor More...
 
virtual void processEvent (const CASSEvent &evt)
 process the event More...
 
virtual const result_tresult (const CASSEvent::id_t)
 retrieve a result. More...
 
virtual void releaseEvent (const CASSEvent &)
 overwrite default behaviour to do nothing More...
 
virtual void createHistList (result_t::shared_pointer result)
 create the list of results More...
 
- Public Member Functions inherited from cass::Processor
 Processor (const name_t &name)
 constructor More...
 
virtual ~Processor ()
 virtual destructor More...
 
result_t::shared_pointer resultCopy (const uint64_t eventid)
 retrieve histogram for id More...
 
virtual void load ()
 load the general settings More...
 
virtual void aboutToQuit ()
 function that will be called when the processor is about to be deleted More...
 
const names_tdependencies ()
 Define all processors keys a processor depends on. More...
 
void clearDependencies ()
 clear the dependenies More...
 
void clearHistograms ()
 clear the histograms More...
 
virtual void processCommand (std::string command)
 process command in pp More...
 
const name_t name () const
 retrieve the name of this processor More...
 
bool hide () const
 retrieve the hide flag of this processor More...
 
const std::string & comment () const
 retrieve the comment of this processor More...
 

Protected Member Functions

result_t::value_t average (result_t::value_t val, result_t::value_t aveOld, result_t::value_t scale)
 function for normal averaging. More...
 
result_t::value_t squareAverage (result_t::value_t val, result_t::value_t aveOld, result_t::value_t scale)
 function that will calculate the square average More...
 
result_t::value_t cumulativeScale ()
 retrieve the cumulative scale for the current datum More...
 
result_t::value_t movingScale ()
 retrieve the moving average scale after the initialization of the "first" point More...
 
result_t::value_t movingInitializationScale ()
 retrieve the moving average scale during the initialization More...
 
- Protected Member Functions inherited from cass::Processor
virtual void createHistList (result_t::shared_pointer result)
 create result list. More...
 
void setupGeneral ()
 general setup of the processor More...
 
bool setupCondition (bool defaultConditionType=true)
 setup the condition. More...
 
shared_pointer setupDependency (const std::string &depVarName, const name_t &name="")
 setup the dependecy. More...
 

Protected Attributes

result_t::value_t _alpha
 alpha for the running average More...
 
std::tr1::function< result_t::value_t(result_t::value_t, result_t::value_t, result_t::value_t)> _func
 function that will do the averagin More...
 
std::tr1::function< result_t::value_t()> _scale
 function that will return the scale that should be used for the average More...
 
shared_pointer _pHist
 processor containing result to average More...
 
- Protected Attributes inherited from cass::AccumulatingProcessor
result_t::shared_pointer _result
 the result that accumulates the events More...
 
size_t _nbrEventsAccumulated
 the number of events the processor has accumulated More...
 
- Protected Attributes inherited from cass::Processor
const name_t _name
 the processors name More...
 
bool _hide
 flag to tell whether this pp should be hidden in the dropdown list More...
 
std::string _comment
 optional comment that one can add to a processor. More...
 
CachedList _resultList
 the list of results More...
 
names_t _dependencies
 the list of dependencies More...
 
shared_pointer _condition
 pointer to the processor that will contain the condition More...
 

Additional Inherited Members

- Public Types inherited from cass::Processor
typedef std::tr1::shared_ptr< Processorshared_pointer
 a shared pointer of this More...
 
typedef std::string name_t
 define the name type More...
 
typedef std::list< name_tnames_t
 define the list of names More...
 
typedef CachedList::item_type result_t
 define the results More...
 
typedef CachedList::item_sp resultsp_t
 define the shared pointer to the result More...
 

Detailed Description

result averaging.

Available PostProcessors:
"61": Average of a result

Running or cummulative average of a result. Could also be a squared average.

See also
Processor for a list of all commonly available cass.ini settings.
User definable Parameters:

Processor/%name%/{AveragingType}
The type of averaging that should be performed. Default is "Normal"

  • "Normal": a normal average will be used
  • "Square"; a square averaging will be performed

Processor/%name%/{NbrOfAverages}
how many images should be averaged. When value is 0 its a cummulative average. Default is 1.

Processor/%name%/{InputName}
processor name containing the result that we average.

Author
Lutz Foucar

Definition at line 1096 of file operations.h.

Constructor & Destructor Documentation

pp61::pp61 ( const name_t name)

constructor

Definition at line 1477 of file operations.cpp.

References loadSettings().

Member Function Documentation

Processor::result_t::value_t pp61::average ( result_t::value_t  val,
result_t::value_t  aveOld,
result_t::value_t  scale 
)
protected

function for normal averaging.

this operator is capable of performing a cumulative moving average and a Exponential moving average.

See also
http://en.wikipedia.org/wiki/Moving_average

the operator calculates the average using the function $ave_{new} = ave_{old} + \scale(val-ave_{old})$ where when $\scale$ is equal to N it is a cumulative moving average, otherwise it will be a exponential moving average.

Returns
the new average
Parameters
valthe current value to be added to the average
aveOldthe old average
scalethe scale with which the new value will be weighted

Definition at line 1536 of file operations.cpp.

Referenced by loadSettings().

result_t::value_t cass::pp61::cumulativeScale ( )
inlineprotected

retrieve the cumulative scale for the current datum

Definition at line 1145 of file operations.h.

References cass::AccumulatingProcessor::_nbrEventsAccumulated.

Referenced by loadSettings(), and movingInitializationScale().

void pp61::loadSettings ( size_t  )
virtual

load the settings

: In case we're running a moving average (_alpha is non-zero), we need to initialize the the first value of the moving average. Here we initialize it with the mean of the first datapoints, meaning we'll check if the _alpha calculated for the cumulative averaging is still larger than the _alpha for the moving averge. If its smaller than the _alpha of the cumulative average it means that the current datum will not have as much weight. Therefore from this point onward, we should use the _alpha of the moving averge to start "forgetting" older values by putting comparatively more weight on the newer datums.

: initialize the result to be zero, otherwise the cumulatinve averaging won't produce correct results

Reimplemented from cass::Processor.

Definition at line 1483 of file operations.cpp.

References _alpha, cass::Processor::_condition, _func, _pHist, cass::AccumulatingProcessor::_result, _scale, cass::Log::add(), average(), QSettings::beginGroup(), cass::AccumulatingProcessor::createHistList(), cumulativeScale(), QString::fromStdString(), cass::Log::INFO, movingInitializationScale(), cass::Processor::name(), cass::Processor::setupCondition(), cass::Processor::setupDependency(), cass::Processor::setupGeneral(), squareAverage(), cass::toString(), and QSettings::value().

Referenced by pp61().

Processor::result_t::value_t pp61::movingInitializationScale ( )
protected

retrieve the moving average scale during the initialization

when the first value of the moving avererage has been initialized (see comment above), we can then procede by using the moving average's _alpha

Definition at line 1550 of file operations.cpp.

References _alpha, _scale, cumulativeScale(), and movingScale().

Referenced by loadSettings().

result_t::value_t cass::pp61::movingScale ( )
inlineprotected

retrieve the moving average scale after the initialization of the "first" point

Definition at line 1153 of file operations.h.

References _alpha.

Referenced by movingInitializationScale().

void pp61::process ( const CASSEvent evt,
result_t result 
)
virtual

process event

: the nbr of accumulated events needs to be increased BEFORE calculating the scale because the cumulative scale expect the scale to be $\frac{1}{n+1}$

Reimplemented from cass::Processor.

Definition at line 1564 of file operations.cpp.

References _func, cass::AccumulatingProcessor::_nbrEventsAccumulated, _pHist, _scale, cass::Result< T >::begin(), cass::Result< T >::datasize(), cass::CASSEvent::id(), and cass::Result< T >::lock.

Processor::result_t::value_t pp61::squareAverage ( result_t::value_t  val,
result_t::value_t  aveOld,
result_t::value_t  scale 
)
protected

function that will calculate the square average

the operator calculates the square average using the function $ave_{new} = ave_{old} + \scale(val*val-ave_{old})$ where when $\scale$ is equal to N it is a cumulative moving average.

Returns
the new average
Parameters
valthe current value to be added to the average
aveOldthe old average
scalethe scale with which the new value will be weighted

Definition at line 1543 of file operations.cpp.

Referenced by loadSettings().

Member Data Documentation

result_t::value_t cass::pp61::_alpha
protected

alpha for the running average

Definition at line 1160 of file operations.h.

Referenced by loadSettings(), movingInitializationScale(), and movingScale().

std::tr1::function<result_t::value_t(result_t::value_t,result_t::value_t,result_t::value_t)> cass::pp61::_func
protected

function that will do the averagin

Definition at line 1163 of file operations.h.

Referenced by loadSettings(), and process().

shared_pointer cass::pp61::_pHist
protected

processor containing result to average

Definition at line 1169 of file operations.h.

Referenced by loadSettings(), and process().

std::tr1::function<result_t::value_t()> cass::pp61::_scale
protected

function that will return the scale that should be used for the average

Definition at line 1166 of file operations.h.

Referenced by loadSettings(), movingInitializationScale(), and process().


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