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 {
12 public:
13  // Dummy constructor, to be used for deserialization only
15 
16  // The vector of values must have at least two elements
17  // (for xmin and xmax).
18  //
19  // Argument "leftExtrapolationLinear" determines
20  // whether the extrapolation to the left of xmin
21  // is going to be constant or linear.
22  //
23  // Argument "rightExtrapolationLinear" determines
24  // whether the extrapolation to the right of xmax
25  // is going to be constant or linear.
26  //
27  HcalInterpolatedTableFunctor(const std::vector<double>& values,
28  double xmin, double xmax,
31 
32  inline virtual ~HcalInterpolatedTableFunctor() {}
33 
34  virtual double operator()(double x) const override;
35  inline virtual double xmin() const override {return xmin_;}
36  inline virtual 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 virtual bool isEqual(const AbsHcalFunctor& other) const override
47  {
49  static_cast<const HcalInterpolatedTableFunctor&>(other);
50  return values_ == r.values_ &&
51  xmin_ == r.xmin_ && xmax_ == r.xmax_ &&
54  }
55 
56 private:
57  std::vector<double> values_;
58  double xmin_;
59  double xmax_;
62 
64 
65  template<class Archive>
66  inline void serialize(Archive & ar, unsigned /* version */)
67  {
68  boost::serialization::base_object<AbsHcalFunctor>(*this);
69  ar & values_ & xmin_ & xmax_
70  & leftExtrapolationLinear_
72  }
73 };
74 
75 BOOST_CLASS_VERSION(HcalInterpolatedTableFunctor, 1)
76 BOOST_CLASS_EXPORT_KEY(HcalInterpolatedTableFunctor)
77 
78 #endif // CondFormats_HcalObjects_HcalInterpolatedTableFunctor_h
virtual double xmax() const override
virtual bool isEqual(const AbsHcalFunctor &other) const override
HcalPiecewiseLinearFunctor inverse() const
void serialize(Archive &ar, unsigned)
virtual double xmin() const override
friend class boost::serialization::access
virtual double operator()(double x) const override