CMS 3D CMS Logo

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