File indexing completed on 2024-09-07 04:35:39
0001 #ifndef CondFormats_HcalObjects_HcalPiecewiseLinearFunctor_h
0002 #define CondFormats_HcalObjects_HcalPiecewiseLinearFunctor_h
0003
0004 #include <vector>
0005 #include <utility>
0006
0007 #include "CondFormats/HcalObjects/interface/AbsHcalFunctor.h"
0008
0009 #include "boost/serialization/access.hpp"
0010 #include "boost/serialization/version.hpp"
0011 #include "boost/serialization/vector.hpp"
0012
0013
0014
0015
0016
0017 class HcalPiecewiseLinearFunctor : public AbsHcalFunctor {
0018 public:
0019
0020 HcalPiecewiseLinearFunctor();
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 HcalPiecewiseLinearFunctor(const std::vector<std::pair<double, double> >& points,
0037 bool leftExtrapolationLinear,
0038 bool rightExtrapolationLinear);
0039
0040 inline ~HcalPiecewiseLinearFunctor() override {}
0041
0042 double operator()(double x) const override;
0043 double xmin() const override;
0044 double xmax() const override;
0045
0046
0047 bool isStrictlyMonotonous() const;
0048
0049
0050
0051 HcalPiecewiseLinearFunctor inverse() const;
0052
0053 protected:
0054 inline bool isEqual(const AbsHcalFunctor& other) const override {
0055 const HcalPiecewiseLinearFunctor& r = static_cast<const HcalPiecewiseLinearFunctor&>(other);
0056 return abscissae_ == r.abscissae_ && values_ == r.values_ &&
0057 leftExtrapolationLinear_ == r.leftExtrapolationLinear_ &&
0058 rightExtrapolationLinear_ == r.rightExtrapolationLinear_;
0059 }
0060
0061 private:
0062 std::vector<double> abscissae_;
0063 std::vector<double> values_;
0064 bool leftExtrapolationLinear_;
0065 bool rightExtrapolationLinear_;
0066
0067 friend class boost::serialization::access;
0068
0069 template <class Archive>
0070 inline void serialize(Archive& ar, unsigned ) {
0071 boost::serialization::base_object<AbsHcalFunctor>(*this);
0072 ar & abscissae_ & values_ & leftExtrapolationLinear_ & rightExtrapolationLinear_;
0073 }
0074 };
0075
0076 BOOST_CLASS_VERSION(HcalPiecewiseLinearFunctor, 1)
0077 BOOST_CLASS_EXPORT_KEY(HcalPiecewiseLinearFunctor)
0078
0079 #endif