#ifndef MARS_MExtractTimeAndCharge
#define MARS_MExtractTimeAndCharge

#ifndef MARS_MExtractTime
#include "MExtractTime.h"
#endif

class MPedestalPix;
class MExtractTimeAndCharge : public MExtractTime
{
private:

  static const Float_t fgLoGainStartShift; // Default for fLoGainStartShift (now set to: -2.8)
  
  Byte_t  fLoGainFirstSave;       //! Temporary variable to store the original position of low-gain start slice
  Float_t fLoGainStartShift;      // Shift to start searching the low-gain signal obtained from the high-gain times.

protected:

  Int_t  fWindowSizeHiGain;       //  Window Size High-Gain
  Int_t  fWindowSizeLoGain;       //  Window Size Low-Gain

  Int_t  PreProcess(MParList *pList);
  Int_t  Process();
  Bool_t ReInit(MParList *pList);

  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);

public:

  MExtractTimeAndCharge(const char *name=NULL, const char *title=NULL);
  
  Int_t GetWindowSizeHiGain() const { return fWindowSizeHiGain; }
  Int_t GetWindowSizeLoGain() const { return fWindowSizeLoGain; }

  void Print(Option_t *o="") const;
  
  void SetLoGainStartShift( const Float_t f=fgLoGainStartShift )  { fLoGainStartShift = f + fOffsetLoGain;  }
  virtual void SetWindowSize(Int_t windowh, Int_t windowl) { fWindowSizeHiGain = windowh;
                                                           fWindowSizeLoGain = windowl;  }
  
  virtual Bool_t InitArrays() { return kTRUE; }

  virtual void FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum,
                                       Float_t &time, Float_t &dtime,
                                       Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag) { }
  
  virtual void FindTimeAndChargeLoGain(Byte_t *firstused, Float_t &sum,  Float_t &dsum,
                                       Float_t &time, Float_t &dtime,
                                       Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag) { } 

  ClassDef(MExtractTimeAndCharge, 1)   // Time And Charge Extractor Base Class
};

#endif



