#include "TMHistogrammingGlobalClusterXY.h"
#include <TStyle.h>
#include <TPad.h>
#include <TH2F.h>
#include <TLine.h>

//_____________________________________________________________________
TMHistogrammingGlobalClusterXY::TMHistogrammingGlobalClusterXY(TLine *tla[240]) :
  TMHistogrammingShowDet()
{ 
  for (UInt_t mod=0; mod<240; mod++) {
    fDetLines[mod] = tla[mod];
  }

  fTheHisto = new TH2F("fGlobalXYHisto","Global Cluster XY",500,-9,9,500,-9,9);
  fTheHisto->SetMarkerStyle(8);
  fTheHisto->SetMarkerSize(0.5);
  fTheHisto->SetMarkerColor(kRed);
  fTheHisto->GetXaxis()->SetTitle("X [cm]");
  fTheHisto->GetYaxis()->SetTitle("Y [cm]");
  fTheHisto->SetStats(0);

}
//_____________________________________________________________________
TMHistogrammingGlobalClusterXY::~TMHistogrammingGlobalClusterXY() {
  delete fTheHisto;
}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterXY::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(x,y);
  }
}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterXY::Draw(TPad *pad) {
  pad->cd();
  pad->SetLeftMargin(0.15);
  pad->SetRightMargin(0.15);
  pad->SetBorderSize(0);
  pad->SetBorderMode(0);

  fTheHisto->Draw();

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