CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
npstat::NUHistoAxis Class Reference

#include <NUHistoAxis.h>

Public Member Functions

double binCenter (const int binNum) const
 
Interval< double > binInterval (const int binNum) const
 
int binNumber (double x) const
 
unsigned closestValidBin (double x) const
 
double fltBinNumber (double x, bool mapLeftEdgeTo0=true) const
 
bool isClose (const NUHistoAxis &, double tol) const
 
double leftBinEdge (const int binNum) const
 
 NUHistoAxis (const std::vector< double > &binEdges, const char *label=0)
 
bool operator!= (const NUHistoAxis &) const
 
bool operator== (const NUHistoAxis &) const
 
NUHistoAxis rebin (unsigned newBins) const
 
double rightBinEdge (const int binNum) const
 
void setLabel (const char *newlabel)
 
double min () const
 
double max () const
 
Interval< double > interval () const
 
double length () const
 
unsigned nBins () const
 
double binWidth (const int binNum) const
 
const std::string & label () const
 
bool isUniform () const
 
gs::ClassId classId () const
 
bool write (std::ostream &of) const
 

Static Public Member Functions

static const char * classname ()
 
static NUHistoAxisread (const gs::ClassId &id, std::istream &in)
 
static unsigned version ()
 

Private Member Functions

 NUHistoAxis (unsigned nBins, double min, double max, const char *label=0)
 
 NUHistoAxis ()
 
unsigned overflowIndex (const double x, unsigned *binNum) const
 

Private Attributes

std::vector< double > binEdges_
 
std::string label_
 
double max_
 
double min_
 
unsigned nBins_
 
bool uniform_
 

Friends

class DualHistoAxis
 
template<typename Numeric , class Axis >
class HistoND
 

Detailed Description

This class can be used to create histograms with non-uniform binning

Definition at line 27 of file NUHistoAxis.h.

Constructor & Destructor Documentation

npstat::NUHistoAxis::NUHistoAxis ( const std::vector< double > &  binEdges,
const char *  label = 0 
)

The number of bin edges provided must be at least 2. Edge coordinates will be sorted internally in the increasing order. The number of bins will be less by 1 than the number of edges.

Definition at line 15 of file NUHistoAxis.cc.

npstat::NUHistoAxis::NUHistoAxis ( unsigned  nBins,
double  min,
double  max,
const char *  label = 0 
)
private

Definition at line 29 of file NUHistoAxis.cc.

npstat::NUHistoAxis::NUHistoAxis ( )
inlineprivate

Definition at line 137 of file NUHistoAxis.h.

137  : min_(0.0), max_(0.0),
138  nBins_(0), uniform_(false) {}

Member Function Documentation

double npstat::NUHistoAxis::binCenter ( const int  binNum) const
inline

Return the coordinate of the given bin center

Definition at line 60 of file NUHistoAxis.h.

References binEdges_.

Referenced by npstat::convertToGridAxis().

61  {return 0.5*(binEdges_.at(binNum) + binEdges_.at(binNum + 1));}
std::vector< double > binEdges_
Definition: NUHistoAxis.h:115
Interval<double> npstat::NUHistoAxis::binInterval ( const int  binNum) const
inline

Return the coordinate interval occupied by the given bin

Definition at line 64 of file NUHistoAxis.h.

References binEdges_.

65  {return Interval<double>(binEdges_.at(binNum),
66  binEdges_.at(binNum + 1));}
std::vector< double > binEdges_
Definition: NUHistoAxis.h:115
int npstat::NUHistoAxis::binNumber ( double  x) const

This method returns -1 for values below the lower limit and "nBins()" for values equal to or above the upper limit

Definition at line 78 of file NUHistoAxis.cc.

Referenced by overflowIndex().

double npstat::NUHistoAxis::binWidth ( const int  binNum) const
inline

Definition at line 45 of file NUHistoAxis.h.

References binEdges_.

46  {return binEdges_.at(binNum+1) - binEdges_.at(binNum);}
std::vector< double > binEdges_
Definition: NUHistoAxis.h:115
gs::ClassId npstat::NUHistoAxis::classId ( ) const
inline

Method related to "geners" I/O

Definition at line 101 of file NUHistoAxis.h.

Referenced by npstat::DualHistoAxis::write().

101 {return gs::ClassId(*this);}
static const char* npstat::NUHistoAxis::classname ( )
inlinestatic

Definition at line 105 of file NUHistoAxis.h.

105 {return "npstat::NUHistoAxis";}
unsigned npstat::NUHistoAxis::closestValidBin ( double  x) const

This method returns the closest valid bin number (above 0 and below nBins() )

Definition at line 150 of file NUHistoAxis.cc.

double npstat::NUHistoAxis::fltBinNumber ( double  x,
bool  mapLeftEdgeTo0 = true 
) const

Floating point bin number given the coordinate. Useful for interpolation methods and such.

Definition at line 85 of file NUHistoAxis.cc.

Interval<double> npstat::NUHistoAxis::interval ( ) const
inline

Definition at line 41 of file NUHistoAxis.h.

References max_, and min_.

42  {return Interval<double>(min_, max_);}
bool npstat::NUHistoAxis::isClose ( const NUHistoAxis r,
double  tol 
) const

Comparison of axis coordinates within given tolerance

Definition at line 49 of file NUHistoAxis.cc.

bool npstat::NUHistoAxis::isUniform ( ) const
inline

Definition at line 48 of file NUHistoAxis.h.

References uniform_.

48 {return uniform_;}
const std::string& npstat::NUHistoAxis::label ( ) const
inline

Definition at line 47 of file NUHistoAxis.h.

References label_.

Referenced by npstat::convertToGridAxis().

47 {return label_;}
std::string label_
Definition: NUHistoAxis.h:116
double npstat::NUHistoAxis::leftBinEdge ( const int  binNum) const
inline

Return the coordinate of the given bin left edge

Definition at line 52 of file NUHistoAxis.h.

References binEdges_.

53  {return binEdges_.at(binNum);}
std::vector< double > binEdges_
Definition: NUHistoAxis.h:115
double npstat::NUHistoAxis::length ( ) const
inline

Definition at line 43 of file NUHistoAxis.h.

References max_, and min_.

43 {return max_ - min_;}
double npstat::NUHistoAxis::max ( ) const
inline

Definition at line 40 of file NUHistoAxis.h.

References max_.

40 {return max_;}
double npstat::NUHistoAxis::min ( ) const
inline

Examine axis properties

Definition at line 39 of file NUHistoAxis.h.

References min_.

39 {return min_;}
unsigned npstat::NUHistoAxis::nBins ( ) const
inline

Definition at line 44 of file NUHistoAxis.h.

References nBins_.

Referenced by npstat::convertToGridAxis().

44 {return nBins_;}
bool npstat::NUHistoAxis::operator!= ( const NUHistoAxis r) const

Definition at line 73 of file NUHistoAxis.cc.

bool npstat::NUHistoAxis::operator== ( const NUHistoAxis r) const

Definition at line 63 of file NUHistoAxis.cc.

unsigned npstat::NUHistoAxis::overflowIndex ( const double  x,
unsigned *  binNum 
) const
inlineprivate

Definition at line 123 of file NUHistoAxis.h.

References binNumber(), max_, and min_.

125  {
126  if (x < min_)
127  return 0U;
128  else if (x >= max_)
129  return 2U;
130  else
131  {
132  *binNum = binNumber(x);
133  return 1U;
134  }
135  }
int binNumber(double x) const
Definition: NUHistoAxis.cc:78
NUHistoAxis * npstat::NUHistoAxis::read ( const gs::ClassId &  id,
std::istream &  in 
)
static

Definition at line 171 of file NUHistoAxis.cc.

Referenced by npstat::DualHistoAxis::read().

NUHistoAxis npstat::NUHistoAxis::rebin ( unsigned  newBins) const

Return uniformly rebinned axis

Definition at line 44 of file NUHistoAxis.cc.

double npstat::NUHistoAxis::rightBinEdge ( const int  binNum) const
inline

Return the coordinate of the given bin right edge

Definition at line 56 of file NUHistoAxis.h.

References binEdges_.

57  {return binEdges_.at(binNum + 1);}
std::vector< double > binEdges_
Definition: NUHistoAxis.h:115
void npstat::NUHistoAxis::setLabel ( const char *  newlabel)
inline

Change the axis label

Definition at line 69 of file NUHistoAxis.h.

References label_.

70  {label_ = newlabel ? newlabel : "";}
std::string label_
Definition: NUHistoAxis.h:116
static unsigned npstat::NUHistoAxis::version ( )
inlinestatic

Definition at line 106 of file NUHistoAxis.h.

106 {return 1;}
bool npstat::NUHistoAxis::write ( std::ostream &  of) const

Definition at line 162 of file NUHistoAxis.cc.

Referenced by npstat::DualHistoAxis::write().

Friends And Related Function Documentation

friend class DualHistoAxis
friend

Definition at line 121 of file NUHistoAxis.h.

template<typename Numeric , class Axis >
friend class HistoND
friend

Definition at line 120 of file NUHistoAxis.h.

Member Data Documentation

std::vector<double> npstat::NUHistoAxis::binEdges_
private

Definition at line 115 of file NUHistoAxis.h.

Referenced by binCenter(), binInterval(), binWidth(), leftBinEdge(), and rightBinEdge().

std::string npstat::NUHistoAxis::label_
private

Definition at line 116 of file NUHistoAxis.h.

Referenced by label(), and setLabel().

double npstat::NUHistoAxis::max_
private

Definition at line 114 of file NUHistoAxis.h.

Referenced by interval(), length(), max(), and overflowIndex().

double npstat::NUHistoAxis::min_
private

Definition at line 113 of file NUHistoAxis.h.

Referenced by interval(), length(), min(), and overflowIndex().

unsigned npstat::NUHistoAxis::nBins_
private

Definition at line 117 of file NUHistoAxis.h.

Referenced by nBins().

bool npstat::NUHistoAxis::uniform_
private

Definition at line 118 of file NUHistoAxis.h.

Referenced by isUniform().