1 #ifndef NPSTAT_NUHISTOAXIS_HH_
2 #define NPSTAT_NUHISTOAXIS_HH_
17 #include "geners/ClassId.hh"
21 template <
typename Numeric,
class Axis>
class HistoND;
35 NUHistoAxis(
const std::vector<double>& binEdges,
const char* label = 0);
39 inline double min()
const {
return min_;}
40 inline double max()
const {
return max_;}
41 inline Interval<double> interval()
const
42 {
return Interval<double>(min_, max_);}
43 inline double length()
const {
return max_ - min_;}
44 inline unsigned nBins()
const {
return nBins_;}
45 inline double binWidth(
const int binNum)
const
46 {
return binEdges_.at(binNum+1) - binEdges_.at(binNum);}
47 inline const std::string& label()
const {
return label_;}
48 inline bool isUniform()
const {
return uniform_;}
53 {
return binEdges_.at(binNum);}
57 {
return binEdges_.at(binNum + 1);}
61 {
return 0.5*(binEdges_.at(binNum) + binEdges_.at(binNum + 1));}
66 binEdges_.at(binNum + 1));}
70 {label_ = newlabel ? newlabel :
"";}
101 inline gs::ClassId
classId()
const {
return gs::ClassId(*
this);}
102 bool write(std::ostream& of)
const;
105 static inline const char* classname() {
return "npstat::NUHistoAxis";}
106 static inline unsigned version() {
return 1;}
107 static NUHistoAxis* read(
const gs::ClassId&
id, std::istream& in);
111 const char* label = 0);
115 std::vector<double> binEdges_;
120 template <
typename Numeric,
class Axis>
friend class HistoND;
121 friend class DualHistoAxis;
123 inline unsigned overflowIndex(
124 const double x,
unsigned* binNum)
const
139 inline std::pair<double,double> range()
const
140 {
return std::pair<double,double>(min_, max_);}
147 nBins_(0), uniform_(false) {}
Template to represent intervals in one dimension.
Definition: Interval.hh:29
Definition: NUHistoAxis.hh:28
double leftBinEdge(const int binNum) const
Definition: NUHistoAxis.hh:52
double rightBinEdge(const int binNum) const
Definition: NUHistoAxis.hh:56
bool isClose(const NUHistoAxis &, double tol) const
Interval< double > binInterval(const int binNum) const
Definition: NUHistoAxis.hh:64
NUHistoAxis(const std::vector< double > &binEdges, const char *label=0)
unsigned closestValidBin(double x) const
NUHistoAxis rebin(unsigned newBins) const
void setLabel(const char *newlabel)
Definition: NUHistoAxis.hh:69
double binCenter(const int binNum) const
Definition: NUHistoAxis.hh:60
gs::ClassId classId() const
Definition: NUHistoAxis.hh:101
double min() const
Definition: NUHistoAxis.hh:39
double fltBinNumber(double x, bool mapLeftEdgeTo0=true) const
int binNumber(double x) const
Definition: AbsArrayProjector.hh:14