CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalCubicInterpolator.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_HcalCubicInterpolator_h
2 #define CondFormats_HcalObjects_HcalCubicInterpolator_h
3 
4 #include <vector>
5 #include <tuple>
6 
8 
9 #include "boost/serialization/access.hpp"
10 #include "boost/serialization/version.hpp"
11 #include "boost/serialization/vector.hpp"
12 
13 //
14 // Cubic Hermite spline interpolator in 1-d. See, for example,
15 // http://en.wikipedia.org/wiki/Cubic_Hermite_spline
16 //
18 {
19 public:
20  // Order: abscissa, desired value, derivative
21  typedef std::tuple<double,double,double> Triple;
22 
23  // Dummy constructor, to be used for deserialization only
25 
26  // Normal constructor from the set of interpolated points.
27  // The points will be sorted internally, so they can be
28  // given in arbitrary order.
29  explicit HcalCubicInterpolator(const std::vector<Triple>& points);
30 
31  inline virtual ~HcalCubicInterpolator() {}
32 
33  virtual double operator()(double x) const override;
34  virtual double xmin() const override;
35  virtual double xmax() const override;
36 
37  // Cubic approximation to the inverse curve (note, not the real
38  // solution of the direct cubic equation). Use at your own risc.
40 
41 protected:
42  inline virtual bool isEqual(const AbsHcalFunctor& other) const override
43  {
44  const HcalCubicInterpolator& r =
45  static_cast<const HcalCubicInterpolator&>(other);
46  return abscissae_ == r.abscissae_ &&
47  values_ == r.values_ &&
49  }
50 
51 private:
52  std::vector<double> abscissae_;
53  std::vector<double> values_;
54  std::vector<double> derivatives_;
55 
57 
58  template<class Archive>
59  inline void serialize(Archive & ar, unsigned /* version */)
60  {
61  boost::serialization::base_object<AbsHcalFunctor>(*this);
63  }
64 };
65 
66 BOOST_CLASS_VERSION(HcalCubicInterpolator, 1)
67 BOOST_CLASS_EXPORT_KEY(HcalCubicInterpolator)
68 
69 #endif // CondFormats_HcalObjects_HcalCubicInterpolator_h
void serialize(Archive &ar, unsigned)
friend class boost::serialization::access
virtual double xmax() const override
std::vector< double > abscissae_
std::tuple< double, double, double > Triple
virtual bool isEqual(const AbsHcalFunctor &other) const override
virtual double xmin() const override
HcalCubicInterpolator approximateInverse() const
std::vector< double > values_
virtual double operator()(double x) const override
std::vector< double > derivatives_