CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 public:
19  // Order: abscissa, desired value, derivative
20  typedef std::tuple<double, double, double> Triple;
21 
22  // Dummy constructor, to be used for deserialization only
24 
25  // Normal constructor from the set of interpolated points.
26  // The points will be sorted internally, so they can be
27  // given in arbitrary order.
28  explicit HcalCubicInterpolator(const std::vector<Triple>& points);
29 
30  inline ~HcalCubicInterpolator() override {}
31 
32  double operator()(double x) const override;
33  double xmin() const override;
34  double xmax() const override;
35 
36  // Cubic approximation to the inverse curve (note, not the real
37  // solution of the direct cubic equation). Use at your own risc.
39 
40 protected:
41  inline bool isEqual(const AbsHcalFunctor& other) const override {
42  const HcalCubicInterpolator& r = static_cast<const HcalCubicInterpolator&>(other);
43  return abscissae_ == r.abscissae_ && values_ == r.values_ && derivatives_ == r.derivatives_;
44  }
45 
46 private:
47  std::vector<double> abscissae_;
48  std::vector<double> values_;
49  std::vector<double> derivatives_;
50 
52 
53  template <class Archive>
54  inline void serialize(Archive& ar, unsigned /* version */) {
55  boost::serialization::base_object<AbsHcalFunctor>(*this);
57  }
58 };
59 
60 BOOST_CLASS_VERSION(HcalCubicInterpolator, 1)
61 BOOST_CLASS_EXPORT_KEY(HcalCubicInterpolator)
62 
63 #endif // CondFormats_HcalObjects_HcalCubicInterpolator_h
void serialize(Archive &ar, unsigned)
friend class boost::serialization::access
std::tuple< double, double, double > Triple
double xmax() const override
std::vector< double > abscissae_
double xmin() const override
bool isEqual(const AbsHcalFunctor &other) const override
HcalCubicInterpolator approximateInverse() const
std::vector< double > values_
double operator()(double x) const override
std::vector< double > derivatives_