#include "TMHistogrammingFastorEq.h"
#include "AliITSRawStreamSPD.h"
#include <TStyle.h>
#include <TPad.h>
#include <TH1F.h>

//_____________________________________________________________________
TMHistogrammingFastorEq::TMHistogrammingFastorEq(UInt_t eq) :
  TMHistogramming(), fEq(eq)
{
  TString name = Form("FastorEq%d",fEq);
  TString title = Form("FastOR Signals Eq %d (Per Chip)",fEq);

  fTheHisto = new TH1F(name, title, 60, -0.5, 59.5);
  fTheHisto->SetMinimum(0);
  fTheHisto->SetStats(0);
  fTheHisto->SetFillColor(kBlue);
  fTheHisto->GetXaxis()->SetTitle("hs*10 + chip");
  fTheHisto->GetYaxis()->SetTitle("FastOR Signals");
  fTheHisto->SetTitleOffset(1.2,"X");
  fTheHisto->SetTitleOffset(1.6,"Y");
}
//_____________________________________________________________________
TMHistogrammingFastorEq::~TMHistogrammingFastorEq() {
  delete fTheHisto;
}
//_____________________________________________________________________
void TMHistogrammingFastorEq::EndEvent(AliITSRawStreamSPD *str, UInt_t globalEventNumber) {
  if (fEventAccept) {
    for (UInt_t hs=0; hs<6; hs++) {
      for (UInt_t chip=0; chip<10; chip++) {
	if (str->GetFastOrSignal(fEq,hs,chip)) {
	  fTheHisto->Fill(hs*10+chip);
	}
      }
    }
  }

  TMHistogramming::EndEvent(str, globalEventNumber);
}
//_____________________________________________________________________
void TMHistogrammingFastorEq::Draw(TPad *pad) {
  pad->cd();
  pad->SetLeftMargin(0.15);
  pad->SetRightMargin(0.15);
  pad->SetBorderSize(0);
  pad->SetBorderMode(0);

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

  TMHistogramming::Reset();
}


