#include "TMHistogrammingHitMapChip.h"
#include <TStyle.h>
#include <TPad.h>
#include <TH2F.h>

//_____________________________________________________________________
TMHistogrammingHitMapChip::TMHistogrammingHitMapChip(UInt_t eq, UInt_t hs, UInt_t chip) :
  TMHistogramming(), fEq(eq), fHs(hs), fChip(chip)
{ 

  TString histoName = Form("fHitMap_%d_%d_%d",fEq,fHs,fChip);
  TString histoTitle = Form("Eq %d   HS %d   Chip %d",fEq,fHs,fChip);

  fHitMap = new TH2F(histoName.Data(), histoTitle.Data(), 32, -0.5, 31.5, 256, -0.5, 255.5);
  fHitMap->SetMinimum(0);
  fHitMap->SetStats(0);
}
//_____________________________________________________________________
TMHistogrammingHitMapChip::~TMHistogrammingHitMapChip() {
  delete fHitMap;
}
//_____________________________________________________________________
void TMHistogrammingHitMapChip::ProcessPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) {
  if (fEventAccept) {
    if (eq==fEq && hs==fHs && chip==fChip) {
      fHitMap->Fill(col,row);
    }
  }
}
//_____________________________________________________________________
void TMHistogrammingHitMapChip::Draw(TPad *pad) {
  pad->cd();
  pad->SetLeftMargin(0.15);
  pad->SetRightMargin(0.15);
  pad->SetBorderSize(0);
  pad->SetBorderMode(0);

  fHitMap->Draw("colz");
}
//_____________________________________________________________________
void TMHistogrammingHitMapChip::Reset() {
  fHitMap->Reset();
  TMHistogramming::Reset();
}


