#ifndef MARS_MCalibrationPINDiode
#define MARS_MCalibrationPINDiode

#ifndef MARS_MParContainer
#include "MParContainer.h"
#endif

#include "MHCalibrationPINDiode.h"

class MCalibrationPINDiode : public MParContainer
{
private:

  MHCalibrationPINDiode *fHist; // Pointer to the histograms performing the fits, etc.  
  
  Float_t fCharge;                // The mean charge after the fit
  Float_t fErrCharge;             // The error of mean charge after the fit
  Float_t fPed;              // The mean pedestal (from MPedestalPix)
  Float_t fPedRms;           // The pedestal  RMS (from MPedestalPix)
  Float_t fSigmaCharge;           // The sigma of the mean charge after the fit
  Float_t fErrSigmaCharge;        // The error of the sigma of the mean charge after the fit
  Float_t fTime;                // The mean arrival time after the fit  
  Float_t fErrTime;             // The error of the mean arrival time after the fit
  
  Float_t fRCharge;               // The reduced mean charge after the fit
  Float_t fErrRCharge;            // The error of the reduced mean charge after the fit  
  
public:

  MCalibrationPINDiode(const char *name=NULL, const char *title=NULL);
  ~MCalibrationPINDiode();
  
  void Clear(Option_t *o="");
  
  void SetPed(Float_t ped)          { fPed      = ped;      } 
  void SetPedRms(Float_t pedrms)    { fPedRms   = pedrms; }

  Bool_t IsValid() const { return fRCharge >=0 || fErrRCharge >= 0; }

  Bool_t FillCharge(Float_t q)      { return fHist->FillChargeHiGain(q); }
  Bool_t FillTime(Int_t t)          { return fHist->FillTimeHiGain(t); }  
  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsNHiGain(rq,t); }    
  
  Bool_t FitCharge();
  Bool_t FitTime();
  
  MHCalibrationPINDiode *GetHist()  const  { return fHist;  }
  
  ClassDef(MCalibrationPINDiode, 1)	// Storage Container for Calibration information of one pixel
};

#endif   /* MARS_MCalibrationPINDiode */

