#ifndef gregsKaonTrackCut_h
#define gregsKaonTrackCut_h

#include "StHbtMaker/Base/StHbtTrackCut.h"

//_________________
class gregsKaonTrackCut : public StHbtTrackCut {

 public:
  gregsKaonTrackCut();
  gregsKaonTrackCut(const gregsKaonTrackCut &copy);
  gregsKaonTrackCut *Clone();
  ~gregsKaonTrackCut();

  virtual bool Pass(const StHbtTrack *trk); //0-tpc,1-tof,2-tpc+tof,3-TOF(m^2+3nsigma)orTPC(nsK<v1&&nsO>v2&&p<v3)
  virtual StHbtString Report();
  
  //Set identification type
  void SetDetectorSelection(const short &type) {mSelType = type;}

  //Set track cuts
  void SetType(const short &type) {mType = type;}
  void SetCharge(const short &charge) {mCharge = charge;}
  void SetNHits(const short &lo, const short &hi) {mNHits[0]=lo; mNHits[1]=hi;}
  void SetNHitsFit(const short &lo, const short &hi) {mNHitsFit[0]=lo; mNHitsFit[1]=hi;}
  void SetP(const float &lo, const float &hi) {mP[0]=lo; mP[1]=hi;}
  void SetPt(const float &lo, const float &hi) {mPt[0]=lo; mPt[1]=hi;}
  void SetPx(const float &lo, const float &hi) {mPx[0]=lo; mPx[1]=hi;}
  void SetPy(const float &lo, const float &hi) {mPy[0]=lo; mPy[1]=hi;}
  void SetPz(const float &lo, const float &hi) {mPz[0]=lo; mPz[1]=hi;}
  void SetRapidity(const float &lo, const float &hi) {mRapidity[0]=lo; mRapidity[1]=hi;}
  void SetEta(const float &lo, const float &hi) {mEta[0]=lo; mEta[1]=hi;}
  void SetDCA(const float &lo, const float &hi) {mDCA[0]=lo; mDCA[1]=hi;}
  void SetDCAGlobal(const float &lo, const float &hi) {mDCAGlobal[0]=lo; mDCAGlobal[1]=hi;}
  void SetAntiSplit(const float &lo) {mAntiSplit = lo;}

  //Set TPC identification parameters
  void SetTpcNSigmaElectron(const float& lo, const float& hi) {mTpcNSigmaElectron[0]=lo; mTpcNSigmaElectron[1]=hi;}
  void SetTpcNSigmaPion(const float& lo, const float& hi) {mTpcNSigmaPion[0]=lo; mTpcNSigmaPion[1]=hi;}
  void SetTpcNSigmaKaon(const float& lo, const float& hi) {mTpcNSigmaKaon[0]=lo; mTpcNSigmaKaon[1]=hi;}
  void SetTpcNSigmaProton(const float& lo, const float& hi) {mTpcNSigmaProton[0]=lo; mTpcNSigmaProton[1]=hi;}
  void SetTpcMomentum(const float& lo, const float& hi) {mTpcMomentum[0]=lo; mTpcMomentum[1]=hi;}

  //Set TOF identification parameters
  void SetTofMassSqr(const float& lo, const float& hi) {mTofMassSqr[0]=lo; mTofMassSqr[1]=hi;}
  void SetTofMomentum(const float &lo, const float &hi) {mTofMomentum[0]=lo; mTofMomentum[1]=hi;}
  void SetTofInvBetaDiff(const float &lo, const float &hi) {mTofInvBetaDiff[0]=lo; mTofInvBetaDiff[1]=hi;}

  //Set TOF && TPC identification parameters
  void SetTnTMomentum(const float &lo, const float &hi) {mTnTMomentum[0]=lo; mTnTMomentum[1]=hi;}
  void SetTnTNSigmaKaon(const float &lo, const float &hi) {mTnTNSigmaKaon[0]=lo; mTnTNSigmaKaon[1]=hi;}

 private:
  
  //Selection type
  short mSelType;  //0-tpc,1-tof,2-tpc+tof,3-TOF(m^2+3nsigma)orTPC(nsK<v1&&nsO>v2&&p<v3)
  
  //Track parameters
  short   mType;                // 0-global, 1-primary
  short   mCharge;
  short   mFlag[2];
  short   mNHits[2];
  short   mNHitsFit[2];
  float   mP[2];
  float   mPt[2];
  float   mPx[2];
  float   mPy[2];
  float   mPz[2];
  float   mRapidity[2];
  float   mEta[2];
  float   mDCA[2];
  float   mDCAGlobal[2];
  float   mAntiSplit;         // nHitsFit/nHitsPossible

  //TPC identification
  float   mTpcMomentum[2];
  float   mTpcNSigmaElectron[2];
  float   mTpcNSigmaPion[2];
  float   mTpcNSigmaKaon[2];
  float   mTpcNSigmaProton[2];

  //TOF identification
  float   mTofMomentum[2];
  float   mTofMassSqr[2];
  float   mTofInvBetaDiff[2];

  //TPC&&TOF
  float   mTnTMomentum[2];
  float   mTnTNSigmaKaon[2];

  //Counters
  long   mNTracksPassed;
  long   mNTracksFailed;

#ifdef __ROOT__
  ClassDef(gregsKaonTrackCut, 1)
#endif
};

inline gregsKaonTrackCut *gregsKaonTrackCut::Clone() {
  gregsKaonTrackCut *c = new gregsKaonTrackCut(*this); return c;
}
#endif
