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

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

class QinvCorrFctnRotation : public StHbtCorrFctn {
 public:
  QinvCorrFctnRotation(char* title,const int& nbins=50, 
                       const float& QinvLo=0.,const float& QinvHi=1.,
                       float mass = 0.0, StHbtPairCut *paircut = 0);
  virtual ~QinvCorrFctnRotation();

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

  StHbt1DHisto* Numerator();
  StHbt1DHisto* Denominator();
  StHbt1DHisto* Ratio();

 private:
  StHbt1DHisto* mNumerator;
  StHbt1DHisto* mDenominator;
  StHbt1DHisto* mRatio;

  float mMass;
  double mMagField;

  TRandom3 *mRandy;
  TLorentzVector mTrack1;
  TLorentzVector mTrack2;
  TLorentzVector mDiffVect;

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

inline StHbt1DHisto* QinvCorrFctnRotation::Numerator(){return mNumerator;}
inline StHbt1DHisto* QinvCorrFctnRotation::Denominator(){return mDenominator;}
inline StHbt1DHisto* QinvCorrFctnRotation::Ratio(){return mRatio;}
inline void          QinvCorrFctnRotation::SetSpecificPairCut(StHbtPairCut *paircut) { mPairCut = paircut; }
inline void          QinvCorrFctnRotation::SetMass(float mass) { mMass = mass; }
inline void          QinvCorrFctnRotation::EventBegin(const StHbtEvent *event) { mMagField = event->MagneticField(); }

#endif //QinvCorrFctnRotation_hh
