FACT++  1.0
static void DrsCalibrate::RemoveSpikes3 ( float *  vec,
uint32_t  roi 
)
inlinestatic

Definition at line 652 of file DrsCalib.h.

References i.

653  {
654  if (roi<4)
655  return;
656 
657  const float SingleCandidateTHR = -10.;
658  const float DoubleCandidateTHR = -5.;
659 
660  const std::vector<float> src(vec, vec+roi);
661 
662  std::vector<float> diff(roi);
663  for (size_t i=1; i<roi-1; i++)
664  diff[i] = src[i] - (src[i-1] + src[i+1])/2;
665 
666  // find the spike and replace it by mean value of neighbors
667  for (unsigned int i=1; i<roi-3; i++)
668  {
669  // Speed up (no leading edge)
670  if (diff[i]>=DoubleCandidateTHR)
671  continue;
672 
673  //bool checkDouble = false;
674 
675  // a single spike candidate
676  if (diff[i]<SingleCandidateTHR)
677  {
678  // check consistency with a single channel spike
679  if (diff[i+1] > -1.6*diff[i])
680  {
681  vec[i+1] = (src[i] + src[i+2]) / 2;
682 
683  i += 2;
684 
685  /*** NEW ***/
686  continue;
687  /*** NEW ***/
688  }
689  /*
690  else
691  {
692  // do nothing - not really a single spike,
693  // but check if it is a double
694  checkDouble = true;
695  }*/
696  }
697 
698  // a double spike candidate
699  //if (diff[i]>DoubleCandidateTHR || checkDouble == 1)
700  {
701  // check the consistency with a double spike
702  if ((diff[i+1] > -DoubleCandidateTHR) &&
703  (diff[i+2] > -DoubleCandidateTHR))
704  {
705  vec[i+1] = (src[i+3] - src[i])/3 + src[i];
706  vec[i+2] = 2*(src[i+3] - src[i])/3 + src[i];
707 
708  //vec[i] = (src[i-1] + src[i+2]) / 2.;
709  //vec[i+1] = (src[i-1] + src[i+2]) / 2.;
710 
711  //do not care about the next sample it was the spike
712  i += 3;
713  }
714  }
715  }
716  }
int i
Definition: db_dim_client.c:21