#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  PreProcess(MParList *pList);
  Bool_t ReInit(MParList *pList);
  Int_t  Process();

  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);

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

  MExtractTimeAndCharge(const char *name=NULL, const char *title=NULL);
  
  void SetLoGainStartShift( const Float_t f=fgLoGainStartShift )  { fLoGainStartShift = f + fOffsetLoGain;  }
  
  ClassDef(MExtractTimeAndCharge, 0)   // Time And Charge Extractor Base Class
};

#endif



