1 #ifndef NPSTAT_HISTOAXIS_HH_
2 #define NPSTAT_HISTOAXIS_HH_
16 #include "geners/ClassId.hh"
22 template <
typename Numeric,
class Axis>
class HistoND;
42 inline double min()
const {
return min_;}
43 inline double max()
const {
return max_;}
44 inline Interval<double> interval()
const
45 {
return Interval<double>(min_, max_);}
46 inline double length()
const {
return max_ - min_;}
47 inline unsigned nBins()
const {
return nBins_;}
48 inline double binWidth(
const int =0)
const {
return bw_;}
49 inline const std::string& label()
const {
return label_;}
50 inline bool isUniform()
const {
return true;}
55 {
return min_ + (binNum + 0.5)*bw_;}
59 {
return min_ + binNum*bw_;}
63 {
return min_ + (binNum + 1)*bw_;}
71 {label_ = newlabel ? newlabel :
"";}
100 const bool mapLeftEdgeTo0=
true)
const
101 {
return (x - min_)/bw_ - (mapLeftEdgeTo0 ? 0.0 : 0.5);}
122 inline gs::ClassId
classId()
const {
return gs::ClassId(*
this);}
123 bool write(std::ostream& of)
const;
126 static inline const char* classname() {
return "npstat::HistoAxis";}
127 static inline unsigned version() {
return 1;}
128 static HistoAxis* read(
const gs::ClassId&
id, std::istream& in);
137 template <
typename Numeric,
class Axis>
friend class HistoND;
138 friend class DualHistoAxis;
140 inline unsigned overflowIndex(
141 const double x,
unsigned*
binNumber)
const
149 const unsigned bin =
static_cast<unsigned>((x - min_)/bw_);
150 *
binNumber = bin >= nBins_ ? nBins_ - 1U : bin;
155 unsigned overflowIndexWeighted(
double x,
unsigned*
binNumber,
156 double *weight)
const;
159 inline std::pair<double,double> range()
const
160 {
return std::pair<double,double>(min_, max_);}
166 inline HistoAxis() : min_(0.0), max_(0.0), bw_(0.0), nBins_(0) {}
Linear transformation for circular topology.
Template to represent intervals in one dimension.
Definition: CircularMapper1d.hh:24
Definition: HistoAxis.hh:31
double min() const
Definition: HistoAxis.hh:42
double fltBinNumber(const double x, const bool mapLeftEdgeTo0=true) const
Definition: HistoAxis.hh:99
CircularMapper1d kernelScanMapper(bool doubleRange) const
double leftBinEdge(const int binNum) const
Definition: HistoAxis.hh:58
HistoAxis(unsigned nBins, double min, double max, const char *label=0)
gs::ClassId classId() const
Definition: HistoAxis.hh:122
void setLabel(const char *newlabel)
Definition: HistoAxis.hh:70
bool isClose(const HistoAxis &, double tol) const
int binNumber(double x) const
Interval< double > binInterval(const int binNum) const
Definition: HistoAxis.hh:66
HistoAxis rebin(unsigned newBins) const
unsigned closestValidBin(double x) const
double rightBinEdge(const int binNum) const
Definition: HistoAxis.hh:62
LinearMapper1d binNumberMapper(bool mapLeftEdgeTo0=true) const
double binCenter(const int binNum) const
Definition: HistoAxis.hh:54
Definition: Interval.hh:29
Definition: LinearMapper1d.hh:20
Definition: AbsArrayProjector.hh:14