6 #include "Alignment/Geners/interface/binaryIO.hh"
7 #include "Alignment/Geners/interface/IOException.hh"
15 : min_(min), max_(max), label_(label ? label :
""), nBins_(nbins)
19 "number of bins is out of range");
50 int binnum =
static_cast<int>(floor((x -
min_)/
bw_));
53 if (binnum < static_cast<int>(
nBins_))
58 if (binnum >= static_cast<int>(
nBins_))
78 const unsigned binnum =
static_cast<unsigned>(floor((x-
min_)/
bw_));
88 "In npstat::HistoAxis::binNumberMapper: "
89 "bin width is zero. Mapper can not be constructed.");
97 "In npstat::HistoAxis::kernelScanMapper: "
98 "bin width is zero. Mapper can not be constructed.");
115 "In npstat::HistoAxis::overflowIndexWeighted: "
116 "must have more than one bin");
117 const double dbin = (x -
min_)/
bw_;
123 else if (dbin >=
nBins_ - 0.5)
130 const unsigned bin =
static_cast<unsigned>(dbin - 0.5);
132 *weight = 1.0 - (dbin - 0.5 - *
binNumber);
140 gs::write_pod(of,
min_);
141 gs::write_pod(of,
max_);
142 gs::write_pod(of,
label_);
143 gs::write_pod(of,
nBins_);
149 static const gs::ClassId
current(gs::ClassId::makeId<HistoAxis>());
150 current.ensureSameId(
id);
152 double min = 0.0,
max = 0.0;
156 gs::read_pod(in, &min);
157 gs::read_pod(in, &
max);
158 gs::read_pod(in, &label);
159 gs::read_pod(in, &nBins);
164 throw gs::IOReadFailure(
"In npstat::HistoAxis::read: "
165 "input stream failure");
bool closeWithinTolerance(const double &a, const double &b, const double &tol)
int binNumber(double x) const
const std::string & label() const
bool operator!=(const HistoAxis &) const
bool write(std::ostream &of) const
Exceptions for the npstat namespace.
const T & max(const T &a, const T &b)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static HistoAxis * read(const gs::ClassId &id, std::istream &in)
Determine if two doubles are within requested relative tolerance of each other.
bool isClose(const HistoAxis &, double tol) const
CircularMapper1d kernelScanMapper(bool doubleRange) const
unsigned overflowIndexWeighted(double x, unsigned *binNumber, double *weight) const
bool operator==(const HistoAxis &) const
LinearMapper1d binNumberMapper(bool mapLeftEdgeTo0=true) const
unsigned closestValidBin(double x) const
Histogram axis with equidistant bins.