Ignore:
Timestamp:
11/29/04 16:45:57 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msignal
Files:
8 edited

Legend:

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

    r5499 r5504  
    127127// - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
    128128//                                      fLoGainFirst, fLoGainLast, fNumLoGainSamples);
     129// - InitArrays();
    129130//
    130131Bool_t MExtractTimeAndCharge::ReInit(MParList *pList)
     
    138139                                fLoGainFirst, fLoGainLast, fNumLoGainSamples);
    139140 
    140   *fLog << dec << endl;
    141   *fLog << inf << "Taking " << fNumHiGainSamples
    142         << " HiGain samples from slice " << (Int_t)fHiGainFirst
    143         << " to " << (Int_t)(fHiGainLast+fHiLoLast) << " incl" << endl;
    144   *fLog << inf << "Taking " << fNumLoGainSamples
    145         << " LoGain samples from slice " << (Int_t)fLoGainFirst
    146         << " to " << (Int_t)fLoGainLast << " incl" << endl;
    147  
     141  InitArrays();
     142  Print();
     143
    148144  return kTRUE;
    149145}
    150 
    151 void MExtractTimeAndCharge::FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum,
    152                                                     Float_t &time, Float_t &dtime,
    153                                                     Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag)
    154 {
    155   return;
    156 }
    157 
    158 void MExtractTimeAndCharge::FindTimeAndChargeLoGain(Byte_t *firstused, Float_t &sum, Float_t &dsum,
    159                                                     Float_t &time, Float_t &dtime,
    160                                                     Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag)
    161 {
    162   return;
    163 }
    164 
    165146
    166147// --------------------------------------------------------------------------
     
    261242void MExtractTimeAndCharge::Print(Option_t *o) const
    262243{
    263     *fLog << all;
    264     if (IsA()==MExtractTimeAndCharge::Class())
    265         *fLog << GetDescriptor() << ":" << endl;
    266 
    267     *fLog << " LoGainStartShift: " << fLoGainStartShift << endl;
    268     MExtractTime::Print(o);
    269 }
     244
     245  *fLog << all;
     246  if (IsA()==MExtractTimeAndCharge::Class())
     247    *fLog << GetDescriptor() << ":" << endl;
     248 
     249  *fLog << dec << endl;
     250  *fLog << inf << "Taking " << fNumHiGainSamples
     251        << " HiGain samples from slice " << (Int_t)fHiGainFirst
     252        << " to " << (Int_t)(fHiGainLast+fHiLoLast) << " incl" << endl;
     253  *fLog << inf << "Taking " << fNumLoGainSamples
     254        << " LoGain samples from slice " << (Int_t)fLoGainFirst
     255        << " to " << (Int_t)fLoGainLast << " incl" << endl;
     256 
     257  *fLog << " LoGainStartShift: " << fLoGainStartShift << endl;
     258  MExtractTime::Print(o);
     259}
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndCharge.h

    r5483 r5504  
    1818protected:
    1919
     20  Int_t  fWindowSizeHiGain;       //  Window Size High-Gain
     21  Int_t  fWindowSizeLoGain;       //  Window Size Low-Gain
     22
    2023  Int_t  PreProcess(MParList *pList);
     24  Int_t  Process();
    2125  Bool_t ReInit(MParList *pList);
    22   Int_t  Process();
    2326
    2427  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
     
    2831  MExtractTimeAndCharge(const char *name=NULL, const char *title=NULL);
    2932 
     33  Int_t GetWindowSizeHiGain() const { return fWindowSizeHiGain; }
     34  Int_t GetWindowSizeLoGain() const { return fWindowSizeLoGain; }
     35
     36  void Print(Option_t *o="") const;
     37 
    3038  void SetLoGainStartShift( const Float_t f=fgLoGainStartShift )  { fLoGainStartShift = f + fOffsetLoGain;  }
    31    
    32   void Print(Option_t *o) const;
     39  virtual void SetWindowSize(Int_t windowh, Int_t windowl) { fWindowSizeHiGain = windowh;
     40                                                           fWindowSizeLoGain = windowl;  }
    3341 
     42  virtual void InitArrays() {}
     43
    3444  virtual void FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum,
    3545                                       Float_t &time, Float_t &dtime,
    36                                        Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag);
     46                                       Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag) { }
     47 
    3748  virtual void FindTimeAndChargeLoGain(Byte_t *firstused, Float_t &sum,  Float_t &dsum,
    3849                                       Float_t &time, Float_t &dtime,
    39                                        Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag);
     50                                       Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag) { }
    4051
    4152  ClassDef(MExtractTimeAndCharge, 1)   // Time And Charge Extractor Base Class
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc

    r5495 r5504  
    193193      return kFALSE;
    194194
    195   Print();
    196 
    197195  return MExtractTimeAndCharge::PreProcess(pList);
    198196}
     
    208206Bool_t MExtractTimeAndChargeDigitalFilter::ReInit(MParList *pList)
    209207{
    210     if (!MExtractTimeAndCharge::ReInit(pList))
    211         return kFALSE;
    212 
    213     fHiGainSignal.Set(fHiGainLast - fHiGainFirst + 1 + fHiLoLast);
    214     fLoGainSignal.Set(fLoGainLast - fLoGainFirst + 1);
    215 
    216     fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain;
    217     fTimeShiftLoGain = (Float_t)fLoGainFirst + 0.5 + 1./fBinningResolutionLoGain;
    218 
    219     return kTRUE;
     208  if (!MExtractTimeAndCharge::ReInit(pList))
     209    return kFALSE;
     210
     211  fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain;
     212  fTimeShiftLoGain = (Float_t)fLoGainFirst + 0.5 + 1./fBinningResolutionLoGain;
     213 
     214  return kTRUE;
    220215}
    221216
    222 
     217// --------------------------------------------------------------------------
     218//
     219// InitArrays
     220//
     221// Gets called in the ReInit() and initialized the arrays
     222//
     223void MExtractTimeAndChargeDigitalFilter::InitArrays()
     224{
     225  fHiGainSignal.Set(fHiGainLast - fHiGainFirst + 1 + fHiLoLast);
     226  fLoGainSignal.Set(fLoGainLast - fLoGainFirst + 1);
     227}
     228
     229// --------------------------------------------------------------------------
     230//
     231// Apply the digital filter algorithm to the high-gain slices.
     232//
    223233void MExtractTimeAndChargeDigitalFilter::FindTimeAndChargeHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Float_t &dsum,
    224234                                                                 Float_t &time, Float_t &dtime,
     
    378388}
    379389
     390// --------------------------------------------------------------------------
     391//
     392// Apply the digital filter algorithm to the low-gain slices.
     393//
    380394void MExtractTimeAndChargeDigitalFilter::FindTimeAndChargeLoGain(Byte_t *ptr, Float_t &sum, Float_t &dsum,
    381395                                                                 Float_t &time, Float_t &dtime,
     
    9871001    *fLog << GetDescriptor() << ":" << endl;
    9881002
     1003    MExtractTimeAndCharge::Print(o);
    9891004    *fLog << " Time Shift HiGain:  " << fTimeShiftHiGain << endl;
    9901005    *fLog << " Time Shift LoGain:  " << fTimeShiftLoGain << endl;
     
    9941009    *fLog << " Binning Res LoGain: " << fBinningResolutionHiGain << endl;
    9951010 
     1011    TString opt(o);
     1012    if (!opt.Contains("weights"))
     1013      return;
     1014
    9961015    *fLog << endl;
    9971016    *fLog << inf << "Using the following weights: " << endl;
     
    10041023      *fLog << " " << fAmpWeightsLoGain[i] << " \t " << fTimeWeightsLoGain[i] << endl;
    10051024   
    1006     MExtractTimeAndCharge::Print(o);
    10071025}
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.h

    r5494 r5504  
    3838  Int_t   fSignalStartBinLoGain;                //! Start bin from when on to apply weights
    3939
    40   Int_t   fWindowSizeHiGain;                    //  Weights Window Size High-Gain
    41   Int_t   fWindowSizeLoGain;                    //  Weights Window Size Low-Gain
    42 
    4340  Int_t   fBinningResolutionHiGain;             //  Number of weights per bin High-Gain
    4441  Int_t   fBinningResolutionHalfHiGain;         //  Half Number of weights per bin High-Gain
     
    5754  Int_t PreProcess(MParList *pList);
    5855
     56  void InitArrays();
     57
    5958  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    6059
     
    7069
    7170  void SetNameWeightsFile( TString s = fgNameWeightsFile )   { fNameWeightsFile = s; }
    72   void SetWindowSize(Int_t windowh=fgWindowSizeHiGain,
    73                      Int_t windowl=fgWindowSizeLoGain);
    7471
    7572  void SetBinningResolution(const Int_t rh=fgBinningResolutionHiGain, const Int_t rl=fgBinningResolutionLoGain)  {
     
    8077  }
    8178 
    82 
    8379  void SetSignalStartBin( const Int_t sh=fgSignalStartBinHiGain, const Int_t sl=fgSignalStartBinLoGain) {
    8480    fSignalStartBinHiGain = sh;
    8581    fSignalStartBinLoGain = sl;
    8682  }
     83
     84  void SetWindowSize( Int_t windowh=fgWindowSizeHiGain, Int_t windowl=fgWindowSizeLoGain);
    8785
    8886  const char* GetNameWeightsFile() const  { return fNameWeightsFile.Data(); }
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.cc

    r5416 r5504  
    8989//
    9090MExtractTimeAndChargeSlidingWindow::MExtractTimeAndChargeSlidingWindow(const char *name, const char *title)
    91     : fWindowSizeHiGain(fgHiGainWindowSize),
    92       fWindowSizeLoGain(fgLoGainWindowSize),
    93       fHiGainSignal(NULL), fLoGainSignal(NULL)
    9491{
    9592 
     
    9794  fTitle = title ? title : "Calculate arrival times and charges using a sliding window";
    9895
     96  fWindowSizeHiGain = fgHiGainWindowSize;
     97  fWindowSizeLoGain = fgLoGainWindowSize;
     98
    9999  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
    100 }
    101 
    102 
    103 // --------------------------------------------------------------------------
    104 //
    105 // Destructor: Deletes the arrays
    106 //
    107 MExtractTimeAndChargeSlidingWindow::~MExtractTimeAndChargeSlidingWindow()
    108 {
    109  
    110   if (fHiGainSignal)
    111     delete [] fHiGainSignal;
    112   if (fLoGainSignal)
    113     delete [] fLoGainSignal;
    114  
    115100}
    116101
     
    147132// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples) 
    148133// 
    149 void MExtractTimeAndChargeSlidingWindow::SetWindowSize(Byte_t windowh, Byte_t windowl)
     134void MExtractTimeAndChargeSlidingWindow::SetWindowSize(Int_t windowh, Int_t windowl)
    150135{
    151136 
     
    153138  fWindowSizeLoGain = windowl;
    154139
    155   const Byte_t availhirange = fHiGainLast-fHiGainFirst+1;
     140  const Int_t availhirange = (Int_t)(fHiGainLast-fHiGainFirst+1);
    156141
    157142  if (fWindowSizeHiGain > availhirange)
     
    173158  if (fLoGainLast != 0 && fWindowSizeLoGain != 0)
    174159    {
    175       const Byte_t availlorange = fLoGainLast-fLoGainFirst+1;
     160      const Int_t availlorange = (Int_t)(fLoGainLast-fLoGainFirst+1);
    176161     
    177162      if (fWindowSizeLoGain > availlorange)
     
    196181// --------------------------------------------------------------------------
    197182//
    198 // ReInit
    199 //
    200 // Calls:
    201 // - MExtractTimeAndCharge::ReInit(pList);
    202 // - Deletes all arrays, if not NULL
    203 // - Creates new arrays according to the extraction range
    204 //
    205 Bool_t MExtractTimeAndChargeSlidingWindow::ReInit(MParList *pList)
    206 {
    207 
    208   if (!MExtractTimeAndCharge::ReInit(pList))
    209     return kFALSE;
    210 
    211   if (fHiGainSignal)
    212     delete [] fHiGainSignal;
    213   if (fLoGainSignal)
    214     delete [] fLoGainSignal;
    215  
    216   Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
    217 
    218   fHiGainSignal = new Float_t[range];
    219   memset(fHiGainSignal,0,range*sizeof(Float_t));
    220 
    221   range = fLoGainLast - fLoGainFirst + 1;
    222 
    223   fLoGainSignal = new Float_t[range];
    224   memset(fLoGainSignal,0,range*sizeof(Float_t));
    225 
    226   return kTRUE;
     183// InitArrays
     184//
     185// Gets called in the ReInit() and initialized the arrays
     186//
     187void MExtractTimeAndChargeSlidingWindow::InitArrays()
     188{
     189  fHiGainSignal.Set(fHiGainLast - fHiGainFirst + 1 + fHiLoLast);
     190  fLoGainSignal.Set(fLoGainLast - fLoGainFirst + 1);
    227191}
    228192
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.h

    r5483 r5504  
    44#ifndef MARS_MExtractTimeAndCharge
    55#include "MExtractTimeAndCharge.h"
     6#endif
     7
     8#ifndef MARS_MArrayF
     9#include "MArrayF.h"
    610#endif
    711
     
    1923  static const Byte_t fgLoGainWindowSize; //! The extraction window Lo-Gain
    2024
    21   Byte_t  fWindowSizeHiGain;             // Number of Hi Gain slices in window
    2225  Float_t fHiGainWindowSizeSqrt;         // Square root of number of gains in window
    23   Byte_t  fWindowSizeLoGain;             // Number of Lo Gain slices in window 
    2426  Float_t fLoGainWindowSizeSqrt;         // Square root of number of gains in window
    2527 
    26   Float_t *fHiGainSignal;                //! Need fast access to the pedestal subtracted signals
    27   Float_t *fLoGainSignal;                //! Store them in separate arrays
     28  MArrayF fHiGainSignal;                 //! Need fast access to the signals in a float way
     29  MArrayF fLoGainSignal;                 //! Store them in separate arrays
    2830
    29   Bool_t ReInit( MParList *pList );
     31  void InitArrays();
    3032 
    3133  Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
     
    3436
    3537  MExtractTimeAndChargeSlidingWindow(const char *name=NULL, const char *title=NULL);
    36   ~MExtractTimeAndChargeSlidingWindow(); 
    37 
    38   Byte_t GetWindowSizeHiGain() const { return fWindowSizeHiGain; }
    39   Byte_t GetWindowSizeLoGain() const { return fWindowSizeLoGain; }
     38  ~MExtractTimeAndChargeSlidingWindow() {}
    4039
    4140  void SetRange    ( Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0 ); 
    42   void SetWindowSize(Byte_t windowh=fgHiGainWindowSize,
    43                      Byte_t windowl=fgLoGainWindowSize);
     41  void SetWindowSize(Int_t windowh=fgHiGainWindowSize,
     42                     Int_t windowl=fgLoGainWindowSize);
    4443
    4544  void FindTimeAndChargeHiGain(Byte_t *first, Byte_t *logain, Float_t &sum, Float_t &dsum,
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc

    r5497 r5504  
    177177//
    178178MExtractTimeAndChargeSpline::MExtractTimeAndChargeSpline(const char *name, const char *title)
    179     : fHiGainSignal(NULL), fLoGainSignal(NULL),
    180       fHiGainFirstDeriv(NULL), fLoGainFirstDeriv(NULL),
    181       fHiGainSecondDeriv(NULL), fLoGainSecondDeriv(NULL),
    182       fAbMax(0.), fAbMaxPos(0.), fHalfMax(0.)
     179    : fAbMax(0.), fAbMaxPos(0.), fHalfMax(0.)
    183180{
    184181
     
    197194}
    198195
    199 // --------------------------------------------------------------------------
    200 //
    201 // Destructor: Deletes the arrays
    202 //
    203 MExtractTimeAndChargeSpline::~MExtractTimeAndChargeSpline()
    204 {
    205  
    206   if (fHiGainSignal)
    207     delete [] fHiGainSignal;
    208   if (fLoGainSignal)
    209     delete [] fLoGainSignal;
    210   if (fHiGainFirstDeriv)
    211     delete [] fHiGainFirstDeriv;
    212   if (fLoGainFirstDeriv)
    213     delete [] fLoGainFirstDeriv;
    214   if (fHiGainSecondDeriv)
    215     delete [] fHiGainSecondDeriv;
    216   if (fLoGainSecondDeriv)
    217     delete [] fLoGainSecondDeriv;
    218  
    219 }
    220196
    221197//-------------------------------------------------------------------
     
    273249}
    274250
    275 
    276251// --------------------------------------------------------------------------
    277252//
     
    286261{
    287262
    288   if (fHiGainSignal)
    289     delete [] fHiGainSignal;
    290   if (fLoGainSignal)
    291     delete [] fLoGainSignal;
    292   if (fHiGainFirstDeriv)
    293     delete [] fHiGainFirstDeriv;
    294   if (fLoGainFirstDeriv)
    295     delete [] fLoGainFirstDeriv;
    296   if (fHiGainSecondDeriv)
    297     delete [] fHiGainSecondDeriv;
    298   if (fLoGainSecondDeriv)
    299     delete [] fLoGainSecondDeriv;
    300  
    301   Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
    302 
    303   fHiGainSignal = new Float_t[range];
    304   memset(fHiGainSignal,0,range*sizeof(Float_t));
    305   fHiGainFirstDeriv = new Float_t[range];
    306   memset(fHiGainFirstDeriv,0,range*sizeof(Float_t));
    307   fHiGainSecondDeriv = new Float_t[range];
    308   memset(fHiGainSecondDeriv,0,range*sizeof(Float_t));
    309 
    310   range = fLoGainLast - fLoGainFirst + 1;
    311 
    312   fLoGainSignal = new Float_t[range];
    313   memset(fLoGainSignal,0,range*sizeof(Float_t));
    314   fLoGainFirstDeriv = new Float_t[range];
    315   memset(fLoGainFirstDeriv,0,range*sizeof(Float_t));
    316   fLoGainSecondDeriv = new Float_t[range];
    317   memset(fLoGainSecondDeriv,0,range*sizeof(Float_t));
    318 
    319263  if (IsExtractionType(kAmplitude))
    320264    {
     
    323267      fSqrtHiGainSamples = 1.;
    324268      fSqrtLoGainSamples = 1.;
     269      fWindowSizeHiGain  = 1;
     270      fWindowSizeLoGain  = 1;
    325271    }
    326272
     
    331277      fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
    332278      fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
     279      fWindowSizeHiGain  = (Int_t)(fRiseTime + fFallTime);
     280      fWindowSizeLoGain  = (Int_t)(fRiseTime + fFallTime+1);
    333281    }
    334282
     
    339287}
    340288
     289// --------------------------------------------------------------------------
     290//
     291// InitArrays
     292//
     293// Gets called in the ReInit() and initialized the arrays
     294//
     295void MExtractTimeAndChargeSpline::InitArrays()
     296{
     297
     298  Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
     299
     300  fHiGainSignal     .Set(range);
     301  fHiGainFirstDeriv .Set(range);
     302  fHiGainSecondDeriv.Set(range);
     303
     304  range = fLoGainLast - fLoGainFirst + 1;
     305
     306  fLoGainSignal     .Set(range);
     307  fLoGainFirstDeriv .Set(range);
     308  fLoGainSecondDeriv.Set(range);
     309
     310  fHiGainSignal     .Reset();
     311  fHiGainFirstDeriv .Reset();
     312  fHiGainSecondDeriv.Reset();
     313
     314  fLoGainSignal     .Reset();
     315  fLoGainFirstDeriv .Reset();
     316  fLoGainSecondDeriv.Reset();
     317
     318}
    341319
    342320// --------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.h

    r5497 r5504  
    44#ifndef MARS_MExtractTimeAndCharge
    55#include "MExtractTimeAndCharge.h"
     6#endif
     7
     8#ifndef MARS_MArrayF
     9#include "MArrayF.h"
    610#endif
    711
     
    2024  static const Float_t fgFallTime;       //! Default for fFallTime     (now set to: 4.5)
    2125
    22   Float_t *fHiGainSignal;                //! Need fast access to the signals in a float way
    23   Float_t *fLoGainSignal;                //! Store them in separate arrays
    24   Float_t *fHiGainFirstDeriv;            //!
    25   Float_t *fLoGainFirstDeriv;            //!
    26   Float_t *fHiGainSecondDeriv;           //!
    27   Float_t *fLoGainSecondDeriv;           //!
     26  MArrayF fHiGainSignal;                //! Need fast access to the signals in a float way
     27  MArrayF fLoGainSignal;                //! Store them in separate arrays
     28  MArrayF fHiGainFirstDeriv;            //! High-gain discretized first derivatives
     29  MArrayF fLoGainFirstDeriv;            //! Low-gain discretized first derivatives
     30  MArrayF fHiGainSecondDeriv;           //! High-gain discretized second derivatives
     31  MArrayF fLoGainSecondDeriv;           //! Low-gain discretized second derivatives
    2832
    2933  Float_t fAbMax;                        //! Current maximum of the spline
     
    4145  Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    4246
     47  void InitArrays();
     48 
    4349  void CalcIntegralHiGain(Float_t &sum, Int_t startslice, Int_t lastslice);
    4450  void CalcIntegralLoGain(Float_t &sum, Int_t startslice, Int_t lastslice);
     
    5662
    5763  MExtractTimeAndChargeSpline(const char *name=NULL, const char *title=NULL);
    58   ~MExtractTimeAndChargeSpline()
     64  ~MExtractTimeAndChargeSpline() {}
    5965
    6066  Float_t GetRiseTime() const { return fRiseTime; }
Note: See TracChangeset for help on using the changeset viewer.