CMS 3D CMS Logo

HcalPiecewiseLinearFunctor.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_HcalPiecewiseLinearFunctor_h
2 #define CondFormats_HcalObjects_HcalPiecewiseLinearFunctor_h
3 
4 #include <vector>
5 #include <utility>
6 
8 
9 #include "boost/serialization/access.hpp"
10 #include "boost/serialization/version.hpp"
11 #include "boost/serialization/vector.hpp"
12 
13 //
14 // Simple piecewise linear interpolator.
15 // Will invert the curve if needed.
16 //
18 public:
19  // Dummy constructor, to be used for deserialization only
21 
22  // Abscissae are the first elements of the pairs.
23  // Interpolated values are the second elements.
24  // The order of the points is arbitrary -- they will
25  // be sorted internally anyway in the order of
26  // increasing abscissae.
27  //
28  // Argument "leftExtrapolationLinear" determines
29  // whether the extrapolation to the left of the smallest
30  // abscissa is going to be constant or linear.
31  //
32  // Argument "rightExtrapolationLinear" determines
33  // whether the extrapolation to the right of the largest
34  // abscissa is going to be constant or linear.
35  //
36  HcalPiecewiseLinearFunctor(const std::vector<std::pair<double, double> >& points,
39 
40  inline ~HcalPiecewiseLinearFunctor() override {}
41 
42  double operator()(double x) const override;
43  double xmin() const override;
44  double xmax() const override;
45 
46  // Check if the interpolated values are strictly increasing or decreasing
47  bool isStrictlyMonotonous() const;
48 
49  // For strictly monotonous functors,
50  // we will be able to generate the inverse
52 
53 protected:
54  inline bool isEqual(const AbsHcalFunctor& other) const override {
55  const HcalPiecewiseLinearFunctor& r = static_cast<const HcalPiecewiseLinearFunctor&>(other);
56  return abscissae_ == r.abscissae_ && values_ == r.values_ &&
57  leftExtrapolationLinear_ == r.leftExtrapolationLinear_ &&
58  rightExtrapolationLinear_ == r.rightExtrapolationLinear_;
59  }
60 
61 private:
62  std::vector<double> abscissae_;
63  std::vector<double> values_;
66 
68 
69  template <class Archive>
70  inline void serialize(Archive& ar, unsigned /* version */) {
71  boost::serialization::base_object<AbsHcalFunctor>(*this);
73  }
74 };
75 
76 BOOST_CLASS_VERSION(HcalPiecewiseLinearFunctor, 1)
77 BOOST_CLASS_EXPORT_KEY(HcalPiecewiseLinearFunctor)
78 
79 #endif // CondFormats_HcalObjects_HcalPiecewiseLinearFunctor_h
HLT_2018_cff.points
points
Definition: HLT_2018_cff.py:20125
AbsHcalFunctor
Definition: AbsHcalFunctor.h:19
HcalPiecewiseLinearFunctor::abscissae_
std::vector< double > abscissae_
Definition: HcalPiecewiseLinearFunctor.h:62
HcalPiecewiseLinearFunctor::rightExtrapolationLinear_
bool rightExtrapolationLinear_
Definition: HcalPiecewiseLinearFunctor.h:65
HcalPiecewiseLinearFunctor::HcalPiecewiseLinearFunctor
HcalPiecewiseLinearFunctor()
Definition: HcalPiecewiseLinearFunctor.cc:11
HcalPiecewiseLinearFunctor::isStrictlyMonotonous
bool isStrictlyMonotonous() const
Definition: HcalPiecewiseLinearFunctor.cc:61
DDAxes::x
HcalPiecewiseLinearFunctor
Definition: HcalPiecewiseLinearFunctor.h:17
HcalPiecewiseLinearFunctor::values_
std::vector< double > values_
Definition: HcalPiecewiseLinearFunctor.h:63
HcalPiecewiseLinearFunctor::leftExtrapolationLinear_
bool leftExtrapolationLinear_
Definition: HcalPiecewiseLinearFunctor.h:64
trackingPlots.other
other
Definition: trackingPlots.py:1465
HcalPiecewiseLinearFunctor::xmin
double xmin() const override
Definition: HcalPiecewiseLinearFunctor.cc:82
mixed_calib_calo_ttbar_result.leftExtrapolationLinear
leftExtrapolationLinear
Definition: mixed_calib_calo_ttbar_result.py:10
HcalPiecewiseLinearFunctor::inverse
HcalPiecewiseLinearFunctor inverse() const
Definition: HcalPiecewiseLinearFunctor.cc:65
HcalPiecewiseLinearFunctor::serialize
void serialize(Archive &ar, unsigned)
Definition: HcalPiecewiseLinearFunctor.h:70
AbsHcalFunctor.h
HcalPiecewiseLinearFunctor::~HcalPiecewiseLinearFunctor
~HcalPiecewiseLinearFunctor() override
Definition: HcalPiecewiseLinearFunctor.h:40
HcalPiecewiseLinearFunctor::isEqual
bool isEqual(const AbsHcalFunctor &other) const override
Definition: HcalPiecewiseLinearFunctor.h:54
alignCSCRings.r
r
Definition: alignCSCRings.py:93
mixed_calib_calo_ttbar_result.rightExtrapolationLinear
rightExtrapolationLinear
Definition: mixed_calib_calo_ttbar_result.py:11
HcalPiecewiseLinearFunctor::xmax
double xmax() const override
Definition: HcalPiecewiseLinearFunctor.cc:89
HcalPiecewiseLinearFunctor::access
friend class boost::serialization::access
Definition: HcalPiecewiseLinearFunctor.h:67
HcalPiecewiseLinearFunctor::operator()
double operator()(double x) const override
Definition: HcalPiecewiseLinearFunctor.cc:35