FACT++  1.0
void DrsCalibrate::AddRel ( const int16_t *  val,
const int16_t *  start 
)
inline

Definition at line 52 of file DrsCalib.h.

References fNumChannels.

53  {
54  /*
55  for (size_t ch=0; ch<fNumChannels; ch++)
56  {
57  const int16_t &spos = start[ch];
58  if (spos<0)
59  continue;
60 
61  const size_t pos = ch*1024;
62  for (size_t i=0; i<1024; i++)
63  {
64  // Value is relative to trigger
65  // Abs is corresponding index relative to DRS pipeline
66  const size_t rel = pos + i;
67  const size_t abs = pos + (spos+i)%1024;
68 
69  const int64_t v = val[rel];
70 
71  fSum[abs] += v;
72  fSum2[abs] += v*v;
73  }
74  }*/
75 
76  // This version is 2.5 times faster because the compilers optimization
77  // is not biased by the evaluation of %1024
78  for (size_t ch=0; ch<fNumChannels; ch++)
79  {
80  const int16_t &spos = start[ch];
81  if (spos<0)
82  continue;
83 
84  const size_t pos = ch*1024;
85 
86  const int16_t *beg_val = val + pos;
87  int64_t *beg_sum = fSum.data() + pos;
88  int64_t *beg_sum2 = fSum2.data() + pos;
89 
90  const int16_t *pval = beg_val; // val[rel]
91  int64_t *psum = beg_sum + spos; // fSum[abs]
92  int64_t *psum2 = beg_sum2 + spos; // fSum2[abs]
93 
94  while (psum<beg_sum+1024)
95  {
96  const int64_t v = *pval++;
97 
98  *psum++ += v;
99  *psum2++ += v*v;
100  }
101 
102  psum = beg_sum;
103  psum2 = beg_sum2;
104 
105  while (pval<beg_val+1024)
106  {
107  const int64_t v = *pval++;
108 
109  *psum++ += v;
110  *psum2++ += v*v;
111  }
112  }
113 
114  fNumEntries++;
115  }
int start(int initState)
Definition: feeserver.c:1740
std::vector< int64_t > fSum
Definition: DrsCalib.h:23
std::vector< int64_t > fSum2
Definition: DrsCalib.h:24
size_t fNumChannels
Definition: DrsCalib.h:21
int64_t fNumEntries
Definition: DrsCalib.h:18