FACT++  1.0
pair<vector<float>, vector<float> > StateMachineFeedback::AverageCurrents ( const int16_t *  ptr,
int  n 
)
inlineprivate

Definition at line 174 of file feedback.cc.

References i, and BIAS::kNumChannels.

175  {
176  if (fCursorCur++>=0)
177  {
178  for (int i=0; i<BIAS::kNumChannels; i++)
179  {
180  fCurrentsAvg[i] += ptr[i];
181  fCurrentsRms[i] += ptr[i]*ptr[i];
182  }
183  }
184 
185  if (fCursorCur<n)
186  return make_pair(vector<float>(), vector<float>());
187 
188  const double conv = 5e-3/4096;
189 
190  vector<float> rms(BIAS::kNumChannels);
191  vector<float> avg(BIAS::kNumChannels);
192  for (int i=0; i<BIAS::kNumChannels; i++)
193  {
194  avg[i] = double(fCurrentsAvg[i])/fCursorCur * conv;
195  rms[i] = double(fCurrentsRms[i])/fCursorCur * conv * conv;
196  rms[i] -= avg[i]*avg[i];
197  rms[i] = rms[i]<0 ? 0 : sqrt(rms[i]);
198  }
199 
200  return make_pair(avg, rms);
201  }
int i
Definition: db_dim_client.c:21
vector< int64_t > fCurrentsAvg
Definition: feedback.cc:49
vector< int64_t > fCurrentsRms
Definition: feedback.cc:50