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

BinsFunction Class Reference

#include <BinsFunction.h>

Collaboration diagram for BinsFunction:

Collaboration graph
[legend]
List of all members.

Detailed Description

A binner-like object for drawing functions as a set of straight line segments with all kinks smaller than a certain value.

Bug:
@ If function is being display with X axis on log scale, the the low range of X may not display correctly.

Bug:
On a very peaky distribution, the alogrithim is failing to plot a smooth curve.
look at the "Cost" fit in function.py after expanding it vertically.

Author:
Paul_Kunz@slac.stanford.edu>

Oded Wurman <oded@slac.stanford.edu>

Definition at line 39 of file BinsFunction.h.

Public Member Functions

 BinsFunction (const BinsFunction &binner)
 The copy constructor.
 BinsFunction (int num_bins=10, double low=0.0, double high=50.0)
 The constructor that creates the binner object with the number of bins = num_bins, low edge of first bin = low, and low edge of ( last bin + 1 ) = high (in other words, the high edge of the last bin).
virtual BinsFunctionclone () const
 The clone function returns an object of its own kind which is a copy of this this object at this moment.
virtual void createValuesArray (std::list< std::vector< double > > &array)
 Creates the array of projected values.
void setFunction (FunctionBase *)
 Sets the function to be projected.
virtual void setNumberOfBins (hippodraw::Axes::Type axis, int num_bins)
virtual const RangesetRange (hippodraw::Axes::Type axis, const Range &, bool hold_width=true)
void setRangeOn (hippodraw::Axes::Type axis, const Range &data, const Range &view)
 Sets the range over which the function will be plotted.
virtual ~BinsFunction ()
 The destructor.

Protected Member Functions

void resize (unsigned int new_size, std::list< std::vector< double > > &values)
 Resizes the values list.
void smoothCurve (std::list< std::vector< double > > &)
 Smoothes the appearance of the function line segments.

Protected Attributes

FunctionBasem_function
 The function to be projected.
int m_num_bins
 The number of bins.
bool m_values_dirty
 The dirty flag.
Range m_x_range
 The range of the bins on the X axis.
Range m_xv_range
 The range in the display device's coordinate system.
Range m_y_range
 The range of values on the Y axis.
Range m_yv_range
 The range in the display device's coordinate system.


Constructor & Destructor Documentation

BinsFunction::BinsFunction int  num_bins = 10,
double  low = 0.0,
double  high = 50.0
 

The constructor that creates the binner object with the number of bins = num_bins, low edge of first bin = low, and low edge of ( last bin + 1 ) = high (in other words, the high edge of the last bin).

This is used as a starting point.

Definition at line 46 of file BinsFunction.cxx.

References m_values_dirty, setNumberOfBins(), and hippodraw::Axes::X.

Referenced by clone().

BinsFunction::BinsFunction const BinsFunction binner  ) 
 

The copy constructor.

Definition at line 53 of file BinsFunction.cxx.

BinsFunction::~BinsFunction  )  [virtual]
 

The destructor.

Definition at line 59 of file BinsFunction.cxx.


Member Function Documentation

BinsFunction * BinsFunction::clone  )  const [virtual]
 

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

Definition at line 63 of file BinsFunction.cxx.

References BinsFunction().

void BinsFunction::createValuesArray std::list< std::vector< double > > &  array  )  [virtual]
 

Creates the array of projected values.

Definition at line 92 of file BinsFunction.cxx.

References Range::length(), Range::low(), m_function, m_num_bins, m_values_dirty, m_x_range, resize(), smoothCurve(), hippodraw::Axes::X, and hippodraw::Axes::Y.

Referenced by FunctionProjector::prepareValues().

void BinsFunction::resize unsigned int  new_size,
std::list< std::vector< double > > &  values
[protected]
 

Resizes the values list.

The new size will be new_size.

Definition at line 83 of file BinsFunction.cxx.

References hippodraw::DataPoint2DTuple::SIZE.

Referenced by createValuesArray().

void BinsFunction::setFunction FunctionBase  ) 
 

Sets the function to be projected.

Definition at line 230 of file BinsFunction.cxx.

References m_function, and m_values_dirty.

Referenced by FunctionProjector::prepareValues().

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

Definition at line 70 of file BinsFunction.cxx.

References m_num_bins, m_values_dirty, and hippodraw::Axes::X.

Referenced by BinsFunction(), and FunctionProjector::setNumberOfBins().

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

Definition at line 215 of file BinsFunction.cxx.

References m_values_dirty, m_x_range, m_y_range, hippodraw::Axes::X, and hippodraw::Axes::Y.

Referenced by FunctionProjector::setAxisModel(), and FunctionProjector::setRange().

void BinsFunction::setRangeOn hippodraw::Axes::Type  axis,
const Range data,
const Range view
 

Sets the range over which the function will be plotted.

The first range is in the coordinate system of the data. The second range is in the coordinate system of the display device.

Definition at line 197 of file BinsFunction.cxx.

References m_values_dirty, m_x_range, m_xv_range, m_y_range, m_yv_range, hippodraw::Axes::X, and hippodraw::Axes::Y.

Referenced by FunctionProjector::prepareAxis().

void BinsFunction::smoothCurve std::list< std::vector< double > > &  values  )  [protected]
 

Smoothes the appearance of the function line segments.

Starting with the first point, the angle between the line segment from it and the next, and the line between the next and the one after it, is calculated. If this angle is smaller than the predetermined angle, which depends on the resolution of the display device, then one proceeds to the next point. If not, then a comparison is made between the length along the X axis of the two line segments. A point is inserted in the middle of the longer one and another iteration is performed until the angle is smaller than the predetermined angle.

This algorithm was first implemented by Paul Rensing when he was at SLAC in 1993.

Definition at line 133 of file BinsFunction.cxx.

References std::abs(), Range::length(), m_function, M_PI, m_x_range, m_xv_range, m_y_range, m_yv_range, hippodraw::DataPoint2DTuple::SIZE, hippodraw::Axes::X, and hippodraw::Axes::Y.

Referenced by createValuesArray().


Member Data Documentation

FunctionBase* BinsFunction::m_function [protected]
 

The function to be projected.

Definition at line 63 of file BinsFunction.h.

Referenced by createValuesArray(), setFunction(), and smoothCurve().

int BinsFunction::m_num_bins [protected]
 

The number of bins.

Definition at line 44 of file BinsFunction.h.

Referenced by createValuesArray(), and setNumberOfBins().

bool BinsFunction::m_values_dirty [protected]
 

The dirty flag.

Definition at line 66 of file BinsFunction.h.

Referenced by BinsFunction(), createValuesArray(), setFunction(), setNumberOfBins(), setRange(), and setRangeOn().

Range BinsFunction::m_x_range [protected]
 

The range of the bins on the X axis.

This controls the range over which the function is plotted.

Definition at line 48 of file BinsFunction.h.

Referenced by createValuesArray(), setRange(), setRangeOn(), and smoothCurve().

Range BinsFunction::m_xv_range [protected]
 

The range in the display device's coordinate system.

This is used as part of the algorithm of the curved functions.

Definition at line 56 of file BinsFunction.h.

Referenced by setRangeOn(), and smoothCurve().

Range BinsFunction::m_y_range [protected]
 

The range of values on the Y axis.

The projected values are not generated outside of this range.

Definition at line 52 of file BinsFunction.h.

Referenced by setRange(), setRangeOn(), and smoothCurve().

Range BinsFunction::m_yv_range [protected]
 

The range in the display device's coordinate system.

This is used as part of the algorithm of the curved functions.

Definition at line 60 of file BinsFunction.h.

Referenced by setRangeOn(), and smoothCurve().


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