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

Definition at line 218 of file DrsCalib.h.

References fNumChannels, and fNumSamples.

220  {
221  /*
222  // 1440 without tm, 1600 with tm
223  for (size_t ch=0; ch<fNumChannels; ch++)
224  {
225  const int16_t spos = start[ch];
226  if (spos<0)
227  continue;
228 
229  const size_t pos = ch*fNumSamples;
230  const size_t drs = ch>1439 ? ((ch-1440)*9+8)*1024 : ch*1024;
231 
232  for (size_t i=0; i<fNumSamples; i++)
233  {
234  // Value is relative to trigger
235  // Offset is relative to DRS pipeline
236  // Abs is corresponding index relative to DRS pipeline
237  const size_t rel = pos + i;
238  const size_t abs = drs + (spos+i)%1024;
239 
240  const int64_t v = int64_t(val[rel])*scale-offset[abs];
241 
242  fSum[rel] += v;
243  fSum2[rel] += v*v;
244  }
245  }*/
246 
247  // This version is 1.5 times faster because the compilers optimization
248  // is not biased by the evaluation of %1024
249  for (size_t ch=0; ch<fNumChannels; ch++)
250  {
251  const int16_t &spos = start[ch];
252  if (spos<0)
253  continue;
254 
255  const size_t pos = ch*fNumSamples;
256 
257  const int32_t *beg_offset = offset + ch*1024;
258  const int16_t *beg_val = val + pos;
259  int64_t *beg_sum = fSum.data() + pos;
260  int64_t *beg_sum2 = fSum2.data() + pos;
261 
262 
263  const int16_t *pval = beg_val; // val[rel]
264  const int32_t *poffset = beg_offset + spos; // offset[abs]
265  int64_t *psum = beg_sum; // fSum[rel]
266  int64_t *psum2 = beg_sum2; // fSum2[rel]
267 
268  if (spos+fNumSamples>1024)
269  {
270  while (poffset<beg_offset+1024)
271  {
272  const int64_t v = int64_t(*pval++)*scale - *poffset++;
273 
274  *psum++ += v;
275  *psum2++ += v*v;
276  }
277 
278  poffset = beg_offset;
279  }
280 
281  while (psum<beg_sum+fNumSamples)
282  {
283  const int64_t v = int64_t(*pval++)*scale - *poffset++;
284 
285  *psum++ += v;
286  *psum2++ += v*v;
287  }
288  }
289 
290  fNumEntries++;
291  }
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 fNumSamples
Definition: DrsCalib.h:20
size_t fNumChannels
Definition: DrsCalib.h:21
int64_t fNumEntries
Definition: DrsCalib.h:18