CMS 3D CMS Logo

LookupTable2d.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <cassert>
3 
5 
6 namespace fftjetcms {
8  unsigned nx, double xmin, double xmax, unsigned ny, double ymin, double ymax, const std::vector<double>& data)
9  : data_(data),
10  nx_(nx),
11  ny_(ny),
12  xmin_(xmin),
13  xmax_(xmax),
14  ymin_(ymin),
15  ymax_(ymax),
16  bwx_((xmax - xmin) / nx),
17  bwy_((ymax - ymin) / ny) {
18  assert(nx_);
19  assert(ny_);
20  assert(xmin_ < xmax_);
21  assert(ymin_ < ymax_);
22  assert(data_.size() == nx_ * ny_);
23  }
24 
25  double LookupTable2d::closest(const double x, const double y) const {
26  const unsigned ix =
27  x <= xmin_ ? 0U : x >= xmax_ - bwx_ / 2.0 ? nx_ - 1U : static_cast<unsigned>((x - xmin_) / bwx_);
28  const unsigned iy =
29  y <= ymin_ ? 0U : y >= ymax_ - bwy_ / 2.0 ? ny_ - 1U : static_cast<unsigned>((y - ymin_) / bwy_);
30  return data_[ix * ny_ + iy];
31  }
32 } // namespace fftjetcms
double closest(double x, double y) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::vector< double > data_
Definition: LookupTable2d.h:28