Changeset 16603 for trunk/Mars/mcore/DrsCalib.h
- Timestamp:
- 06/02/13 16:24:14 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/DrsCalib.h
r16561 r16603 29 29 30 30 public: 31 DrsCalibrate() : fNumEntries(0), fNumSamples(0), fNumChannels(0) { } 31 DrsCalibrate() : fNumEntries(0), fNumSamples(0), fNumChannels(0) 32 { 33 fSum.reserve(1024*1440); 34 fSum2.reserve(1024*1440); 35 } 36 32 37 void Reset() 33 38 { … … 45 50 fNumSamples = samples; 46 51 47 fSum. resize(samples*channels);48 fSum2. resize(samples*channels);52 fSum.assign(samples*channels, 0); 53 fSum2.assign(samples*channels, 0); 49 54 } 50 55 … … 71 76 fSum2[abs] += v*v; 72 77 } 73 */78 }*/ 74 79 75 80 // This version is 2.5 times faster because the compilers optimization … … 83 88 const size_t pos = ch*1024; 84 89 85 const int16_t *pval = val + pos; 86 const int16_t *end_val = val + 1024; 87 88 int64_t *beg_sum = fSum.data() + pos; 89 int64_t *beg_sum2 = fSum2.data() + pos; 90 91 int64_t *psum = beg_sum + spos; 92 int64_t *psum2 = beg_sum2 + spos; 90 const int16_t *beg_val = val + pos; 91 int64_t *beg_sum = fSum.data() + pos; 92 int64_t *beg_sum2 = fSum2.data() + pos; 93 94 const int16_t *pval = beg_val; // val[rel] 95 int64_t *psum = beg_sum + spos; // fSum[abs] 96 int64_t *psum2 = beg_sum2 + spos; // fSum2[abs] 93 97 94 98 while (psum<beg_sum+1024) … … 96 100 const int64_t v = *pval++; 97 101 98 *psum++ = v;99 *psum2++ = v*v;102 *psum++ += v; 103 *psum2++ += v*v; 100 104 } 101 105 … … 103 107 psum2 = beg_sum2; 104 108 105 while (pval< end_val)109 while (pval<beg_val+1024) 106 110 { 107 111 const int64_t v = *pval++; 108 112 109 *psum++ = v;110 *psum2++ = v*v;113 *psum++ += v; 114 *psum2++ += v*v; 111 115 } 112 116 } … … 152 156 const size_t pos = ch*1024; 153 157 154 const int16_t *pval = val + pos; 155 const int16_t *end_val = val + 1024; 156 157 const int32_t *beg_offset = offset + pos; 158 const int32_t *poffset = beg_offset + spos; 159 160 int64_t *beg_sum = fSum.data() + pos; 161 int64_t *beg_sum2 = fSum2.data() + pos; 162 163 int64_t *psum = beg_sum + spos; 164 int64_t *psum2 = beg_sum2 + spos; 158 const int16_t *beg_val = val + pos; 159 const int32_t *beg_offset = offset + pos; 160 int64_t *beg_sum = fSum.data() + pos; 161 int64_t *beg_sum2 = fSum2.data() + pos; 162 163 164 const int16_t *pval = beg_val; // val[rel] 165 const int32_t *poffset = beg_offset + spos; // offset[abs] 166 int64_t *psum = beg_sum + spos; // fSum[abs] 167 int64_t *psum2 = beg_sum2 + spos; // fSum2[abs] 165 168 166 169 while (psum<beg_sum+1024) … … 168 171 const int64_t v = int64_t(*pval++)*scale - *poffset++; 169 172 170 *psum++ = v;171 *psum2++ = v*v;173 *psum++ += v; 174 *psum2++ += v*v; 172 175 } 173 176 … … 176 179 poffset = beg_offset; 177 180 178 while (pval< end_val)181 while (pval<beg_val+1024) 179 182 { 180 183 const int64_t v = int64_t(*pval++)*scale - *poffset++; 181 184 182 *psum++ = v;183 *psum2++ = v*v;185 *psum++ += v; 186 *psum2++ += v*v; 184 187 } 185 188 } … … 244 247 fSum2[rel] += v*v; 245 248 } 246 }*/249 }*/ 247 250 248 251 // This version is 1.5 times faster because the compilers optimization … … 256 259 const size_t pos = ch*fNumSamples; 257 260 258 const int 16_t *pval = val + pos;259 260 const int32_t *beg_offset = offset + ch*1024;261 const int32_t *poffset = beg_offset + spos;262 263 int64_t *beg_sum = fSum.data() + pos; 264 int64_t *beg_sum2 = fSum2.data() + pos;265 266 int64_t *psum = beg_sum;267 int64_t *psum2 = beg_sum2;261 const int32_t *beg_offset = offset + ch*1024; 262 const int16_t *beg_val = val + pos; 263 int64_t *beg_sum = fSum.data() + pos; 264 int64_t *beg_sum2 = fSum2.data() + pos; 265 266 267 const int16_t *pval = beg_val; // val[rel] 268 const int32_t *poffset = beg_offset + spos; // offset[abs] 269 int64_t *psum = beg_sum; // fSum[rel] 270 int64_t *psum2 = beg_sum2; // fSum2[rel] 268 271 269 272 if (spos+fNumSamples>1024) … … 273 276 const int64_t v = int64_t(*pval++)*scale - *poffset++; 274 277 275 *psum++ = v;276 *psum2++ = v*v;278 *psum++ += v; 279 *psum2++ += v*v; 277 280 } 278 281 … … 284 287 const int64_t v = int64_t(*pval++)*scale - *poffset++; 285 288 286 *psum++ = v;287 *psum2++ = v*v;289 *psum++ += v; 290 *psum2++ += v*v; 288 291 } 289 292 } … … 302 305 return; 303 306 } 304 305 307 /* 306 308 for (size_t i=0; i<roi; i++) … … 317 319 const int64_t div = gain[abs]; 318 320 vec[i] = div==0 ? 0 : double(v)*scalegain/div; 319 }*/ 321 } 322 */ 320 323 321 324 // This version is faster because the compilers optimization 322 325 // is not biased by the evaluation of %1024 323 326 // (Here we are dominated by numerics... improvement ~10%) 324 const int32_t *poffset = offset + start; 325 const int64_t *pgain = gain + start; 326 const int16_t *pval = val; 327 328 float *pvec = vec; 327 const int32_t *poffset = offset + start; // offset[abs] 328 const int64_t *pgain = gain + start; // gain[abs] 329 const int16_t *pval = val; // val[rel] 330 float *pvec = vec; // vec[rel] 329 331 330 332 if (start+roi>1024) … … 382 384 const int64_t div = gain[abs]*scalerel; 383 385 vec[i] = div==0 ? 0 : double(v)*scalegain/div; 384 } */385 386 } 387 */ 386 388 // (Here we are dominated by numerics... improvement ~10%) 387 const int32_t *poffset = offset + start; 388 const int64_t *pgain = gain + start; 389 const int16_t *pval = val; 390 const int64_t *ptrgoff = trgoff; 391 392 float *pvec = vec; 389 const int32_t *poffset = offset + start; // offset[abs] 390 const int64_t *pgain = gain + start; // gain[abs] 391 const int16_t *pval = val; // val[rel] 392 const int64_t *ptrgoff = trgoff; // trgoff[rel] 393 float *pvec = vec; // vec[rel] 393 394 394 395 if (start+roi>1024)
Note:
See TracChangeset
for help on using the changeset viewer.