// @(#) $Id$ // origin: hough/AliL3Histogram1D.cxx,v 1.11 Tue Jun 14 10:55:20 2005 UTC by cvetan // Author: Anders Vestbo //*-- Copyright © ALICE HLT Group #include #include "AliHLTStdIncludes.h" #include "AliHLTTPCLogging.h" #include "AliHLTTPCHistogram1D.h" #ifdef use_root #include #endif #if __GNUC__ >= 3 using namespace std; #endif //_____________________________________________________________ // AliHLTTPCHistogram1D // // 1D histogram class. ClassImp(AliHLTTPCHistogram1D) AliHLTTPCHistogram1D::AliHLTTPCHistogram1D() { //default ctor fNbins = 0; fNcells = 0; fEntries = 0; fXmin = 0; fXmax = 0; #ifdef use_root fRootHisto = 0; #endif fThreshold = 0; fContent = 0; } AliHLTTPCHistogram1D::AliHLTTPCHistogram1D(Char_t *name,Char_t */*id*/,Int_t nxbin,Double_t xmin,Double_t xmax) { //normal ctor strcpy(fName,name); fNbins = nxbin; fNcells = fNbins + 2; fEntries = 0; fXmin = xmin; fXmax = xmax; #ifdef use_root fRootHisto = 0; #endif fThreshold = 0; fContent = new Double_t[fNcells]; Reset(); } AliHLTTPCHistogram1D::~AliHLTTPCHistogram1D() { //Destructor if(fContent) delete [] fContent; #ifdef use_root if(fRootHisto) delete fRootHisto; #endif } void AliHLTTPCHistogram1D::Reset() { //Reset histogram contents #if defined(__DECCXX) bzero((char *)fContent,fNcells*sizeof(Double_t)); #else bzero(fContent,fNcells*sizeof(Double_t)); #endif fEntries=0; } void AliHLTTPCHistogram1D::Fill(Double_t x,Int_t weight) { //Fill a given bin with weight Int_t bin = FindBin(x); AddBinContent(bin,weight); } Int_t AliHLTTPCHistogram1D::FindBin(Double_t x) const { //Find a given bin if(x < fXmin || x > fXmax) return 0; return 1 + (Int_t)(fNbins*(x-fXmin)/(fXmax-fXmin)); } Int_t AliHLTTPCHistogram1D::GetMaximumBin() const { //Find the bin with the largest content Double_t maxvalue=0; Int_t maxbin=0; for(Int_t i=0; i maxvalue) { maxvalue=fContent[i]; maxbin = i; } } return maxbin; } Double_t AliHLTTPCHistogram1D::GetBinContent(Int_t bin) const { //Get 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")<AddBinContent(bin,GetBinContent(bin)); fRootHisto->Draw(option); }