Changeset 11831 for trunk/Mars/mcore
- Timestamp:
- 08/07/11 16:42:21 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/DrsCalib.h
r11816 r11831 204 204 static void Apply(float *vec, const int16_t *val, const int16_t *start, uint32_t roi, 205 205 const int32_t *offset, const uint32_t scaleabs, 206 const int64_t *gain, const uint64_t scalegain, 207 const int64_t *trgoff, const uint64_t scalerel) 208 { 206 const int64_t *gain, /*const*/ uint64_t scalegain, 207 const int64_t *trgoff, /*const*/ uint64_t scalerel) 208 { 209 210 /* 211 scalegain *= scaleabs; 212 scalerel *= scaleabs; 213 209 214 for (size_t ch=0; ch<1440; ch++) 210 215 { 211 216 const size_t pos = ch*roi; 212 213 217 const int16_t spos = start[ch]; 214 218 if (spos<0) … … 236 240 vec[rel] = double(v)*scalegain/div; 237 241 } 242 }*/ 243 244 for (size_t ch=0; ch<1440; ch++) 245 { 246 const size_t pos = ch*roi; 247 248 const int16_t spos = start[ch]; 249 if (spos<0) 250 { 251 memset(vec+pos, 0, roi); 252 continue; 253 } 254 255 for (size_t i=0; i<roi; i++) 256 { 257 // Value is relative to trigger 258 // Offset is relative to DRS pipeline 259 // Abs is corresponding index relative to DRS pipeline 260 const size_t rel = pos + i; 261 const size_t abs = pos + (spos+i)%1024; 262 263 const int64_t v = 264 + (int64_t(val[rel])*scaleabs-offset[abs])*scalerel 265 - trgoff[rel] 266 ; 267 268 const int64_t div = gain[abs]*scalerel; 269 vec[rel] = double(v)*scalegain/div; 270 } 238 271 } 239 272 } … … 317 350 static void GetPixelStats(float *ptr, const float *data, uint16_t roi) 318 351 { 352 if (roi==0) 353 return; 354 319 355 for (int i=0; i<1440; i++) 320 356 { 321 357 const float *vec = data+i*roi; 322 358 323 double max = vec[0]; 324 int pos = 0; 359 int pos = 0; 325 360 double sum = vec[0]; 326 361 double sum2 = vec[0]*vec[0]; … … 330 365 sum2 += vec[j]*vec[j]; 331 366 332 if (vec[j]>max) 333 { 334 max = vec[j]; 367 if (vec[j]>vec[pos]) 335 368 pos = j; 336 }337 369 } 338 370 sum /= roi; … … 341 373 *(ptr+0*1440+i) = sum; 342 374 *(ptr+1*1440+i) = sqrt(sum2 - sum * sum); 343 *(ptr+2*1440+i) = max;375 *(ptr+2*1440+i) = vec[pos]; 344 376 *(ptr+3*1440+i) = pos; 345 377 }
Note:
See TracChangeset
for help on using the changeset viewer.