#include "TMHistogrammingBunchCrossingMod4.h"
#include "event.h"
#include <TStyle.h>
#include <TPad.h>
#include <TH1F.h>

//_____________________________________________________________________
TMHistogrammingBunchCrossingMod4::TMHistogrammingBunchCrossingMod4() :
  TMHistogrammingCheckButton()
{ 

  fTheHisto = new TH1F("BunchCrossingMod4", "BC mod 4", 4, -0.5, 3.5);
  fTheHisto->SetMinimum(0);
  fTheHisto->SetStats(0);
  fTheHisto->SetFillColor(kBlue);
  fTheHisto->GetXaxis()->SetTitle("BC mod 4");
  fTheHisto->GetYaxis()->SetTitle("Number of Events");
  fTheHisto->SetTitleOffset(1.2,"X");
  fTheHisto->SetTitleOffset(1.6,"Y");

}
//_____________________________________________________________________
TMHistogrammingBunchCrossingMod4::~TMHistogrammingBunchCrossingMod4() {
  delete fTheHisto;
}
//_____________________________________________________________________
void TMHistogrammingBunchCrossingMod4::StartEvent(eventHeaderStruct *event, UInt_t globalEventNumber) {
  UInt_t bc = EVENT_ID_GET_BUNCH_CROSSING(event->eventId);
  if (fChecked) {
    printf("bc=%d\n",bc);
  }
  fTheHisto->Fill(bc%4);
}
//_____________________________________________________________________
void TMHistogrammingBunchCrossingMod4::Draw(TPad *pad) {
  pad->cd();
  pad->SetLeftMargin(0.15);
  pad->SetRightMargin(0.15);
  pad->SetBorderSize(0);
  pad->SetBorderMode(0);

  fTheHisto->Draw();
}
//_____________________________________________________________________
void TMHistogrammingBunchCrossingMod4::Reset() {
  fTheHisto->Reset();

  TMHistogramming::Reset();
}


