// @(#) $Id$ // Author: Anders Vestbo //*-- Copyright © ALICE HLT Group #include "AliHLTTPCStandardIncludes.h" #include "AliHLTTPCLogging.h" #include "AliHLTTPCHistogram.h" #if __GNUC__ >= 3 using namespace std; #endif /** \class AliHLTTPCHistogram
//_____________________________________________________________
// AliHLTTPCHistogram
//
// 2D histogram class
//
*/ //uncomment if you want overflow checks //#define _IFON_ ClassImp(AliHLTTPCHistogram) AliHLTTPCHistogram::AliHLTTPCHistogram() { // Default constructor fNxbins = 0; fNybins = 0; fNcells = 0; fXmin = 0; fYmin = 0; fXmax = 0; fYmax = 0; fBinwidthX = 0; fBinwidthY = 0; fFirstXbin = 0; fLastXbin = 0; fFirstYbin = 0; fLastYbin = 0; fEntries = 0; fContent = 0; fThreshold = 0; #ifdef use_root fRootHisto = 0; #endif } AliHLTTPCHistogram::AliHLTTPCHistogram(Char_t *name,Char_t */*id*/, Int_t nxbin,Double_t xmin,Double_t xmax, Int_t nybin,Double_t ymin,Double_t ymax) { // Normal constructor strcpy(fName,name); fNxbins = nxbin; fNybins = nybin; fNcells = (nxbin+2)*(nybin+2); fXmin = xmin; fYmin = ymin; fXmax = xmax; fYmax = ymax; fBinwidthX = (fXmax - fXmin) / fNxbins; fBinwidthY = (fYmax - fYmin) / fNybins; fEntries = 0; fFirstXbin = 1; fFirstYbin = 1; fLastXbin = nxbin; fLastYbin = nybin; #ifdef use_root fRootHisto = 0; #endif fThreshold = 0; fContent = new Int_t[fNcells]; Reset(); } AliHLTTPCHistogram::~AliHLTTPCHistogram() { //Destructor if(fContent) delete [] fContent; #ifdef use_root if(fRootHisto) delete fRootHisto; #endif } void AliHLTTPCHistogram::Reset() { // Reset histogram contents if(fContent) for(Int_t i=0; i fXmax) return 0; return 1 + (Int_t)(fNxbins*(x-fXmin)/(fXmax-fXmin)); } Int_t AliHLTTPCHistogram::FindYbin(Double_t y) const { // Finds the bin which correspond to y if(y < fYmin || y > fYmax) return 0; return 1 + (Int_t)(fNybins*(y-fYmin)/(fYmax-fYmin)); } Int_t AliHLTTPCHistogram::GetBin(Int_t xbin,Int_t ybin) const { // Returns the bin which correspond to xbin and ybin if(xbin < fFirstXbin || xbin > fLastXbin) return 0; if(ybin < fFirstYbin || ybin > fLastYbin) return 0; return xbin + ybin*(fNxbins+2); } Int_t AliHLTTPCHistogram::GetLabelBin(Int_t xbin,Int_t ybin) const { // Returns the corresponding bin with the mc labels if(xbin < fFirstXbin || xbin > fLastXbin) return -1; if(ybin < fFirstYbin || ybin > fLastYbin) return -1; return (Int_t)(xbin/2) + ((Int_t)(ybin/2))*((Int_t)((fNxbins+3)/2)); } Int_t AliHLTTPCHistogram::GetBinContent(Int_t bin) const { // Return the bin content if(bin >= fNcells) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::GetBinContent","array")<= fNcells) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::SetBinContent","array")< fNcells) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::AddBinContent","array")<GetNbinsX()!=fNxbins || h1->GetNbinsY()!=fNybins) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::Add","array")<< "Mismatch in the number of bins "<GetFirstXbin()!=fFirstXbin || h1->GetLastXbin()!=fLastXbin || h1->GetFirstYbin()!=fFirstYbin || h1->GetLastYbin()!=fLastYbin) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::Add","array")<< "Mismatch in the bin numbering "<GetBinContent(bin); fEntries += h1->GetNEntries(); } Double_t AliHLTTPCHistogram::GetBinCenterX(Int_t xbin) const { // Returns the position of the center of a bin if(xbin < fFirstXbin || xbin > fLastXbin) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::GetBinCenterX","xbin") <<"Bin-value out of range "< fLastYbin) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::GetBinCenterY","ybin") <<"Bin-value out of range "< (fLastXbin+1.5)) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::GetBinCenterX","xbin") <<"Bin-value out of range "< (fLastYbin+1.5)) { LOG(AliHLTTPCLog::kError,"AliHLTTPCHistogram::GetBinCenterY","ybin") <<"Bin-value out of range "<Fill(GetBinCenterX(xbin),GetBinCenterY(ybin),GetBinContent(bin)); } } //fRootHisto->SetStats(kFALSE); fRootHisto->Draw(option); return; #else cerr<<"AliHLTTPCHistogram::Draw : You need to compile with ROOT in order to draw histogram"<