Changeset 3887 for trunk


Ignore:
Timestamp:
04/29/04 15:06:48 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msignal
Files:
3 edited

Legend:

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

    r3868 r3887  
    3535//  determines the integration window position for all pixels of this event.
    3636//  For the moment we neglect time delays between pixels (which are in most
    37 //  cases small). The class is based on MExtractSignal2.
     37//  cases small). The class is based on MExtractSlidingWindow.
     38//
     39//  Call: SetRange(higainfirst, higainlast, logainfirst, logainlast)
     40//  to modify the ranges in which the window is allowed to move.
     41//  Defaults are:
     42//
     43//   fHiGainFirst =  fgHiGainFirst =  0
     44//   fHiGainLast  =  fgHiGainLast  =  14
     45//   fLoGainFirst =  fgLoGainFirst =  3
     46//   fLoGainLast  =  fgLoGainLast  =  14
     47//
     48//  Call: SetWindows(windowhigain, windowlogain,peaksearchwindow)
     49//  to modify the sliding window widths. Windows have to be an even number.
     50//  In case of odd numbers, the window will be modified.
     51//
     52//  Defaults are:
     53//
     54//   fHiGainWindowSize     = fgHiGainWindowSize     = 6
     55//   fLoGainWindowSize     = fgLoGainWindowSize     = 6
     56//   fPeakSearchWindowSize = fgPeakSearchWindowSize = 4
    3857//
    3958//////////////////////////////////////////////////////////////////////////////
     
    6180const Byte_t MExtractFixedWindowPeakSearch::fgHiGainFirst          = 0;
    6281const Byte_t MExtractFixedWindowPeakSearch::fgHiGainLast           = 14;
    63 const Byte_t MExtractFixedWindowPeakSearch::fgLoGainFirst          = 0;
     82const Byte_t MExtractFixedWindowPeakSearch::fgLoGainFirst          = 3;
    6483const Byte_t MExtractFixedWindowPeakSearch::fgLoGainLast           = 14;
    6584// --------------------------------------------------------------------------
     
    6786// Default constructor.
    6887//
     88// Sets:
     89// - fWindowSizeHiGain to fgWindowSizeHiGain
     90// - fWindowSizeLoGain to fgWindowSizeLoGain
     91// - fPeakSearchWindowSize to fgPeakSearchWindowSize
     92//
     93// Calls:
     94// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
     95//
    6996MExtractFixedWindowPeakSearch::MExtractFixedWindowPeakSearch(const char *name, const char *title)
     97    : fWindowSizeHiGain(fgHiGainWindowSize),
     98      fWindowSizeLoGain(fgLoGainWindowSize),
     99      fPeakSearchWindowSize(fgPeakSearchWindowSize)
    70100{
    71101
     
    74104
    75105  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
    76   SetWindows();
    77 }
    78 
     106}
     107
     108// --------------------------------------------------------------------------
     109//
     110// SetRange:
     111//
     112// Calls:
     113// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
     114// - SetWindows(fWindowSizeHiGain,fWindowSizeLoGain,fPeakSearchWindowSize);
     115//
     116void MExtractFixedWindowPeakSearch::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
     117{
     118
     119  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
     120
     121  //
     122  // Redo the checks if the window is still inside the ranges
     123  //
     124  SetWindows(fWindowSizeHiGain,fWindowSizeLoGain,fPeakSearchWindowSize);
     125 
     126}
     127
     128// --------------------------------------------------------------------------
     129//
     130// Checks:
     131// - if a window is odd, subtract one
     132// - if a window is bigger than the one defined by the ranges, set it to the available range
     133// - if a window is smaller than 2, set it to 2
     134//
     135// Sets:
     136// - fNumHiGainSamples to: (Float_t)fWindowSizeHiGain
     137// - fNumLoGainSamples to: (Float_t)fWindowSizeLoGain
     138// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
     139// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples) 
     140// 
    79141void MExtractFixedWindowPeakSearch::SetWindows(Byte_t windowh, Byte_t windowl, Byte_t peaksearchwindow)
    80142{
    81   //
    82   // Set windows to even number of slices due to clock noise (odd/even slice effect).
    83   //
    84   fWindowSizeHiGain = windowh & ~1;
    85   fWindowSizeLoGain = windowl & ~1;
     143
     144  fWindowSizeHiGain     = windowh & ~1;
     145  fWindowSizeLoGain     = windowl & ~1;
    86146  fPeakSearchWindowSize = peaksearchwindow & ~1;
    87147
    88 
    89148  if (fWindowSizeHiGain != windowh)
    90     *fLog << endl << warn <<
    91       "MExtractFixedWindowPeakSearch::SetWindows - Hi Gain window size has to be even, set to: "
    92           << int(fWindowSizeHiGain) << " samples " << endl;
     149    *fLog << warn << GetDescriptor() << ": Hi Gain window size has to be even, set to: "
     150          << int(fWindowSizeHiGain) << " samples " << endl;
     151 
     152  if (fWindowSizeLoGain != windowl)
     153    *fLog << warn << GetDescriptor() << ": Lo Gain window size has to be even, set to: "
     154          << int(fWindowSizeLoGain) << " samples " << endl;
    93155   
    94   if (fWindowSizeLoGain != windowl)
    95     *fLog << endl << warn <<
    96       "MExtractFixedWindowPeakSearch::SetWindows - Lo Gain window size has to be even, set to: "
    97           << int(fWindowSizeLoGain) << " samples " << endl;
    98 
    99156  if (fPeakSearchWindowSize != peaksearchwindow)
    100     *fLog << endl << warn <<
    101       "MExtractFixedWindowPeakSearch::SetWindows - Peak Search window size has to be even, set to: "
    102           << int(fPeakSearchWindowSize) << " samples " << endl;
    103 
    104 
     157    *fLog << warn << GetDescriptor() << ": Peak Search window size has to be even, set to: "
     158          << int(fPeakSearchWindowSize) << " samples " << endl;
     159
     160  const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1;
     161  const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
     162
     163  if (fWindowSizeHiGain > availhirange)
     164    {
     165      *fLog << warn << GetDescriptor()
     166            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fWindowSizeHiGain,
     167                    " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
     168      *fLog << warn << GetDescriptor()
     169            << ": Will set window size to: " << (int)availhirange << endl;
     170      fWindowSizeHiGain = availhirange;
     171    }
     172 
     173  if (fWindowSizeLoGain > availlorange)
     174    {
     175      *fLog << warn << GetDescriptor()
     176            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
     177                    " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
     178      *fLog << warn << GetDescriptor()
     179            << ": Will set window size to: " << (int)availlorange << endl;
     180      fWindowSizeLoGain = availlorange;
     181    }
     182 
    105183  if (fWindowSizeHiGain<2)
    106184    {
    107185      fWindowSizeHiGain = 2;
    108       *fLog << warn
    109             << "MExtractFixedWindowPeakSearch::SetWindows - Hi Gain window size set to two samples" << endl;
    110     }
    111 
     186      *fLog << warn << GetDescriptor() << ": Hi Gain window size set to two samples" << endl;
     187    }
     188 
    112189  if (fWindowSizeLoGain<2)
    113190    {
    114191      fWindowSizeLoGain = 2;
    115       *fLog << warn
    116             << "MExtractFixedWindowPeakSearch::SetWindows - Lo Gain window size set to two samples" << endl;
     192      *fLog << warn << GetDescriptor() << ": Lo Gain window size set to two samples" << endl;
    117193    }
    118194
     
    120196    {
    121197      fPeakSearchWindowSize = 2;
    122       *fLog << warn
    123             << "MExtractFixedWindowPeakSearch::SetWindows - Peak Search window size set to two samples" << endl;
     198      *fLog << warn << GetDescriptor()
     199            << ": Peak Search window size set to two samples" << endl;
    124200    }
    125201
     
    143219                               Int_t &max, Int_t &sat) const
    144220{
     221
    145222  const Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
    146223
     
    188265// --------------------------------------------------------------------------
    189266//
    190 // FindSignal
    191 // Adds up "window" slices starting in slice to which "ptr" points. The result
    192 // is stored in "sum", and the number of saturated  slices in "sat".
    193 //
     267// FindSignalHiGain:
     268//
     269// - Loop from ptr to (ptr+fWindowSizeHiGain)
     270// - Sum up contents of *ptr
     271// - If *ptr is greater than fSaturationLimit, raise sat by 1
     272//
    194273void MExtractFixedWindowPeakSearch::FindSignalHiGain(Byte_t *ptr, Int_t &sum, Byte_t &sat) const
    195274{
     
    213292// --------------------------------------------------------------------------
    214293//
    215 // FindSignal
    216 // Adds up "window" slices starting in slice to which "ptr" points. The result
    217 // is stored in "sum", and the number of saturated  slices in "sat".
    218 //
     294// FindSignalLoGain:
     295//
     296// - Loop from ptr to (ptr+fWindowSizeLoGain)
     297// - Sum up contents of *ptr
     298// - If *ptr is greater than fSaturationLimit, raise sat by 1
     299//
    219300void MExtractFixedWindowPeakSearch::FindSignalLoGain(Byte_t *ptr, Int_t &sum, Byte_t &sat) const
    220301{
     
    262343      sat = 0;
    263344
    264       FindPeak(pixel.GetHiGainSamples(), fPeakSearchWindowSize, startslice, sumhi, sat);
     345      FindPeak(pixel.GetHiGainSamples()+fHiGainFirst, fPeakSearchWindowSize, startslice, sumhi, sat);
     346
    265347      if (sumhi > maxsumhi && sat == 0 )
    266348        {
    267349          maxsumhi = sumhi;
    268350          if (startslice > 0)
    269             hiGainFirst = startslice-1;
     351            hiGainFirst = fHiGainFirst + startslice - 1;
    270352          else
    271             hiGainFirst = 0;
     353            hiGainFirst = fHiGainFirst;
    272354        }
    273355    }
    274356
    275357
    276   loGainFirst = hiGainFirst;
     358  loGainFirst = ( hiGainFirst > fLoGainFirst ) ? hiGainFirst : fLoGainFirst;
    277359
    278360  // Make sure we will not integrate beyond the hi gain limit:
     
    327409    } /* while (pixel.Next()) */
    328410
     411
    329412  fSignals->SetReadyToSave();
    330413
  • trunk/MagicSoft/Mars/msignal/MExtractFixedWindowPeakSearch.h

    r3868 r3887  
    1818  static const Byte_t fgPeakSearchWindowSize; // The window in which the global peak is searched for
    1919
     20  Byte_t  fWindowSizeHiGain;     // Number of Hi Gain slices in window
     21  Byte_t  fWindowSizeLoGain;     // Number of Lo Gain slices in window
    2022  Byte_t  fPeakSearchWindowSize; // Size of FADC window in the search for the highest peak of all pixels.
    2123
    22   Byte_t  fWindowSizeHiGain;     // Number of Hi Gain slices in window
    23   Byte_t  fWindowSizeLoGain;     // Number of Lo Gain slices in window
    2424
    2525  void   FindSignalHiGain(Byte_t *ptr, Int_t &sum, Byte_t &sat) const;
     
    3434    MExtractFixedWindowPeakSearch(const char *name=NULL, const char *title=NULL);
    3535
     36    void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);   
    3637    void SetWindows(Byte_t windowh=fgHiGainWindowSize, Byte_t windowl=fgLoGainWindowSize,
    3738                    Byte_t peaksearchwindow=fgPeakSearchWindowSize);
  • trunk/MagicSoft/Mars/msignal/MExtractor.cc

    r3881 r3887  
    132132        return kFALSE;
    133133
    134     fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
    135                                 fLoGainFirst, fLoGainLast, fNumLoGainSamples);
    136 
    137134    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
    138135
     
    162159// modifying the ranges again, if necessary.
    163160//
     161// Call:
     162// - MExtractedSignalCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
     163//                                          fLoGainFirst, fLoGainLast, fNumLoGainSamples);
     164//
    164165Bool_t MExtractor::ReInit(MParList *pList)
    165166{
     
    195196    }
    196197
     198  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
     199                              fLoGainFirst, fLoGainLast, fNumLoGainSamples);
     200
    197201  return kTRUE;
    198202}
Note: See TracChangeset for help on using the changeset viewer.