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 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
AbsHcalFunctor
Definition: AbsHcalFunctor.h:19
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21449
HcalCubicInterpolator::abscissae_
std::vector< double > abscissae_
Definition: HcalCubicInterpolator.h:47
DDAxes::x
HcalCubicInterpolator::approximateInverse
HcalCubicInterpolator approximateInverse() const
Definition: HcalCubicInterpolator.cc:74
HcalCubicInterpolator::derivatives_
std::vector< double > derivatives_
Definition: HcalCubicInterpolator.h:49
trackingPlots.other
other
Definition: trackingPlots.py:1460
HcalCubicInterpolator::~HcalCubicInterpolator
~HcalCubicInterpolator() override
Definition: HcalCubicInterpolator.h:30
HcalCubicInterpolator::xmin
double xmin() const override
Definition: HcalCubicInterpolator.cc:60
HcalCubicInterpolator
Definition: HcalCubicInterpolator.h:17
AbsHcalFunctor.h
HcalCubicInterpolator::Triple
std::tuple< double, double, double > Triple
Definition: HcalCubicInterpolator.h:20
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HcalCubicInterpolator::isEqual
bool isEqual(const AbsHcalFunctor &other) const override
Definition: HcalCubicInterpolator.h:41
HcalCubicInterpolator::serialize
void serialize(Archive &ar, unsigned)
Definition: HcalCubicInterpolator.h:54
HcalCubicInterpolator::xmax
double xmax() const override
Definition: HcalCubicInterpolator.cc:67
HcalCubicInterpolator::operator()
double operator()(double x) const override
Definition: HcalCubicInterpolator.cc:31
HcalCubicInterpolator::access
friend class boost::serialization::access
Definition: HcalCubicInterpolator.h:51
HcalCubicInterpolator::values_
std::vector< double > values_
Definition: HcalCubicInterpolator.h:48
HcalCubicInterpolator::HcalCubicInterpolator
HcalCubicInterpolator()
Definition: HcalCubicInterpolator.cc:6