Changeset 5726 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
01/07/05 18:21:20 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msignal
Files:
2 edited

Legend:

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

    r5589 r5726  
    5151//  In case of odd numbers, the window will be modified.
    5252//
    53 //
    5453//  Call: SetOffsetFromWindow() to adjust the positionning of the extraction
    5554//  window w.r.t. the peak search window. An fOffsetFromWindow of 0 means that
     
    251250
    252251  return kTRUE;
    253  
    254252}
    255253
     
    262260// saturated slices.
    263261//
    264 void MExtractFixedWindowPeakSearch::FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, Int_t &max, Int_t &sat) const
     262void MExtractFixedWindowPeakSearch::FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, Int_t &max,
     263                                             Int_t &sat, Byte_t &satpos) const
    265264{
    266265
     
    268267
    269268  sat = 0;
     269  satpos = 0;
     270 
    270271  startslice = 0;
    271272  Int_t sum=0;
     
    281282      sum += *p;
    282283      if (*p++ >= fSaturationLimit)
    283         sat++;
     284        {
     285          if (sat == 0)
     286              satpos = p-ptr;
     287          sat++;
     288        }
    284289    }
    285290
     
    289294  while (p<end)
    290295    if (*p++ >= fSaturationLimit)
    291       sat++;
    292 
     296      {
     297        if (sat == 0)
     298          satpos = p-ptr;
     299        sat++;
     300      }
     301 
    293302  //
    294303  // Calculate the i-th sum of n as
     
    395404
    396405  Int_t sat;
     406  Byte_t  satpos;
     407  ULong_t gsatpos = 0;
     408
    397409  Int_t maxsumhi = -1000000;
     410  Int_t numsat   = 0;
    398411  Byte_t startslice;
    399412  Byte_t hiGainFirst = 0;
     
    406419      sat = 0;
    407420
    408       FindPeak(pixel.GetHiGainSamples()+fHiGainFirst, fPeakSearchWindowSize, startslice, sumhi, sat);
    409 
    410       if (sumhi > maxsumhi && sat == 0 )
     421      FindPeak(pixel.GetHiGainSamples()+fHiGainFirst, fPeakSearchWindowSize, startslice, sumhi, sat, satpos);
     422
     423      if (sumhi > maxsumhi && sat == 0)
    411424        {
    412425          maxsumhi = sumhi;
     
    416429            hiGainFirst = fHiGainFirst;
    417430        }
    418     }
    419 
    420 
    421   loGainFirst = ( hiGainFirst+fLoGainPeakShift > fLoGainFirst ) ?
    422     hiGainFirst+fLoGainPeakShift : fLoGainFirst;
     431      else if (sat)
     432        {
     433          numsat++;
     434          gsatpos += satpos;
     435        }
     436    }
     437
     438  // Check necessary for calibration events
     439  if (numsat > fSignals->GetSize()*0.9)
     440    hiGainFirst = gsatpos/numsat - 1;
     441
     442  loGainFirst = ( hiGainFirst+fLoGainPeakShift > fLoGainFirst )
     443    ? hiGainFirst+fLoGainPeakShift
     444    : fLoGainFirst;
    423445
    424446  // Make sure we will not integrate beyond the hi gain limit:
     
    434456  fSignals->Clear();
    435457
    436   sat = 0;
    437458  while (pixel.Next())
    438459    {
     
    448469      Byte_t satlo=0;
    449470      if (pixel.HasLoGain())
    450         {
    451           FindSignalLoGain(pixel.GetLoGainSamples()+loGainFirst, sumlo, satlo);
    452           if (satlo)
    453             sat++;
    454         }
     471        FindSignalLoGain(pixel.GetLoGainSamples()+loGainFirst, sumlo, satlo);
    455472
    456473      //
  • trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.h

    r5469 r5726  
    2929  void   FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const; 
    3030
    31   void   FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, Int_t &signal, Int_t &sat) const;
     31  void   FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, Int_t &signal, Int_t &sat, Byte_t &satpos) const;
    3232
    3333  Bool_t ReInit(MParList *pList);
     
    3737public:
    3838
    39     MExtractFixedWindowPeakSearch(const char *name=NULL, const char *title=NULL);
     39  MExtractFixedWindowPeakSearch(const char *name=NULL, const char *title=NULL);
     40 
     41  Byte_t GetHiGainWindowSize() const { return fHiGainWindowSize; }
     42  Byte_t GetLoGainWindowSize() const { return fLoGainWindowSize; }
    4043
    41     Byte_t GetHiGainWindowSize() const { return fHiGainWindowSize; }
    42     Byte_t GetLoGainWindowSize() const { return fLoGainWindowSize; }
     44  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);   
     45  void SetWindows(Byte_t windowh=fgHiGainWindowSize, Byte_t windowl=fgLoGainWindowSize,
     46                  Byte_t peaksearchwindow=fgPeakSearchWindowSize);
     47  void SetOffsetFromWindow(Byte_t offset=fgOffsetFromWindow)  {  fOffsetFromWindow = offset; }
     48 
     49  void SetLoGainPeakShift(Byte_t shift=fgLoGainPeakShift) { fLoGainPeakShift = shift; }
     50 
     51  void Print(Option_t *o="") const;
    4352
    44     void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);   
    45     void SetWindows(Byte_t windowh=fgHiGainWindowSize, Byte_t windowl=fgLoGainWindowSize,
    46                     Byte_t peaksearchwindow=fgPeakSearchWindowSize);
    47     void SetOffsetFromWindow(Byte_t offset=fgOffsetFromWindow)  {  fOffsetFromWindow = offset; }
    48 
    49     void SetLoGainPeakShift(Byte_t shift=fgLoGainPeakShift) { fLoGainPeakShift = shift; }
    50 
    51     void Print(Option_t *o="") const;
    52 
    53     ClassDef(MExtractFixedWindowPeakSearch, 1) // Signal Extractor for fixed size trigger-corrected extraction window
     53  ClassDef(MExtractFixedWindowPeakSearch, 1) // Signal Extractor for fixed size trigger-corrected extraction window
    5454};
    5555
Note: See TracChangeset for help on using the changeset viewer.