6 #include "Alignment/Geners/interface/binaryIO.hh"
7 #include "Alignment/Geners/interface/IOException.hh"
14 : min_(min), max_(max), label_(label ? label :
""), nBins_(nbins) {
17 "In npstat::HistoAxis constructor: "
18 "number of bins is out of range");
39 int binnum =
static_cast<int>(floor((x -
min_) /
bw_));
41 if (binnum < static_cast<int>(
nBins_))
44 if (binnum >= static_cast<int>(
nBins_))
60 const unsigned binnum =
static_cast<unsigned>(floor((x -
min_) /
bw_));
70 "In npstat::HistoAxis::binNumberMapper: "
71 "bin width is zero. Mapper can not be constructed.");
79 "In npstat::HistoAxis::kernelScanMapper: "
80 "bin width is zero. Mapper can not be constructed.");
95 "In npstat::HistoAxis::overflowIndexWeighted: "
96 "must have more than one bin");
97 const double dbin = (x -
min_) /
bw_;
101 }
else if (dbin >=
nBins_ - 0.5) {
105 const unsigned bin =
static_cast<unsigned>(dbin - 0.5);
107 *weight = 1.0 - (dbin - 0.5 - *
binNumber);
114 gs::write_pod(of,
min_);
115 gs::write_pod(of,
max_);
116 gs::write_pod(of,
label_);
117 gs::write_pod(of,
nBins_);
122 static const gs::ClassId current(gs::ClassId::makeId<HistoAxis>());
123 current.ensureSameId(
id);
125 double min = 0.0,
max = 0.0;
129 gs::read_pod(in, &min);
130 gs::read_pod(in, &
max);
131 gs::read_pod(in, &label);
132 gs::read_pod(in, &nBins);
137 throw gs::IOReadFailure(
138 "In npstat::HistoAxis::read: "
139 "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
const uint16_t range(const Frame &aFrame)
bool write(std::ostream &of) const
Exceptions for the npstat namespace.
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static HistoAxis * read(const gs::ClassId &id, std::istream &in)
HistoAxis rebin(unsigned newBins) const
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.