Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Bins1DHist Class Reference

#include <Bins1DHist.h>

Inheritance diagram for Bins1DHist:

Inheritance graph
[legend]
Collaboration diagram for Bins1DHist:

Collaboration graph
[legend]
List of all members.

Detailed Description

The class for the one-dimensional histogram binning.

Requests:
Should use BinnerAxis::getCoordinate() and have asymmetric errors.

Author:
Stephane Bonneaud <gandalf@slac.stanford.edu>

Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Matan Shacham <matan@slac.stanford.edu>

Oded Wurman <owurman@stanford.edu>

Definition at line 35 of file Bins1DHist.h.

Public Member Functions

virtual void accumulate (double x, double w=1.0, double i1=0.0, double i2=0.0)
 Accumulates a data point xinto a bin with weight w.
int binNumber (double x)
 Returns the number of the bin in which the x value is situated.
 Bins1DHist (const Bins1DHist &binner)
 The copy constructor.
 Bins1DHist ()
 The default constructor.
virtual double binWidth (hippodraw::Axes::Type axis) const
 Returns the bin width parameter on the specified axis.
double binWidth (int i) const
 Returns the width of each bin.
double calcBinWidth (const std::string &axis, int parm, bool dragging) const
 Calculates the bin width from dragging slider.
virtual double calcOffset (const std::string &, int parm, bool dragging) const
 Calculates and returns a new range from dragging slider.
BinsBaseclone () const
 The clone function returns an object of its own kind which is a copy of this object at this moment.
virtual NTuplecreateNTuple () const
 Creates a NTuple.
virtual void fillDataSource (DataSource *ntuple) const
 Fills the DataSource.
virtual const BinnerAxisgetBinnerOn (hippodraw::Axes::Type axis) const
 Returns the BinnerAxis object used by this object.
double getHigh () const
 Returns the lower edge of the last + 1 bin through binner_axis.
virtual int getNumberOfAxes () const
 Returns the number of axes handled by the BinsBase derived class.
virtual int getNumberOfEntries (int i) const
 implementation from pure base
virtual int getNumberOfEntries () const
 implementation from pure base
virtual double getOffset (hippodraw::Axes::Type axis) const
 Returns the offset parameter on specific axis.
virtual const RangegetRange (hippodraw::Axes::Type axis)
 Returns range from binner axis.
virtual double getZValue (double x, double y) const
 Get the z value at the specified point (x,y).
virtual bool hasEqualWidths () const
 Returns true if all bins have the same width.
bool isDirty ()
 Returns true if the re-accumulation is needed.
bool isEmpty () const
 Returns true if no accumulation has yet occurred, otherwise returns false.
double maxBin ()
 Returns the value of the bin with the largest value.
double minBin ()
 Returns the value of the bin with the smallest value.
const std::stringname () const
 Returns the name of the Bins container object.
virtual int numberOfBins (hippodraw::Axes::Type axis) const
 Returns the number of bins on specified axis.
virtual void reset ()
 Resets the accumulation to zero.
virtual double scaleFactor () const
 Returns the scale factor.
virtual void scaleNumberOfEntries (double number)
 Sets a scale factor on the output so that the number of entries appears to be number.
virtual void setBinContents (const DataSource *ntuple)
virtual void setBinnerOn (BinnerAxis *, hippodraw::Axes::Type axis)
 Sets a new BinnerAxis for the binner to use.
virtual const RangesetBinWidth (hippodraw::Axes::Type axis, double value)
 Sets the bin width parameter on the specified axis.
void setDirty ()
 Sets a flag to indicate that re-binning needs to be done.
virtual void setEntriesScaling (bool on)
 Sets the scaling number of entries on if on is true, otherwise turns if off.
virtual void setNumberOfBins (hippodraw::Axes::Type axis, int num_bins)
 Sets the number of bins on the the specified axis.
virtual void setOffset (hippodraw::Axes::Type axis, double value)
 Sets the offset parameter on the specified axis.
virtual const RangesetRange (hippodraw::Axes::Type axis, const Range &, bool hold_width=true)
 Sets the Range on the specified axis.
virtual ~Bins1DHist ()
 The destructor.

Protected Member Functions

virtual double getLow (hippodraw::Axes::Type axis) const
 Returns the low value of the bins on the specified axis.
virtual NTupleprepareNTuple (unsigned int rows) const
 Prepares the NTuple.

Protected Attributes

BinnerAxisbinner_axis
 The binner axis object.
bool m_empty
 A flag set to true, when no accumulation has yet occurred, otherwise is set false.
bool m_is_scaling
 A flag which is set true to enable scaling the output.
double m_scale_factor
 The scale factor.
bool m_values_dirty
 A flag to indicate that the objects in m_values are not correct.

Private Member Functions

virtual void fillProjectedValues (DataSource *ntuple) const
 Fills the NTuple.
virtual void resize (int size)
 Resizes the internal arrays.

Private Attributes

std::vector< double > m_data
 The array of binned data.
double m_moments [3]
 The moments.
std::vector< double > m_variance
 The accumulated square of the weights.


Constructor & Destructor Documentation

Bins1DHist::Bins1DHist  ) 
 

The default constructor.

Definition at line 43 of file Bins1DHist.cxx.

Referenced by clone().

Bins1DHist::Bins1DHist const Bins1DHist binner  ) 
 

The copy constructor.

Definition at line 48 of file Bins1DHist.cxx.

References m_moments.

Bins1DHist::~Bins1DHist  )  [virtual]
 

The destructor.

Definition at line 62 of file Bins1DHist.cxx.


Member Function Documentation

void Bins1DHist::accumulate double  x,
double  w = 1.0,
double  i1 = 0.0,
double  i2 = 0.0
[virtual]
 

Accumulates a data point xinto a bin with weight w.

The remaining arguments are ignored.

Implements BinsBase.

Definition at line 109 of file Bins1DHist.cxx.

References Bins1DBase::binNumber(), m_data, BinsBase::m_empty, m_moments, and m_variance.

int Bins1DBase::binNumber double  x  )  [inline, inherited]
 

Returns the number of the bin in which the x value is situated.

Definition at line 140 of file Bins1DBase.h.

References BinnerAxis::axisBinNumber(), and Bins1DBase::binner_axis.

Referenced by Bins1DProfile::accumulate(), and accumulate().

double Bins1DBase::binWidth hippodraw::Axes::Type  axis  )  const [virtual, inherited]
 

Returns the bin width parameter on the specified axis.

If the bins have all the same width, then returns the bin width. If the bin width are determined by some algorithm, then returns a parameter used to calculate the bin widths.

Implements BinsBase.

Definition at line 133 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, BinnerAxis::getConstWid(), and hippodraw::Axes::X.

double Bins1DBase::binWidth int  i  )  const [inherited]
 

Returns the width of each bin.

Returns the width of the bin with index i. The first bin has index 0 and the last bin has index of number of bins minus 1.

Definition at line 120 of file Bins1DBase.cxx.

References BinnerAxis::axisBinWidth(), and Bins1DBase::binner_axis.

Referenced by Bins1DProfile::fillDataSource(), fillDataSource(), Bins1DProfile::fillProjectedValues(), and fillProjectedValues().

double Bins1DBase::calcBinWidth const std::string axis,
int  parm,
bool  dragging
const [virtual, inherited]
 

Calculates the bin width from dragging slider.

Implements BinsBase.

Definition at line 153 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, and BinnerAxis::calcBinWidth().

double Bins1DBase::calcOffset const std::string ,
int  parm,
bool  dragging
const [virtual, inherited]
 

Calculates and returns a new range from dragging slider.

Implements BinsBase.

Definition at line 166 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, and BinnerAxis::calcOffset().

BinsBase * Bins1DHist::clone  )  const [virtual]
 

The clone function returns an object of its own kind which is a copy of this object at this moment.

Implements BinsBase.

Definition at line 57 of file Bins1DHist.cxx.

References Bins1DHist().

NTuple * Bins1DHist::createNTuple  )  const [virtual]
 

Creates a NTuple.

Creates and returns an NTuple based on the contents of the bins. The receiver takes possession of the NTuple object. The columns in the NTuple are in order: X position, value, X width, and error on value.

Implements BinsBase.

Definition at line 125 of file Bins1DHist.cxx.

References fillProjectedValues(), m_data, Bins1DBase::prepareNTuple(), and num_util::size().

void Bins1DHist::fillDataSource DataSource ntuple  )  const [virtual]
 

Fills the DataSource.

Clears and fills the DataSource based on the contents of the bins. The resulting DataSource is follows the standard defined in hippodraw::DataPoint2DTuple or hippodraw::DataPoint3DTuple.

Implements BinsBase.

Definition at line 175 of file Bins1DHist.cxx.

References std::accumulate(), Bins1DBase::binWidth(), Bins1DBase::getLow(), m_data, BinsBase::m_is_scaling, BinsBase::m_scale_factor, m_variance, hippodraw::DataPoint2DTuple::SIZE, std::sqrt(), hippodraw::Axes::X, hippodraw::DataPoint2DTuple::XERR, hippodraw::Axes::Y, and hippodraw::DataPoint2DTuple::YERR.

void Bins1DHist::fillProjectedValues DataSource ntuple  )  const [private, virtual]
 

Fills the NTuple.

Clears and fills the ntuple from the contents of the bins.

Implements BinsBase.

Definition at line 139 of file Bins1DHist.cxx.

References std::accumulate(), Bins1DBase::binWidth(), Bins1DBase::getLow(), m_data, BinsBase::m_is_scaling, BinsBase::m_scale_factor, m_variance, hippodraw::DataPoint2DTuple::SIZE, std::sqrt(), hippodraw::Axes::X, hippodraw::DataPoint2DTuple::XERR, hippodraw::Axes::Y, and hippodraw::DataPoint2DTuple::YERR.

Referenced by createNTuple().

const BinnerAxis * Bins1DBase::getBinnerOn hippodraw::Axes::Type  axis  )  const [virtual, inherited]
 

Returns the BinnerAxis object used by this object.

Implements BinsBase.

Definition at line 65 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, and hippodraw::Axes::X.

double Bins1DBase::getHigh  )  const [inherited]
 

Returns the lower edge of the last + 1 bin through binner_axis.

Definition at line 92 of file Bins1DBase.cxx.

References BinnerAxis::axisGetHigh(), and Bins1DBase::binner_axis.

double Bins1DBase::getLow hippodraw::Axes::Type  axis  )  const [protected, virtual, inherited]
 

Returns the low value of the bins on the specified axis.

Implements BinsBase.

Definition at line 85 of file Bins1DBase.cxx.

References BinnerAxis::axisGetLow(), Bins1DBase::binner_axis, and hippodraw::Axes::X.

Referenced by Bins1DProfile::fillDataSource(), fillDataSource(), Bins1DProfile::fillProjectedValues(), and fillProjectedValues().

int Bins1DBase::getNumberOfAxes  )  const [virtual, inherited]
 

Returns the number of axes handled by the BinsBase derived class.

Implements BinsBase.

Definition at line 59 of file Bins1DBase.cxx.

int Bins1DHist::getNumberOfEntries int  i  )  const [virtual]
 

implementation from pure base

Implements Bins1DBase.

Definition at line 102 of file Bins1DHist.cxx.

References m_data.

int Bins1DHist::getNumberOfEntries  )  const [virtual]
 

implementation from pure base

Implements BinsBase.

Definition at line 96 of file Bins1DHist.cxx.

References std::accumulate(), and m_data.

double Bins1DBase::getOffset hippodraw::Axes::Type  axis  )  const [virtual, inherited]
 

Returns the offset parameter on specific axis.

Implements BinsBase.

Definition at line 177 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, BinnerAxis::getOffset(), and hippodraw::Axes::X.

const Range & Bins1DBase::getRange hippodraw::Axes::Type  axis  )  [virtual, inherited]
 

Returns range from binner axis.

Implements BinsBase.

Definition at line 209 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, BinnerAxis::getRange(), and hippodraw::Axes::X.

double BinsBase::getZValue double  x,
double  y
const [virtual, inherited]
 

Get the z value at the specified point (x,y).

Reimplemented in Bins2DHist, and Bins2DProfile.

Definition at line 72 of file BinsBase.cxx.

Referenced by BinningProjector::getZValue().

bool Bins1DBase::hasEqualWidths  )  const [virtual, inherited]
 

Returns true if all bins have the same width.

See also:
BinnerAxis::hasEqualWidths.

Implements BinsBase.

Definition at line 114 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, and BinnerAxis::hasEqualWidths().

bool BinsBase::isDirty  )  [inherited]
 

Returns true if the re-accumulation is needed.

Definition at line 57 of file BinsBase.cxx.

References BinsBase::m_values_dirty.

bool BinsBase::isEmpty  )  const [inherited]
 

Returns true if no accumulation has yet occurred, otherwise returns false.

Definition at line 79 of file BinsBase.cxx.

References BinsBase::m_empty.

double Bins1DHist::maxBin  ) 
 

Returns the value of the bin with the largest value.

Definition at line 81 of file Bins1DHist.cxx.

References m_data, and std::max_element().

double Bins1DHist::minBin  ) 
 

Returns the value of the bin with the smallest value.

Definition at line 76 of file Bins1DHist.cxx.

References m_data, and std::min_element().

const string & BinsBase::name  )  const [inherited]
 

Returns the name of the Bins container object.

Definition at line 52 of file BinsBase.cxx.

References BinsBase::m_name.

Referenced by BinsBaseXML::createElement().

int Bins1DBase::numberOfBins hippodraw::Axes::Type  axis  )  const [virtual, inherited]
 

Returns the number of bins on specified axis.

If a BinnerAxis object does not exist, returns 0.

Implements BinsBase.

Definition at line 97 of file Bins1DBase.cxx.

References BinnerAxis::axisNumberOfBins(), Bins1DBase::binner_axis, and hippodraw::Axes::X.

Referenced by Bins1DProfile::fillDataSource(), Bins1DProfile::fillProjectedValues(), and Bins1DBase::resize().

NTuple * Bins1DBase::prepareNTuple unsigned int  rows  )  const [protected, virtual, inherited]
 

Prepares the NTuple.

Creates and returns the NTuple that will be filled from the binner's values. The NTuple will have rows rows and 4 columns.

Implements BinsBase.

Definition at line 226 of file Bins1DBase.cxx.

References hippodraw::DataPoint2DTuple::ERROR, NTuple::setLabels(), and hippodraw::DataPoint2DTuple::WIDTH.

Referenced by Bins1DProfile::createNTuple(), and createNTuple().

void Bins1DHist::reset  )  [virtual]
 

Resets the accumulation to zero.

Implements BinsBase.

Definition at line 86 of file Bins1DHist.cxx.

References std::fill(), m_data, BinsBase::m_empty, m_moments, BinsBase::m_values_dirty, and m_variance.

Referenced by resize().

void Bins1DHist::resize int  size  )  [private, virtual]
 

Resizes the internal arrays.

Implements Bins1DBase.

Definition at line 67 of file Bins1DHist.cxx.

References m_data, BinsBase::m_values_dirty, m_variance, and reset().

double Bins1DBase::scaleFactor  )  const [virtual, inherited]
 

Returns the scale factor.

Used to convert the projected values to number of entries in a bin.

Reimplemented from BinsBase.

Definition at line 127 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, and BinnerAxis::scaleFactorWid().

void BinsBase::scaleNumberOfEntries double  number  )  [virtual, inherited]
 

Sets a scale factor on the output so that the number of entries appears to be number.

This feature might be used, for example, to compare two histograms that have different number of entires by normalizing one to the other.

Definition at line 86 of file BinsBase.cxx.

References BinsBase::m_scale_factor.

void Bins1DHist::setBinContents const DataSource ntuple  )  [virtual]
 

Todo:
The underflow and overflow bins do not get archived, thus don't get restored.
Also the moments.

Implements BinsBase.

Definition at line 214 of file Bins1DHist.cxx.

References m_data, m_variance, num_util::size(), hippodraw::DataPoint2DTuple::XERR, hippodraw::Axes::Y, and hippodraw::DataPoint2DTuple::YERR.

void Bins1DBase::setBinnerOn BinnerAxis ,
hippodraw::Axes::Type  axis
[virtual, inherited]
 

Sets a new BinnerAxis for the binner to use.

The old one, if any, will be destroyed.

Implements BinsBase.

Definition at line 72 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, BinsBase::m_values_dirty, Bins1DBase::resize(), and hippodraw::Axes::X.

const Range & Bins1DBase::setBinWidth hippodraw::Axes::Type  axis,
double  value
[virtual, inherited]
 

Sets the bin width parameter on the specified axis.

Implements BinsBase.

Definition at line 141 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, Bins1DBase::resize(), BinnerAxis::setBinWidth(), and hippodraw::Axes::X.

void BinsBase::setDirty  )  [inherited]
 

Sets a flag to indicate that re-binning needs to be done.

Definition at line 62 of file BinsBase.cxx.

References BinsBase::m_values_dirty.

Referenced by ProfileProjector::changedNTuple(), Profile2DProjector::changedNTuple(), DyHist2DProjector::changedNTuple(), and DyHist1DProjector::changedNTuple().

void BinsBase::setEntriesScaling bool  on  )  [virtual, inherited]
 

Sets the scaling number of entries on if on is true, otherwise turns if off.

Definition at line 93 of file BinsBase.cxx.

References BinsBase::m_is_scaling.

void Bins1DBase::setNumberOfBins hippodraw::Axes::Type  axis,
int  num_bins
[virtual, inherited]
 

Sets the number of bins on the the specified axis.

Implements BinsBase.

Definition at line 104 of file Bins1DBase.cxx.

References BinnerAxis::axisSetNumberOfBins(), Bins1DBase::binner_axis, Bins1DBase::resize(), and hippodraw::Axes::X.

void Bins1DBase::setOffset hippodraw::Axes::Type  axis,
double  value
[virtual, inherited]
 

Sets the offset parameter on the specified axis.

Implements BinsBase.

Definition at line 186 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, BinnerAxis::setOffset(), and hippodraw::Axes::X.

const Range & Bins1DBase::setRange hippodraw::Axes::Type  axis,
const Range ,
bool  hold_width = true
[virtual, inherited]
 

Sets the Range on the specified axis.

If hold_width is true, the bin width parameter will be held constant, otherwise it is adjusted to keep the same number of bins for the new range.

Implements BinsBase.

Definition at line 196 of file Bins1DBase.cxx.

References Bins1DBase::binner_axis, Bins1DBase::resize(), BinnerAxis::setRange(), and hippodraw::Axes::X.


Member Data Documentation

BinnerAxis* Bins1DBase::binner_axis [protected, inherited]
 

The binner axis object.

Definition at line 44 of file Bins1DBase.h.

Referenced by Bins1DBase::binNumber(), Bins1DBase::Bins1DBase(), Bins1DBase::binWidth(), Bins1DBase::calcBinWidth(), Bins1DBase::calcOffset(), Bins1DBase::getBinnerOn(), Bins1DBase::getHigh(), Bins1DBase::getLow(), Bins1DBase::getOffset(), Bins1DBase::getRange(), Bins1DBase::hasEqualWidths(), Bins1DBase::numberOfBins(), Bins1DBase::scaleFactor(), Bins1DBase::setBinnerOn(), Bins1DBase::setBinWidth(), Bins1DBase::setNumberOfBins(), Bins1DBase::setOffset(), Bins1DBase::setRange(), and Bins1DBase::~Bins1DBase().

std::vector< double > Bins1DHist::m_data [private]
 

The array of binned data.

The range of the index is 1 to m_num_bins.( 0 refers to underflow while m_num_bins + 1 refers to overflow )

Definition at line 42 of file Bins1DHist.h.

Referenced by accumulate(), createNTuple(), fillDataSource(), fillProjectedValues(), getNumberOfEntries(), maxBin(), minBin(), reset(), resize(), and setBinContents().

bool BinsBase::m_empty [protected, inherited]
 

A flag set to true, when no accumulation has yet occurred, otherwise is set false.

Definition at line 57 of file BinsBase.h.

Referenced by Bins2DProfile::accumulate(), Bins2DHist::accumulate(), Bins1DProfile::accumulate(), accumulate(), BinsBase::isEmpty(), Bins2DProfile::reset(), Bins2DHist::reset(), Bins1DProfile::reset(), and reset().

bool BinsBase::m_is_scaling [protected, inherited]
 

A flag which is set true to enable scaling the output.

Definition at line 49 of file BinsBase.h.

Referenced by Bins2DHist::fillDataSource(), fillDataSource(), Bins2DHist::fillProjectedValues(), fillProjectedValues(), and BinsBase::setEntriesScaling().

double Bins1DHist::m_moments[3] [private]
 

The moments.

Definition at line 48 of file Bins1DHist.h.

Referenced by accumulate(), Bins1DHist(), and reset().

double BinsBase::m_scale_factor [protected, inherited]
 

The scale factor.

This data member is used to scale the output so that the total number of entries has this value.

Definition at line 45 of file BinsBase.h.

Referenced by Bins2DHist::fillDataSource(), fillDataSource(), Bins2DHist::fillProjectedValues(), fillProjectedValues(), and BinsBase::scaleNumberOfEntries().

bool BinsBase::m_values_dirty [mutable, protected, inherited]
 

A flag to indicate that the objects in m_values are not correct.

Definition at line 52 of file BinsBase.h.

Referenced by Bins1DBase::Bins1DBase(), Bins2DBase::Bins2DBase(), BinsBase::isDirty(), reset(), Bins2DBase::resize(), Bins1DProfile::resize(), resize(), Bins2DBase::setBinnerOn(), Bins1DBase::setBinnerOn(), Bins2DBase::setBinWidth(), BinsBase::setDirty(), and Bins2DBase::setOffset().

std::vector< double > Bins1DHist::m_variance [private]
 

The accumulated square of the weights.

Definition at line 45 of file Bins1DHist.h.

Referenced by accumulate(), fillDataSource(), fillProjectedValues(), reset(), resize(), and setBinContents().


The documentation for this class was generated from the following files:
Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3