/*
 * Look at the opposite hemi-sphere.
 * Rotate one particle of the pair as follow (px,py,pz,e)->(-px,-py,-pz,e)
 * Many transverse pair momentum bins
 * 2015/03/22 gnigmat
 */
#ifndef QinvCorrFctnOpposHemisphereKt_hh
#define QinvCorrFctnOpposHemisphereKt_hh

#include "StHbtMaker/Base/StHbtCorrFctn.hh"
#include "StHbtMaker/Base/StHbtPairCut.h"
#include <TRandom3.h>
#include <TLorentzVector.h>

//_________________
class QinvCorrFctnOpposHemisphereKt : public StHbtCorrFctn {

 public:
  QinvCorrFctnOpposHemisphereKt(char *title,
				const int& nbins=50,const float& QinvLo=0., const float& QinvHi=1.,
                                const int& nCFs=20,const float& KtLo=0., const float& KtHi=1.,
                                float mass = 0.0, StHbtPairCut *paircut = 0);
  virtual ~QinvCorrFctnOpposHemisphereKt();

  virtual StHbtString Report();
  virtual void AddRealPair(const StHbtPair*);
  virtual void AddMixedPair(const StHbtPair*);
  void SetSpecificPairCut(StHbtPairCut *paircut);
  void SetMass(float mass);
  void EventBegin(const StHbtEvent *event);

  virtual void Finish();

  void WriteOutHistos();

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

 private:
  StHbt1DHisto* mNumerator;
  StHbt1DHisto* mDenominator;
  
  TRandom3 *mRandy;
  TLorentzVector mTrack1;
  TLorentzVector mTrack2;
  TLorentzVector mDiffVect;
  TLorentzVector mSumVect;

  int mNumberCFs;
  float mKtMin;
  float mKtMax;

  float mMass;
  double mMagField;

  int* mIndex;
  float mDeltaKt;

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

inline StHbt1DHisto* QinvCorrFctnOpposHemisphereKt::Numerator(int j) {
  return &mNumerator[j]; }
inline StHbt1DHisto* QinvCorrFctnOpposHemisphereKt::Denominator(int j) {
  return &mDenominator[j]; }
inline void          QinvCorrFctnOpposHemisphereKt::SetSpecificPairCut(StHbtPairCut *paircut) { mPairCut = paircut; }
inline void          QinvCorrFctnOpposHemisphereKt::SetMass(float mass) { mMass = mass; }
inline void          QinvCorrFctnOpposHemisphereKt::EventBegin(const StHbtEvent *event) { mMagField = event->MagneticField(); }

#endif //QinvCorrFctnOpposHemisphereKt_hh
