#ifndef QinvCorrFctnKt_MomAndEnCons_hh
#define QinvCorrFctnKt_MomAndEnCons_hh

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

//_________________
class QinvCorrFctnKt_MomAndEnCons : public StHbtCorrFctn {

 public:
  QinvCorrFctnKt_MomAndEnCons(char* title, 
			      const int& nbins, 
			      const float& QinvLo, 
			      const float& QinvHi,
			      const int& nCFs, 
			      const float& KtLo, 
			      const float& KtHi,
			      const double& meanPt2, 
			      const double& meanPz2,
			      const double& meanE2, 
			      const double& meanE, 
			      const int& NofParticles);

  virtual ~QinvCorrFctnKt_MomAndEnCons();

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

  virtual void Finish();

  void SetMass(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);

  StHbt1DHisto* NumeratorFull(int j);
  StHbt1DHisto* DenominatorFull(int j);

  void WriteOutHistos();

 private:

  float mPartMass;
  StHbt1DHisto* mNumerator;
  StHbt1DHisto* mDenominator;

  StHbt1DHisto* mNumeratorPt1xPt2;
  StHbt1DHisto* mNumeratorPt1SqrSumPt2Sqr;
  StHbt1DHisto* mNumeratorPz1xPz2;
  StHbt1DHisto* mNumeratorPz1SqrSumPz2Sqr;

  StHbt1DHisto* mNumeratorE1xE2;
  StHbt1DHisto* mNumeratorE1sumE2;

  double mMeanPt2;
  double mMeanPz2;
  double mMeanE2;
  double mMeanE;
  double mNumberOfParticles;

  StHbt1DHisto* mNumeratorFull;
  StHbt1DHisto* mDenominatorFull;

  int mNumberCFs;
  float mKtMin;
  float mKtMax;

  int* mIndex;
  float mDeltaKt;

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

inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::Numerator(int j) { 
  return &mNumerator[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::Denominator(int j) { 
  return &mDenominator[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::NumeratorPt1xPt2(int j) {
  return &mNumeratorPt1xPt2[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::NumeratorPt1SqrSumPt2Sqr(int j) {
  return &mNumeratorPt1SqrSumPt2Sqr[j]; }

inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::NumeratorPz1xPz2(int j) {
  return &mNumeratorPz1xPz2[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::NumeratorPz1SqrSumPz2Sqr(int j) {
  return &mNumeratorPz1SqrSumPz2Sqr[j]; }

inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::NumeratorE1xE2(int j) { 
  return &mNumeratorE1xE2[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::NumeratorE1sumE2(int j) {
  return &mNumeratorE1sumE2[j]; }

inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::NumeratorFull(int j) {
  return &mNumeratorFull[j]; }
inline StHbt1DHisto* QinvCorrFctnKt_MomAndEnCons::DenominatorFull(int j) {
  return &mDenominatorFull[j]; }

#endif
