CMS 3D CMS Logo

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);
62  ar & abscissae_ & values_ & derivatives_;
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)
virtual bool isEqual(const AbsHcalFunctor &other) const override
friend class boost::serialization::access
std::vector< double > abscissae_
std::tuple< double, double, double > Triple
virtual double operator()(double x) const override
HcalCubicInterpolator approximateInverse() const
virtual double xmax() const override
std::vector< double > values_
std::vector< double > derivatives_
virtual double xmin() const override