FACT++  1.0
void DrsCalibrateTime::AddT ( const float *  val,
const int16_t *  start,
signed char  edge = 0 
)
inline

Definition at line 977 of file DrsCalib.h.

References first, i, DrsCalibrate::Step::pos, second, and v0.

978  {
979  if (fNumSamples!=1024 || fNumChannels!=160)
980  return;
981 
982  // Rising or falling edge detection has the advantage that
983  // we are much less sensitive to baseline shifts
984 
985  for (size_t ch=0; ch<160; ch++)
986  {
987  const size_t tm = ch*9+8;
988 
989  const int16_t spos = start[tm];
990  if (spos<0)
991  continue;
992 
993  const size_t pos = ch*1024;
994 
995  double p_prev = 0;
996  int32_t i_prev = -1;
997 
998  for (size_t i=0; i<1024-1; i++)
999  {
1000  const size_t rel = tm*1024 + i;
1001 
1002  const float &v0 = val[rel]; //-avg;
1003  const float &v1 = val[rel+1];//-avg;
1004 
1005  // If edge is positive ignore all falling edges
1006  if (edge>0 && v0>0)
1007  continue;
1008 
1009  // If edge is negative ignore all falling edges
1010  if (edge<0 && v0<0)
1011  continue;
1012 
1013  // Check if there is a zero crossing
1014  if ((v0<0 && v1<0) || (v0>0 && v1>0))
1015  continue;
1016 
1017  // Calculate the position p of the zero-crossing
1018  // within the interval [rel, rel+1] relative to rel
1019  // by linear interpolation.
1020  const double p = v0==v1 ? 0.5 : v0/(v0-v1);
1021 
1022  // If this was at least the second zero-crossing detected
1023  if (i_prev>=0)
1024  {
1025  // Calculate the distance l between the
1026  // current and the last zero-crossing
1027  const double l = i+p - (i_prev+p_prev);
1028 
1029  // By summation, the average length of each
1030  // cell is calculated. For the first and last
1031  // fraction of a cell, the fraction is applied
1032  // as a weight.
1033  const double w0 = 1-p_prev;
1034  fStat[pos+(spos+i_prev)%1024].first += w0*l;
1035  fStat[pos+(spos+i_prev)%1024].second += w0;
1036 
1037  for (size_t k=i_prev+1; k<i; k++)
1038  {
1039  fStat[pos+(spos+k)%1024].first += l;
1040  fStat[pos+(spos+k)%1024].second += 1;
1041  }
1042 
1043  const double w1 = p;
1044  fStat[pos+(spos+i)%1024].first += w1*l;
1045  fStat[pos+(spos+i)%1024].second += w1;
1046  }
1047 
1048  // Remember this zero-crossing position
1049  p_prev = p;
1050  i_prev = i;
1051  }
1052  }
1053  fNumEntries++;
1054  }
int start(int initState)
Definition: feeserver.c:1740
Return to feeserver c CVS log Up to[MAIN] dcscvs FeeServer feeserver src Wed FeeServer_v0 v0 FeeServer_v0 v0 FeeServer_v0 v0 FeeServer_v0 v0 FeeServer_v0 v0 FeeServer_v0 v0
Definition: feeserver.c:5
structure for storing edges of hexagons (for blurry display)
Definition: BasicGlCamera.h:23
std::vector< std::pair< double, double > > fStat
Definition: DrsCalib.h:938
size_t fNumSamples
Definition: DrsCalib.h:935
int i
Definition: db_dim_client.c:21
int64_t second
offset of this column in the tile, from the start of the heap area
Definition: zofits.h:27
int64_t first
Size of this column in the tile.
Definition: zofits.h:26
size_t fNumChannels
Definition: DrsCalib.h:936
int64_t fNumEntries
Definition: DrsCalib.h:933