File indexing completed on 2024-04-06 12:02:16
0001 #include <algorithm>
0002 #include "FWCore/Utilities/interface/Exception.h"
0003
0004 #include "CondFormats/HcalObjects/interface/HcalPolynomialFunctor.h"
0005
0006 HcalPolynomialFunctor::HcalPolynomialFunctor() : shift_(0.0), xmin_(-DBL_MAX), xmax_(DBL_MAX), outOfRangeValue_(0.0) {}
0007
0008 HcalPolynomialFunctor::HcalPolynomialFunctor(const std::vector<double>& coeffs,
0009 const double shift,
0010 const double xmin,
0011 const double xmax,
0012 const double outOfRangeValue)
0013 : coeffs_(coeffs), shift_(shift), xmin_(xmin), xmax_(xmax), outOfRangeValue_(outOfRangeValue) {}
0014
0015 double HcalPolynomialFunctor::operator()(const double x) const {
0016 double result = outOfRangeValue_;
0017 if (x >= xmin_ && x <= xmax_) {
0018 result = 0.0;
0019 if (!coeffs_.empty()) {
0020 const double* a = &coeffs_[0];
0021 const double y = x + shift_;
0022 for (int deg = coeffs_.size() - 1; deg >= 0; --deg) {
0023 result *= y;
0024 result += a[deg];
0025 }
0026 }
0027 }
0028 return result;
0029 }
0030
0031 BOOST_CLASS_EXPORT_IMPLEMENT(HcalPolynomialFunctor)