Changeset 6166 for trunk


Ignore:
Timestamp:
02/01/05 14:16:45 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilterPeakSearch.cc

    r6157 r6166  
    8181const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgLoGainFirst             =  0;
    8282const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgLoGainLast              = 14;
    83 const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgOffsetLeftFromPeak      =  1;
     83const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgOffsetLeftFromPeak      =  3;
    8484const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgOffsetRightFromPeak     =  3;
    8585const Byte_t MExtractTimeAndChargeDigitalFilterPeakSearch::fgPeakSearchWindowSize    =  2;
     
    102102    fTitle = title ? title : "Digital Filter";
    103103
     104    SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
     105
    104106    SetOffsetLeftFromPeak();
    105107    SetOffsetRightFromPeak();
     
    137139  fHiGainOutOfRangeLeft  = 0;
    138140  fHiGainOutOfRangeRight = 0;
    139   fLoGainOutOfRangeLeft   = 0;
    140   fLoGainOutOfRangeRight  = 0;
     141  fLoGainOutOfRangeLeft  = 0;
     142  fLoGainOutOfRangeRight = 0;
    141143 
    142144  return kTRUE;
     
    152154// saturated slices.
    153155//
    154 void MExtractTimeAndChargeDigitalFilterPeakSearch::FindPeak(Byte_t *ptr, Byte_t &startslice, Int_t &max,
     156void MExtractTimeAndChargeDigitalFilterPeakSearch::FindPeak(Byte_t *ptr, Byte_t *logain, Byte_t &startslice, Int_t &max,
    155157                                                            Int_t &sat, Byte_t &satpos) const
    156158{
    157159
    158   const Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
     160  Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
    159161
    160162  sat = 0;
     
    208210    }
    209211
     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
    210254  return;
    211255}
     
    239283  Byte_t loGainFirstsave = fLoGainFirst;
    240284  Byte_t loGainLastsave  = fLoGainLast;
     285  Byte_t hiLoLastsave    = fHiLoLast;
    241286
    242287  Byte_t higainfirst     = fHiGainFirst;
     
    248293      sat = 0;
    249294
    250       FindPeak(pixel.GetHiGainSamples()+fHiGainFirst, startslice, sumhi, sat, satpos);
     295      FindPeak(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), startslice, sumhi, sat, satpos);
    251296
    252297      if (sumhi > maxsumhi && sat == 0)
     
    279324  // Shift the last slice to the right:
    280325  //
    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      }
    283335  else
    284336    fHiGainOutOfRangeRight++;
    285337     
    286338
    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;
    289342  else
    290343    fLoGainOutOfRangeLeft++;
     
    302355  while (pixel.Next())
    303356    {
     357
    304358      //
    305359      // Find signal in hi- and lo-gain
     
    384438  fLoGainFirst  = loGainFirstsave;
    385439  fLoGainLast   = loGainLastsave ;
     440  fHiLoLast     = hiLoLastsave;
    386441
    387442  return kTRUE;
Note: See TracChangeset for help on using the changeset viewer.