6 #include "Alignment/Geners/interface/binaryIO.hh"
7 #include "Alignment/Geners/interface/IOException.hh"
14 : min_(min), max_(max), label_(label ? label :
""), npt_(nCoords) {
15 if (!(
npt_ > 1U &&
npt_ < UINT_MAX / 2U - 1U))
17 "In npstat::UniformAxis constructor: "
18 "number of points is out of range");
24 "In npstat::UniformAxis constructor: "
25 "minimum and maximum must be distinct");
30 return std::pair<unsigned, double>(0U, 1.0);
32 return std::pair<unsigned, double>(
npt_ - 2U, 0.0);
34 unsigned binnum =
static_cast<unsigned>(floor((x -
min_) /
bw_));
35 if (binnum >
npt_ - 2U)
37 double w = binnum + 1.0 - (x -
min_) /
bw_;
42 return std::pair<unsigned, double>(binnum,
w);
48 return std::pair<unsigned, double>(0U, 1.0 - (x -
min_) /
bw_);
50 return std::pair<unsigned, double>(
npt_ - 2U, (
max_ - x) /
bw_);
52 unsigned binnum =
static_cast<unsigned>(floor((x -
min_) /
bw_));
53 if (binnum >
npt_ - 2U)
55 double w = binnum + 1.0 - (x -
min_) /
bw_;
60 return std::pair<unsigned, double>(binnum,
w);
65 std::vector<double> vec;
67 const unsigned nptm1 =
npt_ - 1U;
68 for (
unsigned i = 0;
i < nptm1; ++
i)
93 gs::write_pod(of,
min_);
94 gs::write_pod(of,
max_);
96 gs::write_pod(of,
npt_);
101 static const gs::ClassId current(gs::ClassId::makeId<UniformAxis>());
102 current.ensureSameId(
id);
104 double min = 0.0,
max = 0.0;
108 gs::read_pod(in, &min);
109 gs::read_pod(in, &
max);
110 gs::read_pod(in, &label);
111 gs::read_pod(in, &nBins);
116 throw gs::IOReadFailure(
117 "In npstat::UniformAxis::read: "
118 "input stream failure");
bool closeWithinTolerance(const double &a, const double &b, const double &tol)
Exceptions for the npstat namespace.
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Determine if two doubles are within requested relative tolerance of each other.