/*
 * Rotate one particle of the pair as follow (px,py,pz,e)->(-px,-py,pz,e)
 * Many transverse pair momentum bins
 * 2015/03/23 gnigmat
 */
#ifndef QinvCorrFctnRotationKt_hh
#define QinvCorrFctnRotationKt_hh

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

//_________________
class QinvCorrFctnRotationKt : public StHbtCorrFctn {

 public:
  QinvCorrFctnRotationKt(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 ~QinvCorrFctnRotationKt();

  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(QinvCorrFctnRotationKt, 1)
#endif
};

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

#endif //QinvCorrFctnRotationKt_hh
