#ifndef QinvCorrFctn_MomAndEnCons_hh
#define QinvCorrFctn_MomAndEnCons_hh

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

//_________________
class QinvCorrFctn_MomAndEnCons : public StHbtCorrFctn {

 public:

  QinvCorrFctn_MomAndEnCons(char* title, 
			    const int& nbins, const float& QinvLo, const float& QinvHi,
			    const double& meanPt2, const double& meanPz2,
			    const double& meanE2, const double& meanE, 
			    const int& NofParticles);

  virtual ~QinvCorrFctn_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();
  StHbt1DHisto* Denominator();

  StHbt1DHisto* NumeratorPt1xPt2();
  StHbt1DHisto* NumeratorPt1SqrSumPt2Sqr();

  StHbt1DHisto* NumeratorPz1xPz2();
  StHbt1DHisto* NumeratorPz1SqrSumPz2Sqr();

  StHbt1DHisto* NumeratorE1xE2();
  StHbt1DHisto* NumeratorE1sumE2();

  StHbt1DHisto* NumeratorFull();
  StHbt1DHisto* DenominatorFull();

  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;

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

inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::Numerator() { return mNumerator; }
inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::Denominator() { return mDenominator; }
inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::NumeratorPt1xPt2() {
  return mNumeratorPt1xPt2; }
inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::NumeratorPt1SqrSumPt2Sqr() {
  return mNumeratorPt1SqrSumPt2Sqr; }

inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::NumeratorPz1xPz2() {
  return mNumeratorPz1xPz2; }
inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::NumeratorPz1SqrSumPz2Sqr() {
  return mNumeratorPz1SqrSumPz2Sqr; }

inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::NumeratorE1xE2() { 
  return mNumeratorE1xE2; }
inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::NumeratorE1sumE2() {
  return mNumeratorE1sumE2; }

inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::NumeratorFull() {
  return mNumeratorFull; }
inline StHbt1DHisto* QinvCorrFctn_MomAndEnCons::DenominatorFull() {
  return mDenominatorFull; }

#endif
