In file Histogram2/Histogram2.hh:

class Histogram2

Histogram API.

Inheritance:


Public Fields

typedef double xbin_t
Axis type;
typedef double histdata_t
Bin content type;
typedef double stat_t
Statistics type;

Public Methods

Histogram2 ()
Default constructor.
Histogram2 (const Histogram2& h)
Copy Constructor.
Histogram2 (const char* name, int nbinx, xbin_t xmin, xbin_t xmax, int nbiny, xbin_t ymin, xbin_t ymax, const char* xlabel = "", const char* ylabel = "", const char* nlabel = "")
Dataless constructor.
Histogram2 (const char* name, int nbinx, xbin_t* xbins, int nbiny, xbin_t* ybins, const char* xlabel = "", const char* ylabel = "", const char* nlabel = "")
Dataless constructor.
virtual ~Histogram2 ()
Histogram2 Destructor.
virtual void Clear ()
Clear bin contents, number of data entries and time.
virtual void Fill (xbin_t x, xbin_t y, double w = 1)
Increment the corresponding bin to the data by the weight.
virtual void FillN (int ntimes, const xbin_t* x, const xbin_t* y)
Increment corresponding bin to each data array element by given weights.
virtual void FillN (int ntimes, const xbin_t* x, const xbin_t* y, const double* w)
Increment corresponding bin to each data array element by given weights.
virtual void GetBinContents (histdata_t* data) const
Copy bin contens to a double array.
virtual histdata_t GetBinContent (int xbin, int ybin) const
Return bin content.
virtual void GetBinLowEdges (xbin_t* bin, int axis) const
Copy bin edges to a double array.
virtual xbin_t GetBinLowEdge (int n, int axis) const
Copy bin edges to a double array.
virtual xbin_t GetBinCenter (int n, int axis) const
Return the center of n-th bin content in the specified axis.
virtual bool GetBinErrors (stat_t* err) const
Copy bin errors to a double array.
virtual stat_t GetBinError (int xbin, int ybin) const
Return bin error.
virtual int GetBinNumber (xbin_t val, int axis) const
Return the bin number in the specified axis.
virtual xbin_t GetBinSpacing (int axis) const
Return bin spacing for fixed bin spacing histogram.
virtual int GetNEntries (void) const
Return the number of data entries.
virtual int GetNBins (int axis) const
Return number of bins.
virtual const char* GetTitle (void) const
Return the title of the histogram.
virtual const char* GetXLabel (void) const
Return the label of the X-axis.
virtual const char* GetYLabel (void) const
Return the label of the Y-axis.
virtual const char* GetNLabel (void) const
Return the label of the bin-count axis.
virtual histdata_t GetMinContent (void) const
Return the minimum of bin contents.
virtual histdata_t GetMaxContent (void) const
Return the maximum of bin contents.
virtual histdata_t GetMinContentBin (int& xbin, int& ybin) const
Return the bin number for the minimum bin content.
virtual histdata_t GetMaxContentBin (int& xbin, int& ybin) const
Return the bin number for the maximum bin content.
virtual stat_t GetMean (int axis) const
Return mean value.
virtual stat_t GetSdev (int axis) const
Return standard deviation.
virtual void GetStats (stat_t *stats) const
Copy statistics of the histogram to an array.
virtual void PutStats (const stat_t *stats)
Copy statistics of the histogram to an array.
virtual Histogram1* Projection (const char* title, int axis, int firstbin = 0, int lastbin = 99999)
Project a 2-D histogram into a 1-D histogram.
virtual int GetBinType (void) const
Return the bin type.
virtual Time GetTime (void) const
Return GPS time.
virtual bool IsErrorFlagON (void) const
Return true, if bin errors are defined.
virtual void SetTitle (const char* name)
Set the histogram title.
virtual void SetXLabel (const char* xlabel)
Set the X-axis label.
virtual void SetYLabel (const char* ylabel)
Set the Y-axis label.
virtual void SetNLabel (const char* nlabel)
Set the bin-count axis label.
virtual void SetBinLowEdges (int nbinx, xbin_t xmin, xbin_t xmax, int nbiny, xbin_t ymin, xbin_t ymax)
Set the histogram bins.
virtual void SetBinLowEdges (int nbinx, const xbin_t* xbins, int nbiny, const xbin_t* ybins)
Set the histogram bins.
virtual void SetBinContents (const histdata_t* data)
Replace the contents of bins.
virtual bool SetBinContent (int xbin, int ybin, histdata_t content)
Replace the specified bin content by the new content.
virtual void SetBinErrors (const stat_t* err)
Replace the error of bins.
virtual bool SetBinError (int x, int y, stat_t err)
Replace the specified bin error by the new error.
virtual void SetNEntries (int n)
Replace the number of entries with new number.
virtual void SetNBins (int nbin, int axis)
Set number of bins.
virtual void SetBinType (int type)
Set the bin type.
virtual void SetTime (const Time& t)
Set a time stamp (GPS).
virtual void Sumw2 (bool reset = true)
Clear or Update errors of bins based on the current bin content.
virtual void Reset (void)
Clear all the histogram data.
virtual const histdata_t& operator [] (int n) const
Get the reference to the n-th bin.
Histogram2& operator = (const Histogram2& h)
Copy histogram.
Histogram2& operator += (const Histogram2& h)
Add a histogram to the current histogram.
Histogram2& operator += (histdata_t bias)
Add a bias to each bin.
Histogram2& operator -= (const Histogram2& h)
Subtract the histogram from the current histogram.
Histogram2& operator *= (double scale)
Multiply bin contents by a scalar.
Histogram2& operator *= (const Histogram2& h)
Multiply current Histogram2 by the argument histogram.
Histogram2& operator /= (const Histogram2& h)
Divide bin contents by bin contents of the argument histogram.

Protected Methods

void Allocate (int nbinx = 0, int nbiny = 0)
Free old memory, then allocate new memory

Documentation

The Histogram2 class holds a 2-dimensional histogram data.
typedef double xbin_t
Histogram axis data type.

typedef double histdata_t
Histogram bin content data type.

typedef double stat_t
Histogram statistics data type.

void Allocate(int nbinx = 0, int nbiny = 0)
Free old memory, then allocate new memory

Histogram2()
A histogram object is initialized.

Histogram2(const Histogram2& h)
The argument histogram is duplicated into the new histogram.
Parameters:
h - Histogram to be duplicated.

Histogram2(const char* name, int nbinx, xbin_t xmin, xbin_t xmax, int nbiny, xbin_t ymin, xbin_t ymax, const char* xlabel = "", const char* ylabel = "", const char* nlabel = "")
A 2-d histogram is created with a specified number of bins, lower edge and upper edge. Bin spacings are fixed.
Parameters:
nbinx - number of bins.
xmin - lower edge.
xmax - upper edge.
nbiny - number of bins.
ymin - lower edge.
ymax - upper edge.
xlabel - label for the X-axis.
ylabel - label for the Y-axis.
nlabel - upper for the bin content axis.

Histogram2(const char* name, int nbinx, xbin_t* xbins, int nbiny, xbin_t* ybins, const char* xlabel = "", const char* ylabel = "", const char* nlabel = "")
A 2-d histogram is created with a specified number of bins and bin edges. Bin spacings are variable.
Parameters:
nbinx - number of bins.
xbins - lower bin edges (the last element is the upper edge).
nbiny - number of bins.
ybins - lower bin edges (the last element is the upper edge).
xlabel - label for the X-axis.
ylabel - label for the Y-axis.
nlabel - upper for the bin content axis.

virtual ~Histogram2()
Histogram2 Destructor.

virtual void Clear()
Bin contents, number of data entries and time are zeroed.

virtual void Fill(xbin_t x, xbin_t y, double w = 1)
The corresponding bin to the data is incremented by the given weight. The default value of the weight is 1.
Parameters:
x - Data for X-axis.
y - Data for Y-axis
w - Weight.

virtual void FillN(int ntimes, const xbin_t* x, const xbin_t* y)
Corresponding bin to each input data array element is incremented by given weights.
Parameters:
ntimes - Number of entries in the data array.
x - Data array for X-axis.
y - Data array for Y-axis.

virtual void FillN(int ntimes, const xbin_t* x, const xbin_t* y, const double* w)
Corresponding bin to each input data array element is incremented by given weights.
Parameters:
ntimes - Number of entries in the data array.
x - Data array for X-axis.
y - Data array for Y-axis.
w - Array of weights.

virtual void GetBinContents(histdata_t* data) const
All bin contents of the histogram is copied to an array. (Nbinx+2)*(Nbiny+2) arrays required. (Nbinx,Nbiny: Number of bins)
Parameters:
data - Double array into which the bin contents to be copied.

virtual histdata_t GetBinContent(int xbin, int ybin) const
The content of the specified bin is returned.
Returns:
n-th bin content.
Parameters:
xbin - Bin number in X-direction. (0: Underflow, N+1: Overflow where N is Number of bins)
ybin - Bin number in Y-direction. (0: Underflow, N+1: Overflow where N is Number of bins)

virtual void GetBinLowEdges(xbin_t* bin, int axis) const
Bin edges to the specified axis are copied to an array. N+1 arrays required. bin[0] to bin[N-1] hold low-edges. bin[N] contains the upper edge. (N: Number of bins)
Parameters:
bin - Double array into which bin edges to be copied.
axis - Select Axis. (0: X-axis, 1: Y-axis)

virtual xbin_t GetBinLowEdge(int n, int axis) const
Bin edge to the specified axis and bin number is returned. bin[0] to bin[N-1] hold low-edges. bin[N] contains the upper edge. (N: Number of bins)
Returns:
n-th bin edge.
Parameters:
axis - Select Axis. (0: X-axis, 1: Y-axis)

virtual xbin_t GetBinCenter(int n, int axis) const
Return the center of n-th bin content in the specified axis.
Returns:
n-th bin center.
Parameters:
n - Bin number. ( n = 1 to N where N is Number of bins)
axis - Select Axis. (0: X-axis, 1: Y-axis)

virtual bool GetBinErrors(stat_t* err) const
All bin errors of the histogram is copied to an array. (Nbinx+2)*(Nbiny+2) arrays required. (Nbinx,Nbiny: Number of bins)
Parameters:
err - Double array into which the bin errors to be copied.

virtual stat_t GetBinError(int xbin, int ybin) const
The error of the specified bin is returned.
Returns:
bin error.
Parameters:
xbin - Bin number in X-direction. (0: Underflow, N+1: Overflow where N is Number of bins)
ybin - Bin number in Y-direction. (0: Underflow, N+1: Overflow where N is Number of bins)

virtual int GetBinNumber(xbin_t val, int axis) const
In the specified axis, bin number corresponding to the argument value is returned.
Returns:
bin number.
Parameters:
val - Data.
axis - Select Axis. (0: X-axis, 1: Y-axis)

virtual xbin_t GetBinSpacing(int axis) const
The bin spacing for a fixed bin spacing histogram is returned.
Returns:
bin spacing. 0 if bin spacing is variable or undefined.
Parameters:
axis - Select Axis. (0: X-axis, 1: Y-axis)

virtual int GetNEntries(void) const
The number of data entries is returned.
Returns:
Number of data entries.

virtual int GetNBins(int axis) const
The number of bins in the specified axis is returned.
Returns:
Number of bins.

virtual const char* GetTitle(void) const
The title of the histogram is returned.
Returns:
Title of the histogram.

virtual const char* GetXLabel(void) const
The label of the X-axis is returned.
Returns:
X-axis Label.

virtual const char* GetYLabel(void) const
The label of the Y-axis is returned.
Returns:
Y-axis Label.

virtual const char* GetNLabel(void) const
The label of the bin-count axis is returned.
Returns:
bin-count axis Label.

virtual histdata_t GetMinContent(void) const
The minimum of bin contents is returned.
Returns:
Minimum of bin contents.

virtual histdata_t GetMaxContent(void) const
The maximum of bin contents is returned.
Returns:
Maximum of bin contents.

virtual histdata_t GetMinContentBin(int& xbin, int& ybin) const
The bin number for the minimum bin content is returned.
Returns:
Bin number for the minimum bin contents.

virtual histdata_t GetMaxContentBin(int& xbin, int& ybin) const
The bin number for the maximum bin content is returned.
Returns:
Bin number for the maximum bin contents.

virtual stat_t GetMean(int axis) const
The mean value in the specified axis is returned.
Returns:
Mean.
Parameters:
axis - Select Axis. (0: X-axis, 1: Y-axis)

virtual stat_t GetSdev(int axis) const
The standard deviation value in the specified axis is returned.
Returns:
standard deviation.
Parameters:
axis - Select Axis. (0: X-axis, 1: Y-axis)

virtual void GetStats(stat_t *stats) const
The statistics of the histogram are copied to the specified array.
stats[0] Sum of weight
stats[1] Sum of weight^2
stats[2] Sum of weight * xdata
stats[3] Sum of weight * xdata^2
stats[4] Sum of weight * ydata
stats[5] Sum of weight * ydata^2
stats[6] Sum of weight * xdata * ydata
Parameters:
stats - Array to store the statistics.

virtual void PutStats(const stat_t *stats)
The statistics of the histogram are replaced by new values.
stats[0] Sum of weight
stats[1] Sum of weight^2
stats[2] Sum of weight * xdata
stats[3] Sum of weight * xdata^2
stats[4] Sum of weight * ydata
stats[5] Sum of weight * ydata^2
stats[6] Sum of weight * xdata * ydata
Parameters:
stats - Array contains new statistics.

virtual Histogram1* Projection(const char* title, int axis, int firstbin = 0, int lastbin = 99999)
A 2-D histogram is projected into a 1-D histogram along the specified axis.
Returns:
Projected 1-D histogram.
Parameters:
title - Title of the 1-d histogram.
axis - Select Axis. (0: X-axis, 1: Y-axis)
firstbin - First bin to be projected.
lastbin - Last bin to be projected.

virtual int GetBinType(void) const
The type of the histogram bin is returned.
Returns:
Bin type.
0 Undefined
1 Fixed Bin
2 Variable Bin

virtual Time GetTime(void) const
GPS time is returned.
Returns:
GPS time.

virtual bool IsErrorFlagON(void) const
If error of bins are defined, return true.
Returns:
true if bin errors are defined, otherwise false.

virtual void SetTitle(const char* name)
New title is copied to the title string.
Parameters:
name - Pointer to the character array.

virtual void SetXLabel(const char* xlabel)
New label is copied to the X-axis label string.
Parameters:
name - Pointer to the character array.

virtual void SetYLabel(const char* ylabel)
New label is copied to the Y-axis label string.
Parameters:
name - Pointer to the character array.

virtual void SetNLabel(const char* nlabel)
New label is copied to the bin-count axis label string.
Parameters:
name - Pointer to the character array.

virtual void SetBinLowEdges(int nbinx, xbin_t xmin, xbin_t xmax, int nbiny, xbin_t ymin, xbin_t ymax)
The histogram bins are redefined.
Parameters:
nbinx - Number of bins in X-axis.
xmin - Lower edge in X-axis.
xmax - Upper edge in X-axis.
nbiny - Number of bins in Y-axis.
ymin - Lower edge in Y-axis.
ymax - Upper edge in Y-axis.

virtual void SetBinLowEdges(int nbinx, const xbin_t* xbins, int nbiny, const xbin_t* ybins)
The histogram bins are redefined.
Parameters:
nbinx - Number of bins in X-axis.
xbins - Array of low-edges in X-axis (the last element is the upper edge).
nbiny - Number of bins in Y-axis.
ybins - Array of low-edges in Y-axis (the last element is the upper edge).

virtual void SetBinContents(const histdata_t* data)
The histogram bin contents are replaced by new contents. Require (Nbinx+2)*(Nbiny+2) data array.
Parameters:
data - Array of new contents.

virtual bool SetBinContent(int xbin, int ybin, histdata_t content)
The specified bin content is replaced by the new content.
Parameters:
xbin - Bin number in X-Axis.
ybin - Bin number in Y-Axis.
content - New content.

virtual void SetBinErrors(const stat_t* err)
The histogram bin errors are replaced by new errors. Require (Nbinx+2)*(Nbiny+2) data array.
Parameters:
data - Array of new errors.

virtual bool SetBinError(int x, int y, stat_t err)
The specified bin error is replaced by the new error.
Parameters:
xbin - Bin number in X-Axis.
ybin - Bin number in Y-Axis.
content - New error.

virtual void SetNEntries(int n)
The number of entries to the histogram is replaced by the new number.
Parameters:
n - Number of entries to be replaced.

virtual void SetNBins(int nbin, int axis)
The number of bins in the specified axis is changed to new number.
Parameters:
nbin - Number of bins.
axis - Select Axis. (0: X-axis, 1: Y-axis)

virtual void SetBinType(int type)
The bin type of the histogram is replaced to the specifed type.
Parameters:
type - Bin type. (0: Undefined, 1: Fixed, 2: Variable)

virtual void SetTime(const Time& t)
A time stamp in GPS seconds is set.
Parameters:
t - GPS time.

virtual void Sumw2(bool reset = true)
The errors of bins are cleared or updated based on the current bin content.
Parameters:
reset - (true: clear bin error with zero, false: update bin error)

virtual void Reset(void)
All the histogram data and statistics are cleared.

virtual const histdata_t& operator [] (int n) const
Reference to the n-th bin of (Nbinx+2)*(Nbiny+2) data array is returned. (Nbinx = of bin in X-axis, Nbiny = of bin in Y-axis)
Returns:
Reference to the n-th bin.
Parameters:
n - Bin number.

Histogram2& operator = (const Histogram2& h)
The Histogram2 data are copied to the current Histogram2.
Returns:
Reference to the updated Histogram2.
Parameters:
h - Constant Histogram2 to be copied.

Histogram2& operator += (const Histogram2& h)
The Histogram2 data are added to the current Histogram2.
Returns:
Reference to the updated Histogram1.
Parameters:
h - Constant Histogram2 to be added.

Histogram2& operator += (histdata_t bias)
A bias is added to each bin of the histogram.
Returns:
Reference to the updated Histogram2.
Parameters:
bias - Number to be added.

Histogram2& operator -= (const Histogram2& h)
The current Histogram2 is subtracted by another Histogram2 data.
Returns:
Reference to the updated Histogram2.
Parameters:
h - Constant Histogram2 to subtract.

Histogram2& operator *= (double scale)
Bin contents are multiplied by a scalar.
Returns:
Reference to the updated Histogram2.
Parameters:
scale - Number to be multiplied.

Histogram2& operator *= (const Histogram2& h)
Current Histogram2 is multiplied by the argument histogram.
Returns:
Reference to the updated Histogram2.
Parameters:
h - Constant Histogram2 to multiply.

Histogram2& operator /= (const Histogram2& h)
Current Histogram2 is divied by the argument histogram bin by bin.
Returns:
Reference to the updated Histogram2.
Parameters:
h - Constant Histogram2 to divide.


This class has no child classes.
Author:
Masahiro Ito
Version:
1.0; Last modified October 15, 2001

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++