FairRoot/PandaRoot
PndEmcPSAFPGAFilterMWD.cxx
Go to the documentation of this file.
2 #include <math.h>
3 
5  buffer(0)
6  ,bpointer(0)
7 {
8 }
9 
11 {
12  buffer.resize(0);
13 }
14 
15 void PndEmcPSAFPGAFilterMWD::set(float tau, unsigned int newBufferSize)
16 {
17  buffer.resize(newBufferSize);
18  for(unsigned int i=0; i<newBufferSize; i++)
19  buffer[i]=0;
20  bpointer=0;
21  sum = 0.0;
22  lambda = 1.0/tau;
23 }
24 
25 //#include <iostream>
26 float PndEmcPSAFPGAFilterMWD::put(float valueToStore){
27  //std::cout<<"buffer# "<<buffer.size()<<std::endl;
28  bpointer %= buffer.size();
29  float diff = valueToStore - buffer[bpointer];
30  float mwd = diff + lambda*sum;
31  sum += diff;
32  buffer[bpointer] = valueToStore;
33  bpointer++;
34  return mwd;
35 }
36 
38  for(unsigned int i=0; i<buffer.size(); i++) {
39  buffer[i]=0;
40  }
41  bpointer = 0.;
42  sum = 0.;
43 }
Int_t i
Definition: run_full.C:25
std::vector< float > buffer
void set(float tau, unsigned int newBufferSize)
virtual float put(float valueToStore)