CMS 3D CMS Logo

HcalChebyshevFunctor.cc
Go to the documentation of this file.
2 
4 
5 HcalChebyshevFunctor::HcalChebyshevFunctor() : xmin_(-1.0), xmax_(1.0), outOfRangeValue_(0.0) {}
6 
7 HcalChebyshevFunctor::HcalChebyshevFunctor(const std::vector<double>& coeffs,
8  const double xmin,
9  const double xmax,
10  const double outOfRangeValue)
11  : coeffs_(coeffs), xmin_(xmin), xmax_(xmax), outOfRangeValue_(outOfRangeValue) {
12  if (xmin_ >= xmax_)
13  throw cms::Exception("In HcalChebyshevFunctor constructor: invalid interval specification");
14 }
15 
16 double HcalChebyshevFunctor::operator()(const double y) const {
17  if (!(y >= xmin_ && y <= xmax_))
18  return outOfRangeValue_;
19 
20  if (coeffs_.empty())
21  return 0.0;
22 
23  const double x = 2.0 * (y - xmin_) / (xmax_ - xmin_) - 1.0;
24  const double* a = &coeffs_[0];
25  const double twox = 2.0 * x;
26 
27  // Clenshaw recursion
28  double rp2 = 0.0, rp1 = 0.0, r = 0.0;
29  for (unsigned k = coeffs_.size() - 1; k > 0U; --k) {
30  r = twox * rp1 - rp2 + a[k];
31  rp2 = rp1;
32  rp1 = r;
33  }
34  return x * rp1 - rp2 + a[0];
35 }
36 
37 BOOST_CLASS_EXPORT_IMPLEMENT(HcalChebyshevFunctor)
double xmin() const override
double operator()(double x) const override
double xmax() const override
double a
Definition: hdecay.h:119
std::vector< double > coeffs_