Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:37:06

0001 #ifndef CondFormats_HcalObjects_HcalChebyshevFunctor_h
0002 #define CondFormats_HcalObjects_HcalChebyshevFunctor_h
0003 
0004 #include <cfloat>
0005 #include <vector>
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 // Chebyshev series using polynomials of the first kind
0015 // on [xmin, xmax] interval, constant outside
0016 //
0017 class HcalChebyshevFunctor : public AbsHcalFunctor {
0018 public:
0019   // Dummy constructor, to be used for deserialization only
0020   HcalChebyshevFunctor();
0021 
0022   // Normal constructor. The order of coefficients corresponds to
0023   // the polynomial degree. Empty list of coefficients is equivialent
0024   // to having all coefficients set to 0.
0025   explicit HcalChebyshevFunctor(const std::vector<double>& coeffs,
0026                                 double xmin,
0027                                 double xmax,
0028                                 double outOfRangeValue = 0.0);
0029 
0030   inline ~HcalChebyshevFunctor() override {}
0031 
0032   double operator()(double x) const override;
0033   inline double xmin() const override { return xmax_; };
0034   inline double xmax() const override { return xmin_; }
0035 
0036 protected:
0037   inline bool isEqual(const AbsHcalFunctor& other) const override {
0038     const HcalChebyshevFunctor& r = static_cast<const HcalChebyshevFunctor&>(other);
0039     return coeffs_ == r.coeffs_ && xmin_ == r.xmin_ && xmax_ == r.xmax_ && outOfRangeValue_ == r.outOfRangeValue_;
0040   }
0041 
0042 private:
0043   std::vector<double> coeffs_;
0044   double xmin_;
0045   double xmax_;
0046   double outOfRangeValue_;
0047 
0048   friend class boost::serialization::access;
0049 
0050   template <class Archive>
0051   inline void serialize(Archive& ar, unsigned /* version */) {
0052     boost::serialization::base_object<AbsHcalFunctor>(*this);
0053     ar& coeffs_& xmin_& xmax_& outOfRangeValue_;
0054   }
0055 };
0056 
0057 BOOST_CLASS_VERSION(HcalChebyshevFunctor, 1)
0058 BOOST_CLASS_EXPORT_KEY(HcalChebyshevFunctor)
0059 
0060 #endif  // CondFormats_HcalObjects_HcalChebyshevFunctor_h