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

Definition at line 117 of file DrsCalib.h.

References fNumChannels.

119  {
120  /*
121  for (size_t ch=0; ch<fNumChannels; ch++)
122  {
123  const int16_t spos = start[ch];
124  if (spos<0)
125  continue;
126 
127  const size_t pos = ch*1024;
128 
129  for (size_t i=0; i<fNumSamples; i++)
130  {
131  // Value is relative to trigger
132  // Offset is relative to DRS pipeline
133  // Abs is corresponding index relative to DRS pipeline
134  const size_t rel = pos + i;
135  const size_t abs = pos + (spos+i)%1024;
136 
137  const int64_t v = int64_t(val[rel])*scale-offset[abs];
138 
139  fSum[abs] += v;
140  fSum2[abs] += v*v;
141  }
142  }*/
143 
144  // This version is 2.5 times faster because the compilers optimization
145  // is not biased by the evaluation of %1024
146  for (size_t ch=0; ch<fNumChannels; ch++)
147  {
148  const int16_t &spos = start[ch];
149  if (spos<0)
150  continue;
151 
152  const size_t pos = ch*1024;
153 
154  const int16_t *beg_val = val + pos;
155  const int32_t *beg_offset = offset + pos;
156  int64_t *beg_sum = fSum.data() + pos;
157  int64_t *beg_sum2 = fSum2.data() + pos;
158 
159 
160  const int16_t *pval = beg_val; // val[rel]
161  const int32_t *poffset = beg_offset + spos; // offset[abs]
162  int64_t *psum = beg_sum + spos; // fSum[abs]
163  int64_t *psum2 = beg_sum2 + spos; // fSum2[abs]
164 
165  while (psum<beg_sum+1024)
166  {
167  const int64_t v = int64_t(*pval++)*scale - *poffset++;
168 
169  *psum++ += v;
170  *psum2++ += v*v;
171  }
172 
173  psum = beg_sum;
174  psum2 = beg_sum2;
175  poffset = beg_offset;
176 
177  while (pval<beg_val+1024)
178  {
179  const int64_t v = int64_t(*pval++)*scale - *poffset++;
180 
181  *psum++ += v;
182  *psum2++ += v*v;
183  }
184  }
185 
186  fNumEntries++;
187  }
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