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

BinnerAxisLinear Class Reference

#include <BinnerAxisLinear.h>

Inheritance diagram for BinnerAxisLinear:

Inheritance graph
[legend]
Collaboration diagram for BinnerAxisLinear:

Collaboration graph
[legend]
List of all members.

Detailed Description

The class for the constant width bins.

Author:
Matan Shacham <matan@slac.stanford.edu>

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

Definition at line 26 of file BinnerAxisLinear.h.

Public Member Functions

virtual int axisBinNumber (double x) const
 Returns the number of the bin in which the x value is situated.
virtual double axisBinWidth (int i) const
 Returns the width of each bin.
double axisGetHigh () const
 Returns the lower edge of the last + 1 bin.
double axisGetLow () const
 Returns the lower edge of the first bin.
int axisNumberOfBins () const
 Returns the number of bins.
virtual void axisSetNumberOfBins (int nb)
 Sets m_num_bins.
virtual const std::vector<
double > & 
binEdges ()
 Returns the vector of cordinates of the bin edges i.e returns the member m_edges.
 BinnerAxisLinear ()
 The default constructor.
virtual double calcBinWidth (int parm, bool dragging) const
 Calculates the bin width parameter when dragging a slider control.
virtual double calcOffset (int parm, bool dragging) const
 Calculates and returns a double corresponding to a bin offset when dragging a slider control.
BinnerAxisclone ()
 The clone function returns an object of its own kind which is a copy of this object at this moment.
virtual double getBinWidth () const
 Returns the bin width parameter.
virtual double getConstWid () const
 Returns the constant width parameter.
virtual double getCoordinate (int i) const
 Returns the coordinate.
virtual double getOffset () const
 Returns the offset.
const RangegetRange () const
 Returns the range.
virtual bool hasEqualWidths () const
 Returns true.
const std::stringname () const
 Returns the name of this binner.
virtual double scaleFactorWid ()
 Returns the bin width associated with the scale factor - in the case of linear binning, this is the const.
virtual const RangesetBinWidth (double width)
 Sets the bin width and adjusts the range and number of bins accordingly.
virtual void setConstWid ()
 Sets the constant width parameter.
virtual const void setOffset (double offset)
 Sets the offset and adjusts the range accordingly.
virtual const RangesetRange (const Range &, bool hold_width=true)
void setStartRange (bool dragging) const
 Sets the starting Range.
void setStartWidth (bool dragging) const
 Sets the starting width parameter.
virtual ~BinnerAxisLinear ()
 The destructor.

Protected Member Functions

 BinnerAxisLinear (const BinnerAxisLinear &binner)
 The copy constructor.

Protected Attributes

std::vector< double > m_bin_edges
 The coordintes of the edges of bins.
int m_num_bins
 The number of bins.
double m_offset
 The offset.
Range m_range
 The range of the bins.
Range m_range_start
 The Range at the start of dragging.
double m_width
 The width parameter for the binning.
double m_width_start
 The width parameter at the start of dragging.

Static Protected Attributes

static double s_bin_factor = 0.75
 The scale factor used to calculate new bin width from slider.
static int s_num_bins = 50
 The default number of bins.

Private Member Functions

virtual int getNob (const Range &range) const
 Gets the number of bins from range.
virtual int getNob (double wid) const
 Returns the number of bins given the width parameter width.


Constructor & Destructor Documentation

BinnerAxisLinear::BinnerAxisLinear const BinnerAxisLinear binner  )  [protected]
 

The copy constructor.

Todo:
Why is width recaluated instead of being copied.

Definition at line 32 of file BinnerAxisLinear.cxx.

BinnerAxisLinear::BinnerAxisLinear  ) 
 

The default constructor.

Definition at line 25 of file BinnerAxisLinear.cxx.

References Range::length(), BinnerAxis::m_num_bins, BinnerAxis::m_range, and BinnerAxis::m_width.

Referenced by clone().

BinnerAxisLinear::~BinnerAxisLinear  )  [virtual]
 

The destructor.

Definition at line 37 of file BinnerAxisLinear.cxx.


Member Function Documentation

int BinnerAxisLinear::axisBinNumber double  x  )  const [virtual]
 

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

Note:
Dividing by the bin width leads to less roundoff errors then using the fraction of the range and mulitiplying by the number of bins.

Implements BinnerAxis.

Definition at line 65 of file BinnerAxisLinear.cxx.

References axisBinWidth(), Range::low(), BinnerAxis::m_num_bins, BinnerAxis::m_range, std::max(), and std::min().

double BinnerAxisLinear::axisBinWidth int  i  )  const [virtual]
 

Returns the width of each bin.

Implements BinnerAxis.

Definition at line 85 of file BinnerAxisLinear.cxx.

References Range::length(), BinnerAxis::m_num_bins, and BinnerAxis::m_range.

Referenced by axisBinNumber(), getConstWid(), and setConstWid().

double BinnerAxis::axisGetHigh  )  const [inherited]
 

Returns the lower edge of the last + 1 bin.

Definition at line 69 of file BinnerAxis.cxx.

References Range::high(), and BinnerAxis::m_range.

Referenced by Bins1DBase::getHigh().

double BinnerAxis::axisGetLow  )  const [inherited]
 

Returns the lower edge of the first bin.

Definition at line 63 of file BinnerAxis.cxx.

References Range::low(), and BinnerAxis::m_range.

Referenced by Bins2DBase::getLow(), and Bins1DBase::getLow().

int BinnerAxis::axisNumberOfBins  )  const [inherited]
 

Returns the number of bins.

Definition at line 82 of file BinnerAxis.cxx.

References BinnerAxis::m_num_bins.

Referenced by Bins2DBase::numberOfBins(), and Bins1DBase::numberOfBins().

void BinnerAxisLinear::axisSetNumberOfBins int  nb  )  [virtual]
 

Sets m_num_bins.

Implements BinnerAxis.

Definition at line 54 of file BinnerAxisLinear.cxx.

References Range::length(), BinnerAxis::m_num_bins, BinnerAxis::m_range, and BinnerAxis::m_width.

const vector< double > & BinnerAxis::binEdges  )  [virtual, inherited]
 

Returns the vector of cordinates of the bin edges i.e returns the member m_edges.

If m_edges is not set it sets it too

Definition at line 108 of file BinnerAxis.cxx.

References BinnerAxis::axisBinWidth(), Range::high(), Range::low(), BinnerAxis::m_bin_edges, BinnerAxis::m_num_bins, and BinnerAxis::m_range.

double BinnerAxisLinear::calcBinWidth int  parm,
bool  dragging
const [virtual]
 

Calculates the bin width parameter when dragging a slider control.

This member saves the current width parameter when first called with dragging is true. The width is then calculated with the parameter parm whose range is expected to be from 0 to 99. Returns the calculated width parameter, but does not change with current parameter.

Implements BinnerAxis.

Definition at line 107 of file BinnerAxisLinear.cxx.

References BinnerAxis::m_width_start, BinnerAxis::s_bin_factor, and BinnerAxis::setStartWidth().

double BinnerAxisLinear::calcOffset int  parm,
bool  dragging
const [virtual]
 

Calculates and returns a double corresponding to a bin offset when dragging a slider control.

The current range is saved when first called with dragging true. The parm is expected to range from 0 to 50 and offsets are calculated with respect the the bin width parameter.

Implements BinnerAxis.

Definition at line 119 of file BinnerAxisLinear.cxx.

References BinnerAxis::setStartRange().

BinnerAxis * BinnerAxisLinear::clone  )  [virtual]
 

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

Implements BinnerAxis.

Definition at line 42 of file BinnerAxisLinear.cxx.

References BinnerAxisLinear().

double BinnerAxisLinear::getBinWidth  )  const [virtual]
 

Returns the bin width parameter.

If the bin widths are not equal, then return a parameter used to calculate the bin widths.

Implements BinnerAxis.

Definition at line 182 of file BinnerAxisLinear.cxx.

References getConstWid().

double BinnerAxisLinear::getConstWid  )  const [virtual]
 

Returns the constant width parameter.

Implements BinnerAxis.

Definition at line 171 of file BinnerAxisLinear.cxx.

References axisBinWidth().

Referenced by getBinWidth(), getNob(), and scaleFactorWid().

double BinnerAxisLinear::getCoordinate int  i  )  const [virtual]
 

Returns the coordinate.

Returns the coordinate of the bin at index i. The coordinate is midway between the bin edges.

Implements BinnerAxis.

Definition at line 79 of file BinnerAxisLinear.cxx.

References Range::length(), Range::low(), BinnerAxis::m_num_bins, and BinnerAxis::m_range.

int BinnerAxisLinear::getNob const Range range  )  const [private, virtual]
 

Gets the number of bins from range.

Implements BinnerAxis.

Definition at line 199 of file BinnerAxisLinear.cxx.

References getConstWid(), and Range::length().

int BinnerAxisLinear::getNob double  wid  )  const [private, virtual]
 

Returns the number of bins given the width parameter width.

Implements BinnerAxis.

Definition at line 213 of file BinnerAxisLinear.cxx.

References BinnerAxis::m_range, and Range::numberOfBins().

Referenced by setBinWidth().

double BinnerAxisLinear::getOffset  )  const [virtual]
 

Returns the offset.

Implements BinnerAxis.

Definition at line 127 of file BinnerAxisLinear.cxx.

References BinnerAxis::m_offset.

const Range & BinnerAxis::getRange  )  const [inherited]
 

Returns the range.

Definition at line 76 of file BinnerAxis.cxx.

References BinnerAxis::m_range.

Referenced by Bins2DBase::getRange(), Bins1DBase::getRange(), and BinnerAxisXML::setAttributes().

bool BinnerAxisLinear::hasEqualWidths  )  const [virtual]
 

Returns true.

This derived class is a special case in that it has bins of all the same width.

See also:
BinnerAxis::hasEqualWidths.

Reimplemented from BinnerAxis.

Definition at line 48 of file BinnerAxisLinear.cxx.

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

Returns the name of this binner.

Definition at line 51 of file BinnerAxis.cxx.

References BinnerAxis::m_name.

Referenced by BinnerAxisXML::setAttributes().

double BinnerAxisLinear::scaleFactorWid  )  [virtual]
 

Returns the bin width associated with the scale factor - in the case of linear binning, this is the const.

bin width

Implements BinnerAxis.

Definition at line 194 of file BinnerAxisLinear.cxx.

References getConstWid().

const Range & BinnerAxisLinear::setBinWidth double  width  )  [virtual]
 

Sets the bin width and adjusts the range and number of bins accordingly.

Returns the adjusted range.

Implements BinnerAxis.

Definition at line 93 of file BinnerAxisLinear.cxx.

References getNob(), BinnerAxis::m_num_bins, BinnerAxis::m_range, BinnerAxis::m_width, and Range::setLength().

void BinnerAxisLinear::setConstWid  )  [virtual]
 

Sets the constant width parameter.

Definition at line 188 of file BinnerAxisLinear.cxx.

References axisBinWidth(), and BinnerAxis::m_width.

const void BinnerAxisLinear::setOffset double  offset  )  [virtual]
 

Sets the offset and adjusts the range accordingly.

Implements BinnerAxis.

Definition at line 133 of file BinnerAxisLinear.cxx.

References Range::high(), Range::low(), BinnerAxis::m_offset, BinnerAxis::m_range, and BinnerAxis::m_width.

const Range & BinnerAxisLinear::setRange const Range range,
bool  hold_width = true
[virtual]
 

Todo:
Had to put std:: in here for Sun's CC, but not in AxisModelxxx.
So there must be a better fix.

Implements BinnerAxis.

Definition at line 150 of file BinnerAxisLinear.cxx.

References Range::length(), BinnerAxis::m_num_bins, BinnerAxis::m_range, BinnerAxis::m_width, and Range::setLength().

void BinnerAxis::setStartRange bool  dragging  )  const [inherited]
 

Sets the starting Range.

Definition at line 88 of file BinnerAxis.cxx.

References BinnerAxis::m_dragging, BinnerAxis::m_range, and BinnerAxis::m_range_start.

Referenced by BinnerAxisLog::calcOffset(), and calcOffset().

void BinnerAxis::setStartWidth bool  dragging  )  const [inherited]
 

Sets the starting width parameter.

Definition at line 98 of file BinnerAxis.cxx.

References BinnerAxis::m_dragging, BinnerAxis::m_width, and BinnerAxis::m_width_start.

Referenced by BinnerAxisLog::calcBinWidth(), and calcBinWidth().


Member Data Documentation

std::vector< double > BinnerAxis::m_bin_edges [protected, inherited]
 

The coordintes of the edges of bins.

Since there are m_num_bins this is a vector of size 1 + m_num_bins. A size zero indicates that no value has been set yet.

Definition at line 78 of file BinnerAxis.h.

Referenced by BinnerAxis::binEdges().

int BinnerAxis::m_num_bins [protected, inherited]
 

The number of bins.

Definition at line 62 of file BinnerAxis.h.

Referenced by BinnerAxisLog::axisBinNumber(), axisBinNumber(), BinnerAxisLog::axisBinWidth(), axisBinWidth(), BinnerAxis::axisNumberOfBins(), BinnerAxisLog::axisSetNumberOfBins(), axisSetNumberOfBins(), BinnerAxis::binEdges(), BinnerAxisLinear(), BinnerAxisLog::getCoordinate(), getCoordinate(), BinnerAxisLog::setBinWidth(), setBinWidth(), BinnerAxisLog::setConstWid(), BinnerAxisLog::setRange(), and setRange().

double BinnerAxis::m_offset [protected, inherited]
 

The offset.

Definition at line 69 of file BinnerAxis.h.

Referenced by BinnerAxisLog::getOffset(), getOffset(), BinnerAxisLog::setOffset(), and setOffset().

Range BinnerAxis::m_range [protected, inherited]
 

The range of the bins.

The lower edge of the first bin and the upper edge of the last bin are represented by this range.

Definition at line 66 of file BinnerAxis.h.

Referenced by axisBinNumber(), axisBinWidth(), BinnerAxis::axisGetHigh(), BinnerAxis::axisGetLow(), axisSetNumberOfBins(), BinnerAxis::binEdges(), BinnerAxisLinear(), BinnerAxisLog::calcWidthParm(), getCoordinate(), BinnerAxisLog::getNob(), getNob(), BinnerAxis::getRange(), BinnerAxisLog::setBins(), BinnerAxisLog::setBinWidth(), setBinWidth(), setOffset(), BinnerAxisLog::setRange(), setRange(), and BinnerAxis::setStartRange().

Range BinnerAxis::m_range_start [mutable, protected, inherited]
 

The Range at the start of dragging.

Definition at line 81 of file BinnerAxis.h.

Referenced by BinnerAxisLog::setOffset(), and BinnerAxis::setStartRange().

double BinnerAxis::m_width [protected, inherited]
 

The width parameter for the binning.

A negative number indicates that no value has been set yet.

Definition at line 73 of file BinnerAxis.h.

Referenced by axisSetNumberOfBins(), BinnerAxisLinear(), BinnerAxisLog::getBinWidth(), BinnerAxisLog::getConstWid(), BinnerAxisLog::getNob(), BinnerAxisLog::setBins(), BinnerAxisLog::setBinWidth(), setBinWidth(), BinnerAxisLog::setConstWid(), setConstWid(), BinnerAxisLog::setOffset(), setOffset(), BinnerAxisLog::setRange(), setRange(), and BinnerAxis::setStartWidth().

double BinnerAxis::m_width_start [mutable, protected, inherited]
 

The width parameter at the start of dragging.

Definition at line 84 of file BinnerAxis.h.

Referenced by BinnerAxisLog::calcBinWidth(), calcBinWidth(), and BinnerAxis::setStartWidth().

double BinnerAxis::s_bin_factor = 0.75 [static, protected, inherited]
 

The scale factor used to calculate new bin width from slider.

Definition at line 23 of file BinnerAxis.cxx.

Referenced by BinnerAxisLog::calcBinWidth(), and calcBinWidth().

int BinnerAxis::s_num_bins = 50 [static, protected, inherited]
 

The default number of bins.

The default number of bins used by the default constructor.

Definition at line 22 of file BinnerAxis.cxx.


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