#include "TMHistogrammingGlobalClusterXYZ.h"
#include "TMControlSPD.h"
#include "AliITSRawStreamSPD.h"
#include <TStyle.h>
#include <TPad.h>
#include <TH3F.h>
#include <TPolyLine3D.h>

//_____________________________________________________________________
TMHistogrammingGlobalClusterXYZ::TMHistogrammingGlobalClusterXYZ(TPolyLine3D *tla[240]) :
  TMHistogrammingShowDet()
{

  for (UInt_t mod=0; mod<240; mod++) {
    fDetLines[mod] = tla[mod];
  }

  fTheHisto = new TH3F("fGlobalClusterXYZHisto","Global Cluster XYZ",100,-15,15,100,-9,9,100,-9,9);
  fTheHisto->SetMarkerStyle(8);
  fTheHisto->SetMarkerSize(0.5);
  fTheHisto->SetMarkerColor(kRed);
  fTheHisto->GetXaxis()->SetTitle("Z [cm]");
  fTheHisto->GetYaxis()->SetTitle("X [cm]");
  fTheHisto->GetZaxis()->SetTitle("Y [cm]");
  fTheHisto->SetStats(0);

}
//_____________________________________________________________________
TMHistogrammingGlobalClusterXYZ::~TMHistogrammingGlobalClusterXYZ() {
  delete fTheHisto;
}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterXYZ::ProcessCluster(Float_t x, Float_t y, Float_t z, UInt_t module, UInt_t size, UInt_t widz, UInt_t widphi, UInt_t type) {
  if (fEventAccept) {
    fTheHisto->Fill(z,x,y);
  }
}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterXYZ::Draw(TPad *pad) {
  pad->cd();
  pad->SetLeftMargin(0.15);
  pad->SetRightMargin(0.15);
  pad->SetBorderSize(0);
  pad->SetBorderMode(0);

  fTheHisto->Draw();

}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterXYZ::Reset() {
  fTheHisto->Reset();
  TMHistogramming::Reset();
}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterXYZ::DrawDetector(TPad *pad) {
  pad->cd();
  for (UInt_t mod=0; mod<240; mod++) {
    fDetLines[mod]->Draw();
  }
}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterXYZ::HideDetector(TPad *pad) {
  pad->Clear();
  Draw(pad);
}

