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

//_____________________________________________________________________
TMHistogrammingGlobalClusterZY::TMHistogrammingGlobalClusterZY(TLine *tla[960]) : 
  TMHistogrammingShowDet()
{ 

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

  fTheHisto = new TH2F("fGlobalZYHisto","Global Cluster ZY",500,-15,15,500,-9,9);
  fTheHisto->SetMarkerStyle(8);
  fTheHisto->SetMarkerSize(0.5);
  fTheHisto->SetMarkerColor(kRed);
  fTheHisto->GetXaxis()->SetTitle("Z [cm]");
  fTheHisto->GetYaxis()->SetTitle("Y [cm]");
  fTheHisto->SetStats(0);
}
//_____________________________________________________________________
TMHistogrammingGlobalClusterZY::~TMHistogrammingGlobalClusterZY() {
  delete fTheHisto;
}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterZY::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,y);
  }
}
//_____________________________________________________________________
void TMHistogrammingGlobalClusterZY::Draw(TPad *pad) {
  pad->cd();
  pad->SetLeftMargin(0.15);
  pad->SetRightMargin(0.15);
  pad->SetBorderSize(0);
  pad->SetBorderMode(0);

  fTheHisto->Draw();

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


