CMS 3D CMS Logo

HcalInterpolatedTableFunctor.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_HcalInterpolatedTableFunctor_h
2 #define CondFormats_HcalObjects_HcalInterpolatedTableFunctor_h
3 
5 
6 //
7 // Simple linear interpolator from equidistant points.
8 // Need O(1) operations no matter how many points are used.
9 //
11 public:
12  // Dummy constructor, to be used for deserialization only
14 
15  // The vector of values must have at least two elements
16  // (for xmin and xmax).
17  //
18  // Argument "leftExtrapolationLinear" determines
19  // whether the extrapolation to the left of xmin
20  // is going to be constant or linear.
21  //
22  // Argument "rightExtrapolationLinear" determines
23  // whether the extrapolation to the right of xmax
24  // is going to be constant or linear.
25  //
26  HcalInterpolatedTableFunctor(const std::vector<double>& values,
27  double xmin,
28  double xmax,
31 
32  inline ~HcalInterpolatedTableFunctor() override {}
33 
34  double operator()(double x) const override;
35  inline double xmin() const override { return xmin_; }
36  inline double xmax() const override { return xmax_; }
37 
38  // Check if the interpolated values are strictly increasing or decreasing
39  bool isStrictlyMonotonous() const;
40 
41  // For strictly monotonous functors,
42  // we will be able to generate the inverse
44 
45 protected:
46  inline bool isEqual(const AbsHcalFunctor& other) const override {
48  return values_ == r.values_ && xmin_ == r.xmin_ && xmax_ == r.xmax_ &&
49  leftExtrapolationLinear_ == r.leftExtrapolationLinear_ &&
50  rightExtrapolationLinear_ == r.rightExtrapolationLinear_;
51  }
52 
53 private:
54  std::vector<double> values_;
55  double xmin_;
56  double xmax_;
59 
61 
62  template <class Archive>
63  inline void serialize(Archive& ar, unsigned /* version */) {
64  boost::serialization::base_object<AbsHcalFunctor>(*this);
66  }
67 };
68 
69 BOOST_CLASS_VERSION(HcalInterpolatedTableFunctor, 1)
70 BOOST_CLASS_EXPORT_KEY(HcalInterpolatedTableFunctor)
71 
72 #endif // CondFormats_HcalObjects_HcalInterpolatedTableFunctor_h
void serialize(Archive &ar, unsigned)
friend class boost::serialization::access
bool isEqual(const AbsHcalFunctor &other) const override
double operator()(double x) const override
HcalPiecewiseLinearFunctor inverse() const