BinnerAxisLog Class Reference

#include <BinnerAxisLog.h>

Inheritance diagram for BinnerAxisLog:

Inheritance graph
BinnerAxis
[legend]
Collaboration diagram for BinnerAxisLog:

Collaboration graph
BinnerAxisRange
[legend]

List of all members.


Detailed Description

The class for bins of logarithmically increasing widths.

Bug:
Resolve this issue. Is plotting the log(x) on linear scale the same as binning x on log scale?
Author:
Matan Shacham <matan@slac.stanford.edu>

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

Oded Wurman <owurman@stanford.edu>

Definition at line 32 of file BinnerAxisLog.h.


Public Member Functions

virtual int axisBinNumber (double x) const
 Returns the number of the bin in which the x value and y value are situated.
virtual double axisBinWidth (int bins_number) const
 Returns the width of the bin designated by its place number in the bins structure.
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 coordinates of the bin edges i.e returns the member m_edges.
 BinnerAxisLog ()
 The default constructor.
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 if all the bins have the same width.
const std::string & name () const
 Returns the name of this binner.
virtual double scaleFactorWid ()
 Returns the bin width associated with the scale factor - in the case of log binning, this is always 1.0.
virtual const RangesetBinWidth (double width)
 Sets the bin width and adjusts the range and number of bins accordingly.
virtual const void setOffset (double offset)
 Sets the offset and adjusts the range accordingly.
virtual const RangesetRange (const Range &, bool hold_width=true)
 Sets the range.
void setStartRange (bool dragging) const
 Sets the starting Range.
void setStartWidth (bool dragging) const
 Sets the starting width parameter.
virtual ~BinnerAxisLog ()
 The destructor.

Protected Attributes

std::vector< double > m_bin_edges
 The coordinates 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

 BinnerAxisLog (const BinnerAxisLog &binner)
 The copy constructor.
double calcWidthParm (int number) const
 Calculates the bin width parameter given the number of bins.
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.
void setBins ()
 Sets the bins structure by calculating the lower edge of each bin.
virtual void setConstWid ()
 Sets the constant width parameter.

Private Attributes

std::vector< double > bins
 Has the lower edge of each bin, starting with [0] = the first one.

Constructor & Destructor Documentation

BinnerAxisLog ( const BinnerAxisLog binner  )  [private]

The copy constructor.

Definition at line 42 of file BinnerAxisLog.cxx.

BinnerAxisLog (  ) 

The default constructor.

Definition at line 37 of file BinnerAxisLog.cxx.

Referenced by BinnerAxisLog::clone().

~BinnerAxisLog (  )  [virtual]

The destructor.

Definition at line 48 of file BinnerAxisLog.cxx.


Member Function Documentation

int axisBinNumber ( double  x  )  const [virtual]

Returns the number of the bin in which the x value and y value are situated.

Implements BinnerAxis.

Definition at line 65 of file BinnerAxisLog.cxx.

References BinnerAxisLog::bins, and BinnerAxis::m_num_bins.

double axisBinWidth ( int  bins_number  )  const [virtual]

Returns the width of the bin designated by its place number in the bins structure.

Implements BinnerAxis.

Definition at line 89 of file BinnerAxisLog.cxx.

References BinnerAxisLog::bins, and BinnerAxis::m_num_bins.

double axisGetHigh (  )  const [inherited]

Returns the lower edge of the last + 1 bin.

Definition at line 71 of file BinnerAxis.cxx.

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

Referenced by Bins1DBase::getHigh().

double axisGetLow (  )  const [inherited]

Returns the lower edge of the first bin.

Definition at line 65 of file BinnerAxis.cxx.

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

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

int axisNumberOfBins (  )  const [inherited]

Returns the number of bins.

Definition at line 84 of file BinnerAxis.cxx.

References BinnerAxis::m_num_bins.

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

void axisSetNumberOfBins ( int  nb  )  [virtual]

Sets m_num_bins.

Implements BinnerAxis.

Definition at line 59 of file BinnerAxisLog.cxx.

References BinnerAxis::m_num_bins.

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

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

If m_edges is not set it sets it too

Definition at line 110 of file BinnerAxis.cxx.

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

double calcBinWidth ( int  parm,
bool  dragging 
) const [inherited]

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.

Definition at line 130 of file BinnerAxis.cxx.

References BinnerAxis::calcWidthParm(), BinnerAxis::getNob(), BinnerAxis::m_num_bins, BinnerAxis::m_width_start, and BinnerAxis::setStartWidth().

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

double 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 197 of file BinnerAxisLog.cxx.

References BinnerAxis::setStartRange().

double calcWidthParm ( int  number  )  const [private, virtual]

Calculates the bin width parameter given the number of bins.

Implements BinnerAxis.

Definition at line 121 of file BinnerAxisLog.cxx.

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

Referenced by BinnerAxisLog::setConstWid(), and BinnerAxisLog::setRange().

BinnerAxis * 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 53 of file BinnerAxisLog.cxx.

References BinnerAxisLog::BinnerAxisLog().

double 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 109 of file BinnerAxisLog.cxx.

References BinnerAxis::m_width.

double getConstWid (  )  const [virtual]

Returns the constant width parameter.

Implements BinnerAxis.

Definition at line 102 of file BinnerAxisLog.cxx.

References BinnerAxis::m_width.

double getCoordinate ( int  i  )  const [virtual]

Returns the coordinate.

Returns the coordinate of the bin at index i. The coordinate of the bin is not the center of the bin. The calculation is such that doing a chi-square fit to power-law on log-log scale is correct. Also plotting individual points is correct.

Implements BinnerAxis.

Definition at line 78 of file BinnerAxisLog.cxx.

References BinnerAxisLog::bins, and BinnerAxis::m_num_bins.

int getNob ( const Range range  )  const [private, virtual]

Gets the number of bins from range.

Implements BinnerAxis.

Definition at line 236 of file BinnerAxisLog.cxx.

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

int getNob ( double  width  )  const [private, virtual]

Returns the number of bins given the width parameter width.

Implements BinnerAxis.

Definition at line 246 of file BinnerAxisLog.cxx.

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

Referenced by BinnerAxisLog::setBinWidth(), and BinnerAxisLog::setRange().

double getOffset (  )  const [virtual]

Returns the offset.

Todo:
Maybe be able to remove this function and other getOffset functions.

Implements BinnerAxis.

Definition at line 207 of file BinnerAxisLog.cxx.

References BinnerAxis::m_offset.

const Range & getRange (  )  const [inherited]

Returns the range.

Definition at line 78 of file BinnerAxis.cxx.

References BinnerAxis::m_range.

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

bool hasEqualWidths (  )  const [virtual, inherited]

Returns true if all the bins have the same width.

The implementation in this base class is to return false. In the special case where all bins have equal widths, this function should be overridden in a derived class. The intent is to allow classes that use such special case to display an alternate label for an axis, such as Entries per bin.

Reimplemented in BinnerAxisLinear.

Definition at line 59 of file BinnerAxis.cxx.

Referenced by Bins2DBase::hasEqualWidths(), Bins1DBase::hasEqualWidths(), and Bins2DBase::scaleFactor().

const string & name (  )  const [inherited]

Returns the name of this binner.

Definition at line 53 of file BinnerAxis.cxx.

References BinnerAxis::m_name.

Referenced by BinnerAxisXML::setAttributes().

double scaleFactorWid (  )  [virtual]

Returns the bin width associated with the scale factor - in the case of log binning, this is always 1.0.

Implements BinnerAxis.

Definition at line 231 of file BinnerAxisLog.cxx.

void setBins (  )  [private]

Sets the bins structure by calculating the lower edge of each bin.

Definition at line 132 of file BinnerAxisLog.cxx.

References BinnerAxisLog::bins, Range::low(), BinnerAxis::m_range, and BinnerAxis::m_width.

Referenced by BinnerAxisLog::setBinWidth(), and BinnerAxisLog::setRange().

const Range & 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 180 of file BinnerAxisLog.cxx.

References BinnerAxisLog::bins, BinnerAxisLog::getNob(), Range::low(), BinnerAxis::m_num_bins, BinnerAxis::m_range, BinnerAxis::m_width, BinnerAxisLog::setBins(), and Range::setHigh().

void setConstWid (  )  [private, virtual]

Sets the constant width parameter.

Todo:
Remove this function in favor of calcWidthParm.

Definition at line 115 of file BinnerAxisLog.cxx.

References BinnerAxisLog::calcWidthParm(), BinnerAxis::m_num_bins, and BinnerAxis::m_width.

const void setOffset ( double  offset  )  [virtual]

Sets the offset and adjusts the range accordingly.

Implements BinnerAxis.

Definition at line 213 of file BinnerAxisLog.cxx.

References BinnerAxisLog::bins, Range::low(), BinnerAxis::m_offset, BinnerAxis::m_range_start, BinnerAxis::m_width, and BinnerAxisLog::setRange().

const Range & setRange ( const Range ,
bool  hold_width = true 
) [virtual]

Sets the range.

Adjusts the number of bins if hold_width is true, otherwise adjusts the width parameter. Returns the adjusted range.

Implements BinnerAxis.

Definition at line 147 of file BinnerAxisLog.cxx.

References BinnerAxisLog::bins, BinnerAxisLog::calcWidthParm(), BinnerAxisLog::getNob(), Range::high(), Range::low(), BinnerAxis::m_num_bins, BinnerAxis::m_range, BinnerAxis::m_width, BinnerAxisLog::setBins(), Range::setHigh(), and Range::setLow().

Referenced by BinnerAxisLog::setOffset().

void setStartRange ( bool  dragging  )  const [inherited]

Sets the starting Range.

Definition at line 90 of file BinnerAxis.cxx.

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

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

void setStartWidth ( bool  dragging  )  const [inherited]

Sets the starting width parameter.

Definition at line 100 of file BinnerAxis.cxx.

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

Referenced by BinnerAxis::calcBinWidth().


Member Data Documentation

std::vector<double> bins [private]

Has the lower edge of each bin, starting with [0] = the first one.

Definition at line 41 of file BinnerAxisLog.h.

Referenced by BinnerAxisLog::axisBinNumber(), BinnerAxisLog::axisBinWidth(), BinnerAxisLog::getCoordinate(), BinnerAxisLog::setBins(), BinnerAxisLog::setBinWidth(), BinnerAxisLog::setOffset(), and BinnerAxisLog::setRange().

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

The coordinates 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 80 of file BinnerAxis.h.

Referenced by BinnerAxis::binEdges().

int m_num_bins [mutable, protected, inherited]

The number of bins.

Definition at line 64 of file BinnerAxis.h.

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

double m_offset [protected, inherited]

The offset.

Definition at line 71 of file BinnerAxis.h.

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

Range 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 68 of file BinnerAxis.h.

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

Range m_range_start [mutable, protected, inherited]

The Range at the start of dragging.

Definition at line 83 of file BinnerAxis.h.

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

double m_width [protected, inherited]

The width parameter for the binning.

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

Definition at line 75 of file BinnerAxis.h.

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

double m_width_start [mutable, protected, inherited]

The width parameter at the start of dragging.

Definition at line 86 of file BinnerAxis.h.

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

double s_bin_factor = 0.75 [static, protected, inherited]

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

Definition at line 61 of file BinnerAxis.h.

int 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 57 of file BinnerAxis.h.


The documentation for this class was generated from the following files:
Generated for HippoDraw Class Library by doxygen