#include "StHbtMaker/Infrastructure/StHbtTrack.hh"
#include "StHbtMaker/Infrastructure/StHbtTypes.hh"
#include "StHbtMaker/Cut/trackCutMonitor_P_vs_Dedx.h"

#ifdef __ROOT__ 
ClassImp(trackCutMonitor_P_vs_Dedx)
#endif

//_________________
trackCutMonitor_P_vs_Dedx::trackCutMonitor_P_vs_Dedx() { // default constructor
  mHisto = new TH2F("trackCutMonitor_P_vs_Dedx",
		    "Momentum (GeV/c) vs Energy loss (a.u.)",
		    200,0.,2.,100,0.,10e-6);
  mCharge = 0;
}

//_________________
trackCutMonitor_P_vs_Dedx::trackCutMonitor_P_vs_Dedx(int charge) {
  mHisto = new TH2F("trackCutMonitor_P_vs_Dedx",
		    "Momentum (GeV/c) vs Energy loss (a.u.)",
		    200,0.,2.,100,0.,10e-6);
  mCharge = charge;
}

//_________________
trackCutMonitor_P_vs_Dedx::trackCutMonitor_P_vs_Dedx(int charge, 
						     const char* TitCutMoni){
  mHisto = new TH2F(TitCutMoni,
		    "Momentum (GeV/c) vs Energy loss (a.u.)",
		    200,0.,2.,100,0.,10e-6);
  mCharge = charge;
}

//_________________
trackCutMonitor_P_vs_Dedx::trackCutMonitor_P_vs_Dedx(int charge, 
						     const char* TitCutMoni, 
						     const char* title,
						     int nbins1, double min1, 
						     double max1,
						     int nbins2, double min2, 
						     double max2){

  mHisto= new TH2F(title, TitCutMoni, nbins1 , min1, max1, nbins2 , min2, max2);
  mCharge = charge;
}

//_________________
trackCutMonitor_P_vs_Dedx::trackCutMonitor_P_vs_Dedx(const  trackCutMonitor_P_vs_Dedx& cutMoni){
  mCharge = cutMoni.mCharge;
  mHisto = new TH2F(*(cutMoni.mHisto));
}

//_________________
trackCutMonitor_P_vs_Dedx::trackCutMonitor_P_vs_Dedx(const  trackCutMonitor_P_vs_Dedx& cutMoni, 
						      int charge) {
  mCharge = charge;
  mHisto = new TH2F(*(cutMoni.mHisto));
}

//_________________
trackCutMonitor_P_vs_Dedx::~trackCutMonitor_P_vs_Dedx(){
  delete mHisto;
}

//_________________
void trackCutMonitor_P_vs_Dedx::Fill(const StHbtTrack* track){
  if (track->Charge() == mCharge || mCharge == 0)
    mHisto->Fill( track->P().mag() , track->dEdx(), 1.);
}


