7 #include "Alignment/Geners/interface/binaryIO.hh"
8 #include "Alignment/Geners/interface/IOException.hh"
16 : binEdges_(binEdges), nBins_(binEdges.
size() - 1U), uniform_(
false) {
19 "In npstat::NUHistoAxis constructor: "
20 "number of bin edges is out of range");
29 : min_(min), max_(max), nBins_(nBins), uniform_(
true) {
32 "In npstat::NUHistoAxis constructor: "
33 "number of bins is out of range");
69 const int binnum = delta - 1;
74 double bval = (x - left) / (right - left);
80 }
else if (static_cast<unsigned>(binnum) >=
nBins_) {
83 double bval =
nBins_ - 1U + (x - left) / (right - left);
86 if (bval > static_cast<double>(
nBins_))
93 return binnum + (x - left) / (right - left);
100 return binnum + (x - left) / (right - left) - 0.5;
126 int binnum = delta - 1;
129 else if (static_cast<unsigned>(binnum) >=
nBins_)
136 gs::write_pod(of,
label_);
138 gs::write_pod(of, c);
143 static const gs::ClassId current(gs::ClassId::makeId<NUHistoAxis>());
144 current.ensureSameId(
id);
146 std::vector<double> binEdges;
149 gs::read_pod_vector(in, &binEdges);
150 gs::read_pod(in, &label);
151 gs::read_pod(in, &unif);
153 throw gs::IOReadFailure(
154 "In npstat::UHistoAxis::read: "
155 "input stream failure");
unsigned closestValidBin(double x) const
std::vector< double > binEdges_
const edm::EventSetup & c
int binNumber(double x) const
bool write(std::ostream &of) const
bool closeWithinTolerance(const double &a, const double &b, const double &tol)
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Histogram axis with non-uniform bin spacing.
bool operator!=(const NUHistoAxis &) const
Equidistant sequences of points in either linear or log space.
Exceptions for the npstat namespace.
NUHistoAxis rebin(unsigned newBins) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Determine if two doubles are within requested relative tolerance of each other.
static NUHistoAxis * read(const gs::ClassId &id, std::istream &in)
bool isClose(const NUHistoAxis &, double tol) const
double fltBinNumber(double x, bool mapLeftEdgeTo0=true) const
bool operator==(const NUHistoAxis &) const
tuple size
Write out results.
const std::string & label() const