#include <HistoAxis.h>
Public Member Functions | |
double | binCenter (const int binNum) const |
Interval< double > | binInterval (const int binNum) const |
int | binNumber (double x) const |
LinearMapper1d | binNumberMapper (bool mapLeftEdgeTo0=true) const |
unsigned | closestValidBin (double x) const |
double | fltBinNumber (const double x, const bool mapLeftEdgeTo0=true) const |
HistoAxis (unsigned nBins, double min, double max, const char *label=0) | |
bool | isClose (const HistoAxis &, double tol) const |
CircularMapper1d | kernelScanMapper (bool doubleRange) const |
double | leftBinEdge (const int binNum) const |
bool | operator!= (const HistoAxis &) const |
bool | operator== (const HistoAxis &) 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=0) 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 HistoAxis * | read (const gs::ClassId &id, std::istream &in) |
static unsigned | version () |
Private Member Functions | |
HistoAxis () | |
unsigned | overflowIndex (const double x, unsigned *binNumber) const |
unsigned | overflowIndexWeighted (double x, unsigned *binNumber, double *weight) const |
Private Attributes | |
double | bw_ |
std::string | label_ |
double | max_ |
double | min_ |
unsigned | nBins_ |
Friends | |
class | DualHistoAxis |
class | HistoND |
Class which contain the information needed to define a histogram axis. All bins will have the same width. See NUHistoAxis and DualHistoAxis classes for non-uniform binning.
Definition at line 30 of file HistoAxis.h.
npstat::HistoAxis::HistoAxis | ( | unsigned | nBins, |
double | min, | ||
double | max, | ||
const char * | label = 0 |
||
) |
Minimum and maximum will be internally swapped if the minimum parameter is larger than the maximum
Definition at line 13 of file HistoAxis.cc.
npstat::HistoAxis::HistoAxis | ( | ) | [inline, private] |
double npstat::HistoAxis::binCenter | ( | const int | binNum | ) | const [inline] |
Return the coordinate of the given bin center
Definition at line 54 of file HistoAxis.h.
Referenced by npstat::DualHistoAxis::binCenter(), and npstat::convertToGridAxis().
Interval<double> npstat::HistoAxis::binInterval | ( | const int | binNum | ) | const [inline] |
Return the coordinate interval occupied by the given bin
Definition at line 66 of file HistoAxis.h.
Referenced by npstat::DualHistoAxis::binInterval().
int npstat::HistoAxis::binNumber | ( | double | x | ) | const |
This method returns arbitrary integer bin number, including negative numbers and numbers which can exceed nBins()-1
Definition at line 46 of file HistoAxis.cc.
References bw_, max_, min_, and nBins_.
Referenced by npstat::DualHistoAxis::binNumber(), and overflowIndexWeighted().
LinearMapper1d npstat::HistoAxis::binNumberMapper | ( | bool | mapLeftEdgeTo0 = true | ) | const |
Return the mapper which calculates floating point bin number given the coordinate. The resulting bin number can go above and below the axis range. If "mapLeftEdgeTo0" is specified as "false", it is the center of the first bin which gets mapped to 0.
Definition at line 85 of file HistoAxis.cc.
double npstat::HistoAxis::binWidth | ( | const int | = 0 | ) | const [inline] |
Definition at line 48 of file HistoAxis.h.
References bw_.
Referenced by npstat::DualHistoAxis::binWidth().
{return bw_;}
gs::ClassId npstat::HistoAxis::classId | ( | ) | const [inline] |
Method related to "geners" I/O
Definition at line 119 of file HistoAxis.h.
Referenced by npstat::DualHistoAxis::write().
{return gs::ClassId(*this);}
static const char* npstat::HistoAxis::classname | ( | ) | [inline, static] |
Definition at line 123 of file HistoAxis.h.
{return "npstat::HistoAxis";}
unsigned npstat::HistoAxis::closestValidBin | ( | double | x | ) | const |
This method returns the closest valid bin number (above 0 and below nBins() )
Definition at line 72 of file HistoAxis.cc.
References bw_, max_, min_, and nBins_.
Referenced by npstat::DualHistoAxis::closestValidBin().
double npstat::HistoAxis::fltBinNumber | ( | const double | x, |
const bool | mapLeftEdgeTo0 = true |
||
) | const [inline] |
Floating point bin number given the coordinate (no bin number truncation of any kind is performed). Works in exactly the same way as the mapper returned by the previous method.
Definition at line 99 of file HistoAxis.h.
Referenced by npstat::DualHistoAxis::fltBinNumber().
Interval<double> npstat::HistoAxis::interval | ( | ) | const [inline] |
Definition at line 44 of file HistoAxis.h.
Referenced by npstat::DualHistoAxis::interval().
bool npstat::HistoAxis::isClose | ( | const HistoAxis & | r, |
double | tol | ||
) | const |
Comparison of axis coordinates within given tolerance
Definition at line 25 of file HistoAxis.cc.
References npstat::closeWithinTolerance(), label_, max_, min_, and nBins_.
Referenced by npstat::DualHistoAxis::isClose().
{ return closeWithinTolerance(min_, r.min_, tol) && closeWithinTolerance(max_, r.max_, tol) && label_ == r.label_ && nBins_ == r.nBins_; }
bool npstat::HistoAxis::isUniform | ( | ) | const [inline] |
Definition at line 50 of file HistoAxis.h.
{return true;}
CircularMapper1d npstat::HistoAxis::kernelScanMapper | ( | bool | doubleRange | ) | const |
The following function returns a mapper that can be helpful in scanning a kernel (a density function) for subsequent convolution with the histogram which contains this axis.
Definition at line 94 of file HistoAxis.cc.
References bw_, max_, and min_.
{ if (!bw_) throw npstat::NpstatDomainError( "In npstat::HistoAxis::kernelScanMapper: " "bin width is zero. Mapper can not be constructed."); double range = max_ - min_; if (doubleRange) range *= 2.0; return CircularMapper1d(bw_, 0.0, range); }
const std::string& npstat::HistoAxis::label | ( | ) | const [inline] |
Definition at line 49 of file HistoAxis.h.
References label_.
Referenced by npstat::convertToGridAxis(), npstat::DualHistoAxis::label(), and read().
{return label_;}
double npstat::HistoAxis::leftBinEdge | ( | const int | binNum | ) | const [inline] |
Return the coordinate of the given bin left edge
Definition at line 58 of file HistoAxis.h.
Referenced by npstat::DualHistoAxis::leftBinEdge().
double npstat::HistoAxis::length | ( | ) | const [inline] |
Definition at line 46 of file HistoAxis.h.
Referenced by npstat::DualHistoAxis::length().
double npstat::HistoAxis::max | ( | ) | const [inline] |
Definition at line 43 of file HistoAxis.h.
References max_.
Referenced by npstat::DualHistoAxis::max(), and read().
{return max_;}
double npstat::HistoAxis::min | ( | ) | const [inline] |
Examine axis properties
Definition at line 42 of file HistoAxis.h.
References min_.
Referenced by npstat::DualHistoAxis::min(), and read().
{return min_;}
unsigned npstat::HistoAxis::nBins | ( | ) | const [inline] |
Definition at line 47 of file HistoAxis.h.
References nBins_.
Referenced by npstat::convertToGridAxis(), npstat::DualHistoAxis::nBins(), and read().
{return nBins_;}
bool npstat::HistoAxis::operator!= | ( | const HistoAxis & | r | ) | const |
bool npstat::HistoAxis::operator== | ( | const HistoAxis & | r | ) | const |
unsigned npstat::HistoAxis::overflowIndex | ( | const double | x, |
unsigned * | binNumber | ||
) | const [inline, private] |
Definition at line 139 of file HistoAxis.h.
References newFWLiteAna::bin, bw_, max_, min_, and nBins_.
Referenced by npstat::DualHistoAxis::overflowIndex().
unsigned npstat::HistoAxis::overflowIndexWeighted | ( | double | x, |
unsigned * | binNumber, | ||
double * | weight | ||
) | const [private] |
Definition at line 105 of file HistoAxis.cc.
References newFWLiteAna::bin, binNumber(), bw_, max_, min_, and nBins_.
{ if (x < min_) return 0U; else if (x >= max_) return 2U; else { if (nBins_ <= 1U) throw npstat::NpstatInvalidArgument( "In npstat::HistoAxis::overflowIndexWeighted: " "must have more than one bin"); const double dbin = (x - min_)/bw_; if (dbin <= 0.5) { *binNumber = 0; *weight = 1.0; } else if (dbin >= nBins_ - 0.5) { *binNumber = nBins_ - 2; *weight = 0.0; } else { const unsigned bin = static_cast<unsigned>(dbin - 0.5); *binNumber = bin >= nBins_ - 1U ? nBins_ - 2U : bin; *weight = 1.0 - (dbin - 0.5 - *binNumber); } return 1U; } }
HistoAxis * npstat::HistoAxis::read | ( | const gs::ClassId & | id, |
std::istream & | in | ||
) | [static] |
Definition at line 147 of file HistoAxis.cc.
References cond::rpcobimon::current, HistoAxis(), label(), max(), min(), nBins(), and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by npstat::DualHistoAxis::read().
{ static const gs::ClassId current(gs::ClassId::makeId<HistoAxis>()); current.ensureSameId(id); double min = 0.0, max = 0.0; std::string label; unsigned nBins = 0; gs::read_pod(in, &min); gs::read_pod(in, &max); gs::read_pod(in, &label); gs::read_pod(in, &nBins); if (!in.fail()) return new HistoAxis(nBins, min, max, label.c_str()); else throw gs::IOReadFailure("In npstat::HistoAxis::read: " "input stream failure"); }
double npstat::HistoAxis::rightBinEdge | ( | const int | binNum | ) | const [inline] |
Return the coordinate of the given bin right edge
Definition at line 62 of file HistoAxis.h.
Referenced by npstat::DualHistoAxis::rightBinEdge().
void npstat::HistoAxis::setLabel | ( | const char * | newlabel | ) | [inline] |
Change the axis label
Definition at line 70 of file HistoAxis.h.
References label_.
Referenced by npstat::DualHistoAxis::setLabel().
{label_ = newlabel ? newlabel : "";}
static unsigned npstat::HistoAxis::version | ( | ) | [inline, static] |
Definition at line 124 of file HistoAxis.h.
{return 1;}
bool npstat::HistoAxis::write | ( | std::ostream & | of | ) | const |
friend class DualHistoAxis [friend] |
Definition at line 137 of file HistoAxis.h.
friend class HistoND [friend] |
Definition at line 136 of file HistoAxis.h.
double npstat::HistoAxis::bw_ [private] |
Definition at line 132 of file HistoAxis.h.
Referenced by binCenter(), binInterval(), binNumber(), binNumberMapper(), binWidth(), closestValidBin(), fltBinNumber(), HistoAxis(), kernelScanMapper(), leftBinEdge(), overflowIndex(), overflowIndexWeighted(), and rightBinEdge().
std::string npstat::HistoAxis::label_ [private] |
Definition at line 133 of file HistoAxis.h.
Referenced by isClose(), label(), operator==(), setLabel(), and write().
double npstat::HistoAxis::max_ [private] |
Definition at line 131 of file HistoAxis.h.
Referenced by binNumber(), closestValidBin(), HistoAxis(), interval(), isClose(), kernelScanMapper(), length(), max(), operator==(), overflowIndex(), overflowIndexWeighted(), and write().
double npstat::HistoAxis::min_ [private] |
Definition at line 130 of file HistoAxis.h.
Referenced by binCenter(), binInterval(), binNumber(), binNumberMapper(), closestValidBin(), fltBinNumber(), HistoAxis(), interval(), isClose(), kernelScanMapper(), leftBinEdge(), length(), min(), operator==(), overflowIndex(), overflowIndexWeighted(), rightBinEdge(), and write().
unsigned npstat::HistoAxis::nBins_ [private] |
Definition at line 134 of file HistoAxis.h.
Referenced by binNumber(), closestValidBin(), HistoAxis(), isClose(), nBins(), operator==(), overflowIndex(), overflowIndexWeighted(), and write().