CMS 3D CMS Logo

HcalPolynomialFunctor.cc
Go to the documentation of this file.
1 #include <algorithm>
3 
5 
6 HcalPolynomialFunctor::HcalPolynomialFunctor() : shift_(0.0), xmin_(-DBL_MAX), xmax_(DBL_MAX), outOfRangeValue_(0.0) {}
7 
8 HcalPolynomialFunctor::HcalPolynomialFunctor(const std::vector<double>& coeffs,
9  const double shift,
10  const double xmin,
11  const double xmax,
12  const double outOfRangeValue)
13  : coeffs_(coeffs), shift_(shift), xmin_(xmin), xmax_(xmax), outOfRangeValue_(outOfRangeValue) {}
14 
15 double HcalPolynomialFunctor::operator()(const double x) const {
16  double result = outOfRangeValue_;
17  if (x >= xmin_ && x <= xmax_) {
18  result = 0.0;
19  if (!coeffs_.empty()) {
20  const double* a = &coeffs_[0];
21  const double y = x + shift_;
22  for (int deg = coeffs_.size() - 1; deg >= 0; --deg) {
23  result *= y;
24  result += a[deg];
25  }
26  }
27  }
28  return result;
29 }
30 
31 BOOST_CLASS_EXPORT_IMPLEMENT(HcalPolynomialFunctor)
double operator()(double x) const override
std::vector< double > coeffs_
double a
Definition: hdecay.h:119
static unsigned int const shift
float x