Changeset 6166 for trunk/MagicSoft
- Timestamp:
- 02/01/05 14:16:45 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilterPeakSearch.cc
r6157 r6166 81 81 const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgLoGainFirst = 0; 82 82 const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgLoGainLast = 14; 83 const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgOffsetLeftFromPeak = 1;83 const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgOffsetLeftFromPeak = 3; 84 84 const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgOffsetRightFromPeak = 3; 85 85 const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgPeakSearchWindowSize = 2; … … 102 102 fTitle = title ? title : "Digital Filter"; 103 103 104 SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast); 105 104 106 SetOffsetLeftFromPeak(); 105 107 SetOffsetRightFromPeak(); … … 137 139 fHiGainOutOfRangeLeft = 0; 138 140 fHiGainOutOfRangeRight = 0; 139 fLoGainOutOfRangeLeft 140 fLoGainOutOfRangeRight 141 fLoGainOutOfRangeLeft = 0; 142 fLoGainOutOfRangeRight = 0; 141 143 142 144 return kTRUE; … … 152 154 // saturated slices. 153 155 // 154 void MExtractTimeAndChargeDigitalFilterPeakSearch::FindPeak(Byte_t *ptr, Byte_t &startslice, Int_t &max,156 void MExtractTimeAndChargeDigitalFilterPeakSearch::FindPeak(Byte_t *ptr, Byte_t *logain, Byte_t &startslice, Int_t &max, 155 157 Int_t &sat, Byte_t &satpos) const 156 158 { 157 159 158 constByte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;160 Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1; 159 161 160 162 sat = 0; … … 208 210 } 209 211 212 if (!fHiLoLast) 213 return; 214 215 Byte_t *l = logain; 216 217 while (++p < end && l < logain+fHiLoLast) 218 { 219 sum += *l - *p; 220 if (sum > max) 221 { 222 max = sum; 223 startslice = p-ptr+1; 224 } 225 226 if (*l++ >= fSaturationLimit) 227 { 228 if (sat == 0) 229 satpos = l-logain + fHiGainLast - fHiGainFirst; 230 sat++; 231 } 232 } 233 234 if (fHiLoLast <= fPeakSearchWindowSize) 235 return; 236 237 while (l < logain+fHiLoLast) 238 { 239 if (*l++ >= fSaturationLimit) 240 { 241 if (sat == 0) 242 satpos = l-logain+fHiGainLast-fHiGainFirst; 243 sat++; 244 } 245 246 sum += *l - *(l-fPeakSearchWindowSize); 247 if (sum > max) 248 { 249 max = sum; 250 startslice = l-logain + fHiGainLast - fHiGainFirst - fPeakSearchWindowSize + 1; 251 } 252 } 253 210 254 return; 211 255 } … … 239 283 Byte_t loGainFirstsave = fLoGainFirst; 240 284 Byte_t loGainLastsave = fLoGainLast; 285 Byte_t hiLoLastsave = fHiLoLast; 241 286 242 287 Byte_t higainfirst = fHiGainFirst; … … 248 293 sat = 0; 249 294 250 FindPeak(pixel.GetHiGainSamples()+fHiGainFirst, startslice, sumhi, sat, satpos);295 FindPeak(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), startslice, sumhi, sat, satpos); 251 296 252 297 if (sumhi > maxsumhi && sat == 0) … … 279 324 // Shift the last slice to the right: 280 325 // 281 if (higainfirst + fOffsetRightFromPeak + fWindowSizeHiGain <= hiGainLastsave) 282 fHiGainLast = higainfirst + fOffsetRightFromPeak + fWindowSizeHiGain; 326 const Byte_t rlim = higainfirst + fOffsetRightFromPeak + fWindowSizeHiGain; 327 if (rlim <= hiGainLastsave+fHiLoLast) 328 if (rlim > hiGainLastsave) 329 fHiLoLast = rlim - fHiGainLast; 330 else 331 { 332 fHiLoLast = 0; 333 fHiGainLast = rlim; 334 } 283 335 else 284 336 fHiGainOutOfRangeRight++; 285 337 286 338 287 if ( fHiGainFirst+(Int_t)fOffsetLoGain >= fLoGainFirst ) 288 fLoGainFirst = fHiGainFirst + (Int_t)fOffsetLoGain; 339 const Byte_t llim = fHiGainFirst + (Int_t)fOffsetLoGain; 340 if ( llim >= fLoGainFirst ) 341 fLoGainFirst = llim; 289 342 else 290 343 fLoGainOutOfRangeLeft++; … … 302 355 while (pixel.Next()) 303 356 { 357 304 358 // 305 359 // Find signal in hi- and lo-gain … … 384 438 fLoGainFirst = loGainFirstsave; 385 439 fLoGainLast = loGainLastsave ; 440 fHiLoLast = hiLoLastsave; 386 441 387 442 return kTRUE;
Note:
See TracChangeset
for help on using the changeset viewer.