#include "AliL3Logging.h"
#include "AliL3Histogram.h"
-#if __GNUC__ == 3
+#if __GNUC__ >= 3
using namespace std;
#endif
AliL3Histogram::AliL3Histogram()
{
+ // Default constructor
fNxbins = 0;
fNybins = 0;
fNcells = 0;
#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;
void AliL3Histogram::Reset()
{
+ // Reset histogram contents
if(fContent)
for(Int_t i=0; i<fNcells; i++) fContent[i] = 0;
void AliL3Histogram::Fill(Double_t x,Double_t y,Int_t weight)
{
+ // Fill the weight into a bin which correspond to x and y
Int_t bin = FindBin(x,y);
#ifdef _IFON_
if(bin < 0)
void AliL3Histogram::Fill(Double_t x,Int_t ybin,Int_t weight)
{
+ // Fill the weight into a bin which correspond to x and ybin
Int_t xbin = FindXbin(x);
Int_t bin = GetBin(xbin,ybin);
#ifdef _IFON_
void AliL3Histogram::Fill(Int_t xbin,Double_t y,Int_t weight)
{
+ // Fill the weight into a bin which correspond to xbin and y
Int_t ybin = FindYbin(y);
Int_t bin = GetBin(xbin,ybin);
#ifdef _IFON_
void AliL3Histogram::Fill(Int_t xbin,Int_t ybin,Int_t weight)
{
+ // Fill the weight into a bin which correspond to xbin and ybin
Int_t bin = GetBin(xbin,ybin);
#ifdef _IFON_
if(bin < 0)
Int_t AliL3Histogram::FindBin(Double_t x,Double_t y) const
{
+ // Finds the bin which correspond to x and y
Int_t xbin = FindXbin(x);
Int_t ybin = FindYbin(y);
#ifdef _IFON_
return GetBin(xbin,ybin);
}
+Int_t AliL3Histogram::FindLabelBin(Double_t x,Double_t y) const
+{
+ // Returns the corresponding bin with the mc labels
+ Int_t xbin = FindXbin(x);
+ Int_t ybin = FindYbin(y);
+#ifdef _IFON_
+ if(!xbin || !ybin)
+ return -1;
+#endif
+
+ return GetLabelBin(xbin,ybin);
+}
+
Int_t AliL3Histogram::FindXbin(Double_t x) const
{
+ // Finds the bin which correspond to x
if(x < fXmin || x > fXmax)
return 0;
Int_t AliL3Histogram::FindYbin(Double_t y) const
{
+ // Finds the bin which correspond to y
if(y < fYmin || y > fYmax)
return 0;
Int_t AliL3Histogram::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 xbin + ybin*(fNxbins+2);
}
+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")<<AliL3Log::kDec<<
void AliL3Histogram::SetBinContent(Int_t xbin,Int_t ybin,Int_t value)
{
+ // Set bin content
Int_t bin = GetBin(xbin,ybin);
#ifdef _IFON_
if(bin == 0)
void AliL3Histogram::SetBinContent(Int_t bin,Int_t value)
{
+ // Set bin content
if(bin >= fNcells)
{
void AliL3Histogram::AddBinContent(Int_t xbin,Int_t ybin,Int_t weight)
{
+ // Adds weight to bin content
Int_t bin = GetBin(xbin,ybin);
#ifdef _IFON_
if(bin == 0)
void AliL3Histogram::AddBinContent(Int_t bin,Int_t weight)
{
+ // Adds weight to bin content
if(bin < 0 || bin > fNcells)
{
LOG(AliL3Log::kError,"AliL3Histogram::AddBinContent","array")<<AliL3Log::kDec<<
fContent[bin] += weight;
}
-void AliL3Histogram::Add(AliL3Histogram *h1,Double_t weight)
+void AliL3Histogram::Add(AliL3Histogram *h1,Double_t /*weight*/)
{
//Adding two histograms. Should be identical.
Double_t AliL3Histogram::GetBinCenterX(Int_t xbin) const
{
+ // Returns the position of the center of a bin
if(xbin < fFirstXbin || xbin > fLastXbin)
{
LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterX","xbin")
Double_t AliL3Histogram::GetBinCenterY(Int_t ybin) const
{
+ // Returns the position of the center of a bin
if(ybin < fFirstYbin || ybin > fLastYbin)
{
LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterY","ybin")
Double_t AliL3Histogram::GetPreciseBinCenterX(Float_t xbin) const
{
- if(xbin < fFirstXbin || xbin > fLastXbin)
+ // Returns the position of the center of a bin using precise values inside the bin
+ if(xbin < (fFirstXbin-1.5) || xbin > (fLastXbin+1.5))
{
LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterX","xbin")
<<"Bin-value out of range "<<xbin<<ENDLOG;
Double_t AliL3Histogram::GetPreciseBinCenterY(Float_t ybin) const
{
- if(ybin < fFirstYbin || ybin > fLastYbin)
+ // Returns the position of the center of a bin using precise values inside the bin
+ if(ybin < (fFirstYbin-1.5) || ybin > (fLastYbin+1.5))
{
LOG(AliL3Log::kError,"AliL3Histogram::GetBinCenterY","ybin")
<<"Bin-value out of range "<<ybin<<ENDLOG;
void AliL3Histogram::Draw(Char_t *option)
{
+ // Fill the contents of the corresponding ROOT histogram and draws it
#ifdef use_root
if(!fRootHisto)
CreateRootHisto();
//fRootHisto->SetStats(kFALSE);
fRootHisto->Draw(option);
return;
-#endif
+#else
cerr<<"AliL3Histogram::Draw : You need to compile with ROOT in order to draw histogram"<<endl;
-
+#endif
}
void AliL3Histogram::CreateRootHisto()
{
+ // Create ROOT histogram out of AliL3Histogram
#ifdef use_root
fRootHisto = new TH2F(fName,"",fNxbins,fXmin,fXmax,fNybins,fYmin,fYmax);
return;
-#endif
+#else
cerr<<"AliL3Histogram::CreateRootHisto : You need to compile with ROOT in order to create ROOT histogram"<<endl;
+#endif
}
ofstream& operator<<(ofstream &o, const AliL3Histogram &h)