In file Histogram1/Histogram1.hh:

class Histogram1

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

Histogram1 ()
Default constructor.
Histogram1 (const Histogram1& h)
Copy Constructor.
Histogram1 (const char* name, int nbinx, xbin_t xmin, xbin_t xmax, const char* xlabel = "", const char* nlabel = "")
Dataless constructor.
Histogram1 (const char* name, int nbinx, const xbin_t* xbins, const char* xlabel = "", const char* nlabel = "")
Dataless constructor.
virtual ~Histogram1 ()
Histogram1 Destructor.
virtual void Clear ()
Clear bin contents, number of data entries and time.
virtual std::ostream& Dump (std::ostream& out) const
Output formatted dump of the Histogram1 data.
virtual void Fill (xbin_t x, double w = 1.0)
Increment the corresponding bin to the data by the weight.
virtual void FillN (int ntimes, const xbin_t* x)
Increment corresponding bins to each element of the data array.
virtual void FillN (int ntimes, const xbin_t* x, const double* w)
Increment corresponding bins to each data array element by given weights.
virtual void GetBinContents (histdata_t* data) const
Copy bin contens to a double array.
virtual void GetBinLowEdges (xbin_t* bin) const
Copy low-edges and upper edge to a double array.
virtual xbin_t GetBinLowEdge (int n) const
Return low-edge of the n-th bin.
virtual histdata_t GetBinContent (int n) const
Return the n-th bin content.
virtual xbin_t GetBinCenter (int n) const
Return the center of n-th bin content.
virtual bool GetBinErrors (stat_t* err) const
Copy the error of bins to an array.
virtual stat_t GetBinError (int n) const
Return the n-th bin error.
virtual int GetBinNumber (xbin_t x) const
Return the bin number.
virtual xbin_t GetBinSpacing (void) const
Return bin spacing for fixed bin spacing histogram.
virtual int GetNEntries (void) const
Return the number of data entries.
virtual int GetNBins (void) const
Return the number of bins.
virtual const char* GetTitle (void) const
Return title of the histogram.
virtual const char* GetXLabel (void) const
Return X-axis label.
virtual const char* GetNLabel (void) const
Return bin-count axis label.
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 int GetMinContentBin (void) const
Return the bin number for the minimum bin content.
virtual int GetMaxContentBin (void) const
Return the bin number for the maximum bin content.
virtual stat_t GetMean (void) const
Return the mean value.
virtual stat_t GetSdev (void) const
Return the standard deviation.
virtual void GetStats (stat_t *stats) const
Copy statistics of the histogram to an array.
virtual void PutStats (const stat_t *stats)
Replace the statistics of the 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 SetNLabel (const char* nlabel)
Set the bin-count axis label.
virtual void SetBinLowEdges (int nbinx, xbin_t xmin, xbin_t xmax)
Set the histogram bins.
virtual void SetBinLowEdges (int nbinx, const xbin_t* xbins)
Set the histogram bins.
virtual void SetBinContents (const histdata_t* data)
Replace the contents of bins.
virtual void SetBinContent (int n, histdata_t content)
Replace n-th bin content.
virtual void SetBinErrors (const stat_t* err)
Replace errors of bins.
virtual bool SetBinError (int n, stat_t err)
Replace n-th bin error.
virtual void SetNEntries (int n)
Replace the number of entries with new number.
virtual void SetNBins (int nbinx)
Set number of bins.
virtual void SetBinType (int n)
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.
Histogram1& operator = (const Histogram1& h)
Copy histogram.
Histogram1& operator += (const Histogram1& h)
Add a histogram to the current histogram.
Histogram1& operator += (histdata_t bias)
Add a bias to each bin.
Histogram1& operator -= (const Histogram1& h)
Subtract the histogram from the current histogram.
Histogram1& operator *= (double scale)
Multiply bin contents by a scalar.
Histogram1& operator *= (const Histogram1& h)
Multiply current Histogram1 by the argument histogram.
Histogram1& operator /= (const Histogram1& h)
Divide bin contents by bin contents of the argument histogram.

Protected Methods

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

Documentation

The Histogram1 class holds a 1-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 nbin = 0)
Free old memory, then allocate new memory

Histogram1()
A histogram object is initialized.

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

Histogram1(const char* name, int nbinx, xbin_t xmin, xbin_t xmax, const char* xlabel = "", const char* nlabel = "")
A 1-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.
xlabel - labe for the X-axis.
nlabel - upper for the bin content axis.

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

virtual ~Histogram1()
Histogram1 Destructor.

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

virtual std::ostream& Dump(std::ostream& out) const
A formatted dump of the histogram contents are written to the specified output stream.
Returns:
reference to the specified output stream.
Parameters:
out - Output stream to receive the formatted Histogram1 dump.

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

virtual void FillN(int ntimes, const xbin_t* x)
Corresponding bins to each element of the data array are incremented by 1.
Parameters:
ntimes - Number of elements in the data array.
x - Data array.

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

virtual void GetBinContents(histdata_t* data) const
All bin contents of the histogram is copied to an array. N+2 arrays required. data[0] and data[N+1] contain under and overflow of the histogram, respectively. (N: Number of bins)
Parameters:
data - Double array into which the bin contents to be copied.

virtual void GetBinLowEdges(xbin_t* bin) const
Bin edges 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:
data - Double array into which the lower-edges to be copied.

virtual xbin_t GetBinLowEdge(int n) const
The low-edge of n-th bin is returned.
Parameters:
n - Bin number. (N: Number of bins)
1 to N low-edges of n-th bin
N+1 Upper edge

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

virtual xbin_t GetBinCenter(int n) const
Return the center of n-th bin content.
Returns:
n-th bin center.
Parameters:
n - Bin number. ( n = 1 to N where N is Number of bins)

virtual bool GetBinErrors(stat_t* err) const
The errors of bins are copied to an array. If bin errors aren't defined, returns false. N+2 arrays required. err[0] and err[N+1] contain errors of under and overflow, respectively. (N: Number of bins)
Returns:
return true if bin errors are defined, otherwise false.
Parameters:
err - Array into which the errors to be copied.

virtual stat_t GetBinError(int n) const
The error of the n-th bin is returned.
Returns:
n-th bin error, if bin errors aren't defined return -1.
Parameters:
n - Bin number. (0: Underflow, N+1: Overflow where N is Number of bins)

virtual int GetBinNumber(xbin_t x) const
The bin number corresponding to the argument value is returned.
Returns:
bin number.
Parameters:
x - Data.

virtual xbin_t GetBinSpacing(void) const
The bin spacing for a fixed bin spacing histogram is returned.
Returns:
bin spacing. -1 if bin spacing is variable or undefined.

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

virtual int GetNBins(void) const
The number of bins in the histogram 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* 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 int GetMinContentBin(void) const
The bin number for the minimum bin content is returned.
Returns:
Bin number for the minimum bin contents.

virtual int GetMaxContentBin(void) const
The bin number for the maximum bin content is returned.
Returns:
Bin number for the maximum bin contents.

virtual stat_t GetMean(void) const
The mean value is returned.
Returns:
Mean.

virtual stat_t GetSdev(void) const
The standard deviation is returned.
Returns:
standard deviation.

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 * data
stats[3] Sum of weight * data^2

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 * data
stats[3] Sum of weight * data^2

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 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)
The histogram bins are redefined.
Parameters:
nbinx - Number of bins.
xmin - Lower edge.
xmax - Upper edge.

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

virtual void SetBinContents(const histdata_t* data)
The histogram contents are replaced by new contents. Require N+2 data array. data[0] and data[N+1] contain underflow and overflow, respectivly.
Parameters:
data - Array of new contents.

virtual void SetBinContent(int n, histdata_t content)
The n-th bin content is replaced by the new content.
Parameters:
n - Bin number. (0: Underflow, N+1: Overflow where N is Number of bins)
content - New content.

virtual void SetBinErrors(const stat_t* err)
The errors of bins are replaced by new values. Require N+2 data array. err[0] and err[N+1] contain errors of underflow and overflow, respectivly.
Parameters:
data - Array of new values of error.

virtual bool SetBinError(int n, stat_t err)
The n-th bin error is replaced by the new value. If bin errors aren't defined, return false and does nothing on err array.
Returns:
true if bin errors are defined, otherwise false.
Parameters:
n - Bin number. (0: Underflow, N+1: Overflow where N is Number of bins)
content - New content.

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 nbinx)
The number of bins of the histogram is changed to the specified number.
Parameters:
n - Number of bins.

virtual void SetBinType(int n)
The bin type of the histogram is replaced to the specifed type.
Parameters:
n - 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 is returned.
Returns:
Reference to the n-th bin.
Parameters:
n - Bin number.

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

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

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

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

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

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

Histogram1& operator /= (const Histogram1& h)
Current Histogram1 is divied by the argument histogram bin by bin.
Returns:
Reference to the updated Histogram1.
Parameters:
h - Constant Histogram1 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++