File indexing completed on 2024-09-07 04:35:39
0001 #ifndef CondFormats_HcalObjects_HcalLinearCompositionFunctor_h
0002 #define CondFormats_HcalObjects_HcalLinearCompositionFunctor_h
0003
0004 #include "FWCore/Utilities/interface/Exception.h"
0005
0006 #include "CondFormats/HcalObjects/interface/AbsHcalFunctor.h"
0007
0008 #include "boost/serialization/access.hpp"
0009 #include "boost/serialization/version.hpp"
0010 #include "boost/serialization/shared_ptr.hpp"
0011
0012
0013
0014
0015
0016
0017 class HcalLinearCompositionFunctor : public AbsHcalFunctor {
0018 public:
0019
0020 inline HcalLinearCompositionFunctor() : a_(0.0), b_(0.0) {}
0021
0022
0023 HcalLinearCompositionFunctor(std::shared_ptr<AbsHcalFunctor> p, double a, double b);
0024
0025 inline ~HcalLinearCompositionFunctor() override {}
0026
0027 double operator()(double x) const override;
0028
0029 inline double xmin() const override { return other_->xmin(); }
0030 inline double xmax() const override { return other_->xmax(); }
0031
0032 inline double a() const { return a_; }
0033 inline double b() const { return b_; }
0034
0035 protected:
0036 inline bool isEqual(const AbsHcalFunctor& other) const override {
0037 const HcalLinearCompositionFunctor& r = static_cast<const HcalLinearCompositionFunctor&>(other);
0038 return *other_ == *r.other_ && a_ == r.a_ && b_ == r.b_;
0039 }
0040
0041 private:
0042 std::shared_ptr<AbsHcalFunctor> other_;
0043 double a_;
0044 double b_;
0045
0046 friend class boost::serialization::access;
0047
0048 template <class Archive>
0049 inline void serialize(Archive& ar, unsigned ) {
0050 boost::serialization::base_object<AbsHcalFunctor>(*this);
0051
0052
0053
0054 #if BOOST_VERSION < 105600 || BOOST_VERSION > 105800
0055 ar & other_ & a_ & b_;
0056 #else
0057 throw cms::Exception(
0058 "HcalLinearCompositionFunctor can not be"
0059 " serialized with this version of boost");
0060 #endif
0061 }
0062 };
0063
0064 BOOST_CLASS_VERSION(HcalLinearCompositionFunctor, 1)
0065 BOOST_CLASS_EXPORT_KEY(HcalLinearCompositionFunctor)
0066
0067 #endif