7 #include "Alignment/Geners/interface/binaryIO.hh"
8 #include "Alignment/Geners/interface/IOException.hh"
17 : binEdges_(binEdges), nBins_(binEdges.
size() - 1U), uniform_(
false)
21 "number of bin edges is out of range");
30 const double min,
const double max,
32 : min_(min), max_(max), nBins_(nBins), uniform_(
true)
36 "number of bins is out of range");
84 const int binnum = delta - 1;
90 double bval = (x - left)/(right - left);
97 else if (static_cast<unsigned>(binnum) >=
nBins_)
101 double bval =
nBins_ - 1U + (x - left)/(right - left);
104 if (bval > static_cast<double>(
nBins_))
113 return binnum + (x - left)/(right - left);
119 const double binCenter = (left + right)/2.0;
120 if ((binnum == 0 && x <= binCenter) ||
121 (
static_cast<unsigned>(binnum) ==
nBins_ - 1 && x >= binCenter))
122 return binnum + (x - left)/(right - left) - 0.5;
123 else if (x <= binCenter)
125 const double otherBinCenter = (left +
binEdges_[binnum - 1])/2.0;
126 return binnum + (x -
binCenter)/(binCenter - otherBinCenter);
130 const double otherBinCenter = (right +
binEdges_[binnum + 1])/2.0;
131 return binnum + (x -
binCenter)/(otherBinCenter - binCenter);
141 int binnum = delta - 1;
144 else if (static_cast<unsigned>(binnum) >=
nBins_)
152 gs::write_pod(of,
label_);
154 gs::write_pod(of, c);
160 static const gs::ClassId
current(gs::ClassId::makeId<NUHistoAxis>());
161 current.ensureSameId(
id);
163 std::vector<double> binEdges;
166 gs::read_pod_vector(in, &binEdges);
167 gs::read_pod(in, &label);
168 gs::read_pod(in, &unif);
170 throw gs::IOReadFailure(
"In npstat::UHistoAxis::read: "
171 "input stream failure");
unsigned closestValidBin(double x) const
std::vector< double > binEdges_
int binNumber(double x) const
bool write(std::ostream &of) const
bool closeWithinTolerance(const double &a, const double &b, const double &tol)
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.
const T & max(const T &a, const T &b)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Determine if two doubles are within requested relative tolerance of each other.
double binCenter(const int binNum) const
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
volatile std::atomic< bool > shutdown_flag false
tuple size
Write out results.
const std::string & label() const