CMS 3D CMS Logo

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