X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2Fhough%2FAliL3Histogram.cxx;h=e006985ed04313e37ac2df63f264009cea9d023c;hb=78001a7300e44384a691580cb18d49a1ce3e41d5;hp=1a111211fabde912bba366fbc50cc1d61aa5c6f9;hpb=6b9816d61fe59c6bad9d0037005c4709db23f893;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/hough/AliL3Histogram.cxx b/HLT/hough/AliL3Histogram.cxx index 1a111211fab..e006985ed04 100644 --- a/HLT/hough/AliL3Histogram.cxx +++ b/HLT/hough/AliL3Histogram.cxx @@ -1,21 +1,35 @@ -//$Id$ +// @(#) $Id$ // Author: Anders Vestbo -//*-- Copyright © ASV +//*-- Copyright © ALICE HLT Group + +#include "AliL3StandardIncludes.h" -#include #include "AliL3Logging.h" #include "AliL3Histogram.h" +#if __GNUC__ >= 3 +using namespace std; +#endif + +/** \class AliL3Histogram +
 //_____________________________________________________________
 // AliL3Histogram
 //
 // 2D histogram class
+//
+
+*/ + +//uncomment if you want overflow checks +//#define _IFON_ ClassImp(AliL3Histogram) AliL3Histogram::AliL3Histogram() { + // Default constructor fNxbins = 0; fNybins = 0; fNcells = 0; @@ -23,6 +37,8 @@ AliL3Histogram::AliL3Histogram() fYmin = 0; fXmax = 0; fYmax = 0; + fBinwidthX = 0; + fBinwidthY = 0; fFirstXbin = 0; fLastXbin = 0; fFirstYbin = 0; @@ -35,21 +51,23 @@ AliL3Histogram::AliL3Histogram() #endif } - -AliL3Histogram::AliL3Histogram(Char_t *name,Char_t *id, +AliL3Histogram::AliL3Histogram(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; @@ -73,72 +91,136 @@ AliL3Histogram::~AliL3Histogram() if(fRootHisto) delete fRootHisto; #endif - } - void AliL3Histogram::Reset() { - - for(Int_t i=0; i fXmax) return 0; return 1 + (Int_t)(fNxbins*(x-fXmin)/(fXmax-fXmin)); - } -Int_t AliL3Histogram::FindYbin(Double_t y) +Int_t AliL3Histogram::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 AliL3Histogram::GetBin(Int_t xbin,Int_t ybin) +Int_t AliL3Histogram::GetBin(Int_t xbin,Int_t ybin) const { - if(xbin < 0 || xbin > GetLastXbin()) - { - LOG(AliL3Log::kError,"AliL3Histogram::GetBin","array")< GetLastYbin()) - { - LOG(AliL3Log::kError,"AliL3Histogram::Getbin","array")< fLastXbin) + return 0; + if(ybin < fFirstYbin || ybin > fLastYbin) + return 0; return xbin + ybin*(fNxbins+2); } -Int_t AliL3Histogram::GetBinContent(Int_t bin) +Int_t AliL3Histogram::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 AliL3Histogram::GetBinContent(Int_t bin) const { + // Return the bin content if(bin >= fNcells) { LOG(AliL3Log::kError,"AliL3Histogram::GetBinContent","array")<= fNcells) { @@ -168,23 +255,27 @@ void AliL3Histogram::SetBinContent(Int_t bin,Int_t value) "bin out of range "< fNcells) { LOG(AliL3Log::kError,"AliL3Histogram::AddBinContent","array")<GetFirstXbin()!=fFirstXbin || h1->GetLastXbin()!=fLastXbin || h1->GetFirstYbin()!=fFirstYbin || h1->GetLastYbin()!=fLastYbin) { @@ -228,46 +320,103 @@ void AliL3Histogram::Add(AliL3Histogram *h1,Double_t weight) fEntries += h1->GetNEntries(); } -Double_t AliL3Histogram::GetBinCenterX(Int_t xbin) +Double_t AliL3Histogram::GetBinCenterX(Int_t xbin) const { - - Double_t binwidth = (fXmax - fXmin) / fNxbins; - return fXmin + (xbin-1) * binwidth + 0.5*binwidth; - + // Returns the position of the center of a bin + if(xbin < fFirstXbin || xbin > fLastXbin) + { + LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterX","xbin") + <<"Bin-value out of range "< fLastYbin) + { + LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterY","ybin") + <<"Bin-value out of range "< (fLastXbin+1.5)) + { + LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterX","xbin") + <<"Bin-value out of range "< (fLastYbin+1.5)) + { + LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterY","ybin") + <<"Bin-value out of range "<AddBinContent(bin,GetBinContent(bin)); + for(Int_t ybin=GetFirstYbin(); ybin<=GetLastYbin(); ybin++) + { + Int_t bin = GetBin(xbin,ybin); + fRootHisto->Fill(GetBinCenterX(xbin),GetBinCenterY(ybin),GetBinContent(bin)); + } } - fRootHisto->SetStats(kFALSE); + //fRootHisto->SetStats(kFALSE); fRootHisto->Draw(option); return; -#endif +#else cerr<<"AliL3Histogram::Draw : You need to compile with ROOT in order to draw histogram"<