#ifndef QinvCorrFctnKt_MomCons_hh
#define QinvCorrFctnKt_MomCons_hh

#include "StHbtMaker/Base/StHbtCorrFctn.hh"
#include "StHbtMaker/Base/StHbtPairCut.h"

//_________________
class QinvCorrFctnKt_MomCons : public StHbtCorrFctn {

 public:
  QinvCorrFctnKt_MomCons(char *title,
			 const int& nbins, const float& QinvLo, const float& QinvHi,
			 const int& nCFs=20, const float& KtLo=0., const float& KtHi=1.);
  virtual ~QinvCorrFctnKt_MomCons();

  virtual StHbtString Report();
  virtual void AddRealPair(const StHbtPair*);
  virtual void AddMixedPair(const StHbtPair*);
  
  virtual void Finish();

  void WriteOutHistos();
  void SetMass(const float &mass) {mPartMass = mass;}

  StHbt1DHisto* Numerator(int j);
  StHbt1DHisto* Denominator(int j);

  StHbt1DHisto* NumeratorPt1xPt2(int j);
  StHbt1DHisto* NumeratorPt1SqrSumPt2Sqr(int j);

  StHbt1DHisto* NumeratorPz1xPz2(int j);
  StHbt1DHisto* NumeratorPz1SqrSumPz2Sqr(int j);

  StHbt1DHisto* NumeratorE1xE2(int j);
  StHbt1DHisto* NumeratorE1sumE2(int j);

 private:
  StHbt1DHisto *mNumerator;
  StHbt1DHisto *mDenominator;
  
  StHbt1DHisto* mNumeratorPt1xPt2;
  StHbt1DHisto* mNumeratorPt1SqrSumPt2Sqr;
  StHbt1DHisto* mNumeratorPz1xPz2;
  StHbt1DHisto* mNumeratorPz1SqrSumPz2Sqr;

  StHbt1DHisto* mNumeratorE1xE2;
  StHbt1DHisto* mNumeratorE1sumE2;

  int mNumberCFs;
  float mKtMin;
  float mKtMax;

  int* mIndex;
  float mDeltaKt;

  float mPartMass;

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

inline StHbt1DHisto *QinvCorrFctnKt_MomCons::Numerator(int j) { 
  return &mNumerator[j]; }
inline StHbt1DHisto *QinvCorrFctnKt_MomCons::Denominator(int j) { 
  return &mDenominator[j];}
inline StHbt1DHisto *QinvCorrFctnKt_MomCons::NumeratorPt1xPt2(int j) {
  return &mNumeratorPt1xPt2[j];}
inline StHbt1DHisto* QinvCorrFctnKt_MomCons::NumeratorPt1SqrSumPt2Sqr(int j) {
  return &mNumeratorPt1SqrSumPt2Sqr[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomCons::NumeratorPz1xPz2(int j){
  return &mNumeratorPz1xPz2[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomCons::NumeratorPz1SqrSumPz2Sqr(int j) {
  return &mNumeratorPz1SqrSumPz2Sqr[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomCons::NumeratorE1xE2(int j) {
  return &mNumeratorE1xE2[j];}
inline StHbt1DHisto* QinvCorrFctnKt_MomCons::NumeratorE1sumE2(int j) {
  return &mNumeratorE1sumE2[j];}
#endif
