CMS 3D CMS Logo

ScalingExponential.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_ScalingExponential_h_
2 #define CondFormats_HcalObjects_ScalingExponential_h_
3 
4 #include <cmath>
5 
6 #include "boost/serialization/access.hpp"
7 #include "boost/serialization/version.hpp"
8 #include <cstdint>
9 
11 public:
12  inline ScalingExponential() : p0_(0.0), p1_(0.0), linear_(0) {}
13 
14  inline ScalingExponential(const double p0, const double p1, const bool isLinear = false)
15  : p0_(p0), p1_(p1), linear_(isLinear) {}
16 
17  inline double operator()(const double x) const {
18  const double scale = linear_ ? p0_ * x + p1_ : p0_ * (1.0 - exp(-x / p1_));
19  return scale * x;
20  }
21 
22  inline bool operator==(const ScalingExponential& r) const {
23  return p0_ == r.p0_ && p1_ == r.p1_ && linear_ == r.linear_;
24  }
25 
26  inline bool operator!=(const ScalingExponential& r) const { return !(*this == r); }
27 
28 private:
29  double p0_;
30  double p1_;
31  uint8_t linear_;
32 
34 
35  template <class Archive>
36  inline void serialize(Archive& ar, unsigned /* version */) {
37  ar& p0_& p1_& linear_;
38  }
39 };
40 
41 BOOST_CLASS_VERSION(ScalingExponential, 1)
42 
43 #endif // CondFormats_HcalObjects_ScalingExponential_h_
bool operator==(const ScalingExponential &r) const
ScalingExponential(const double p0, const double p1, const bool isLinear=false)
friend class boost::serialization::access
bool operator!=(const ScalingExponential &r) const
double operator()(const double x) const
void serialize(Archive &ar, unsigned)