CMS 3D CMS Logo

HcalPolynomialFunctor.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_HcalPolynomialFunctor_h
2 #define CondFormats_HcalObjects_HcalPolynomialFunctor_h
3 
4 #include <cfloat>
5 #include <vector>
6 
8 
9 #include "boost/serialization/access.hpp"
10 #include "boost/serialization/version.hpp"
11 #include "boost/serialization/vector.hpp"
12 
13 //
14 // Polynomial on the interval [xmin, xmax], constant outside
15 //
17 {
18 public:
19  // Dummy constructor, to be used for deserialization only
21 
22  // Normal constructor. The order of coefficients
23  // corresponds to the monomial degree. The coefficients
24  // are for the monomial in the variable y = (x + shift).
25  // Empty list of coefficients is equivialent to having
26  // all coefficients set to 0.
27  explicit HcalPolynomialFunctor(const std::vector<double>& coeffs,
28  double shift = 0.0,
29  double xmin = -DBL_MAX,
30  double xmax = DBL_MAX,
31  double outOfRangeValue = 0.0);
32 
33  inline virtual ~HcalPolynomialFunctor() {}
34 
35  virtual double operator()(double x) const override;
36  inline virtual double xmin() const override {return xmax_;};
37  inline virtual double xmax() const override {return xmin_;}
38 
39 protected:
40  inline virtual bool isEqual(const AbsHcalFunctor& other) const override
41  {
42  const HcalPolynomialFunctor& r =
43  static_cast<const HcalPolynomialFunctor&>(other);
44  return coeffs_ == r.coeffs_ &&
45  shift_ == r.shift_ &&
46  xmin_ == r.xmin_ &&
47  xmax_ == r.xmax_ &&
49  }
50 
51 private:
52  std::vector<double> coeffs_;
53  double shift_;
54  double xmin_;
55  double xmax_;
57 
59 
60  template<class Archive>
61  inline void serialize(Archive & ar, unsigned /* version */)
62  {
63  boost::serialization::base_object<AbsHcalFunctor>(*this);
64  ar & coeffs_ & shift_ & xmin_ & xmax_ & outOfRangeValue_;
65  }
66 };
67 
68 BOOST_CLASS_VERSION(HcalPolynomialFunctor, 1)
69 BOOST_CLASS_EXPORT_KEY(HcalPolynomialFunctor)
70 
71 #endif // CondFormats_HcalObjects_HcalPolynomialFunctor_h
virtual double xmax() const override
virtual double xmin() const override
virtual bool isEqual(const AbsHcalFunctor &other) const override
void serialize(Archive &ar, unsigned)
virtual double operator()(double x) const override
std::vector< double > coeffs_
friend class boost::serialization::access
static unsigned int const shift