#ifndef gregsEventCut_hh
#define gregsEventCut_hh

#include "StHbtMaker/Base/StHbtEventCut.h"
// Get the StRefMultCorr headers used for centrality definition
#include "StRoot/StRefMultCorr/StRefMultCorr.h"
#include "StRoot/StRefMultCorr/CentralityMaker.h"

//_________________
class gregsEventCut : public StHbtEventCut {

 public:
  gregsEventCut();
  gregsEventCut(const gregsEventCut& copy); //Copy constructor
  gregsEventCut *Clone(void);               //Unsafe
  ~gregsEventCut();

  void SetEventMult(const int& lo, const int& hi);
  void SetVertXPos(const float& lo, const float& hi);
  void SetVertYPos(const float& lo, const float& hi);
  void SetVertZPos(const float& lo, const float& hi);
  void SetVertXYShift(const float& xShift, const float& yShift);
  void SetVertRPos(const float& v);
  void SetCollisionType(const int& type);  //0-pp; 1-AuAu
  void SetVzVpdVzDiff(const float& lo, const float& hi);
  //Next methods needed for StRefMultCorr
  void SetEventCentralityBins(const int& lo, const int& hi);
  void SetCentralityDefinition(const int& nCentralityBins);
  void SetZdcRefMultCorrection(const Bool_t& corr);

  int NEventsPassed();
  int NEventsFailed();

  virtual string Report();
  virtual bool Pass(const StHbtEvent*);

 private:   //here are the quantities I want to cut on...

  //Multiplicity range
  int	  mRefMult[2];
  float   mVtxX[2];
  float   mVtxY[2];
  float   mVtxZ[2];
  float   mVtxR;
  float   mVzVpdVzDiff[2];
  int     mCollisionType;  //0-pp; 1-AuAu
  float   mVtxXShift;
  float   mVtxYShift;
  Bool_t  mUseZdcRefMultCorr;
  
  //Centrality definitions for AuAu
  int     mNumberOfCentralityBins;   //9 or 16 centrality bins
  int     mCentralityBinRange[2];
  StRefMultCorr* mRefMultCorrUtil;
  int     mRefMultCorrUtil_curInitRunNumber;
  
  long    mNEventsPassed;
  long    mNEventsFailed;

  Bool_t isOnList(int, const Int_t*, int);

  static const Int_t n_bad_run_numbers[7];
  static const Int_t bad_run_list_7GeV[328];
  static const Int_t bad_run_list_11GeV[27];
  static const Int_t bad_run_list_19GeV[35];
  static const Int_t bad_run_list_27GeV[34];
  static const Int_t bad_run_list_39GeV[38];
  static const Int_t bad_run_list_62GeV[105];
  static const Int_t bad_run_list_200GeV[219];

#ifdef __ROOT__
  ClassDef(gregsEventCut, 1)
#endif

};

inline void gregsEventCut::SetEventMult(const int& lo, const int& hi) { mRefMult[0] = lo; mRefMult[1] = hi; }
inline void gregsEventCut::SetVertXPos(const float& lo, const float& hi) { mVtxX[0] = lo; mVtxX[1] = hi; }
inline void gregsEventCut::SetVertYPos(const float& lo, const float& hi) { mVtxY[0] = lo; mVtxY[1] = hi; }
inline void gregsEventCut::SetVertZPos(const float& lo, const float& hi) { mVtxZ[0] = lo; mVtxZ[1] = hi; }
inline void gregsEventCut::SetVertRPos(const float& v) { mVtxR = v; }
inline void gregsEventCut::SetVzVpdVzDiff(const float& lo, const float& hi) {
  mVzVpdVzDiff[0] = lo; mVzVpdVzDiff[1] = hi; }
inline void gregsEventCut::SetCollisionType(const int& type) {
  mCollisionType = type;
  if(type!=0) {
    //Do not forget to add: gSystem->Load("StRefMultCorr"); in the running macro
    mRefMultCorrUtil = new StRefMultCorr("refmult");
  }
}
inline void gregsEventCut::SetCentralityDefinition(const int& nCentralityBins) {
  mNumberOfCentralityBins = nCentralityBins;
}
inline void gregsEventCut::SetEventCentralityBins(const int& lo, const int& hi) {
  assert(lo >= 0 && hi <= mNumberOfCentralityBins);
  mCentralityBinRange[0] = lo; mCentralityBinRange[1] = hi;
}
inline int gregsEventCut::NEventsPassed() { return (mNEventsPassed); }
inline int gregsEventCut::NEventsFailed() { return (mNEventsFailed); }
inline gregsEventCut* gregsEventCut::Clone() { 
  gregsEventCut *c = new gregsEventCut(*this);
  return c;
}
inline void gregsEventCut::SetVertXYShift(const float& xShift, const float& yShift) {
  mVtxXShift = xShift; mVtxYShift = yShift;
}
inline void gregsEventCut::SetZdcRefMultCorrection(const Bool_t &corr) {
  mUseZdcRefMultCorr = corr;
}
#endif
