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

//_____________________________________________________________________
TMHistogrammingFastorAll::TMHistogrammingFastorAll() :
  TMHistogramming(), fTotalNumberOfSignals(0)
{
  fTheHisto = new TH1F("FastorAll", "FastOR Signals (Per Eq)", 20, -0.5, 19.5);
  fTheHisto->SetMinimum(0);
  fTheHisto->SetStats(0);
  fTheHisto->SetFillColor(kBlue);
  fTheHisto->GetXaxis()->SetTitle("Eq");
  fTheHisto->GetYaxis()->SetTitle("FastOR Signals");
  fTheHisto->SetTitleOffset(1.2,"X");
  fTheHisto->SetTitleOffset(1.6,"Y");
}
//_____________________________________________________________________
TMHistogrammingFastorAll::~TMHistogrammingFastorAll() {
  delete fTheHisto;
}
//_____________________________________________________________________
void TMHistogrammingFastorAll::EndEvent(AliITSRawStreamSPD *str, UInt_t globalEventNumber) {
  if (fEventAccept) {
    UInt_t totalSignals = 0;
    for (UInt_t eq=0; eq<20; eq++) {
      for (UInt_t hs=0; hs<6; hs++) {
	for (UInt_t chip=0; chip<10; chip++) {
	  if (str->GetFastOrSignal(eq,hs,chip)) {
	    fTheHisto->Fill(eq);
	    totalSignals++;
	  }
	}
      }
    }

    fTotalNumberOfSignals += totalSignals;
  }

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

  fTheHisto->Draw();
}
//_____________________________________________________________________
void TMHistogrammingFastorAll::Reset() {
  fTheHisto->Reset();
  fTotalNumberOfSignals = 0;

  TMHistogramming::Reset();
}


