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/cstdint.hpp"
7 #include "boost/serialization/access.hpp"
8 #include "boost/serialization/version.hpp"
9 
11 {
12 public:
13  inline ScalingExponential() : p0_(0.0), p1_(0.0), linear_(0) {}
14 
15  inline ScalingExponential(const double p0, const double p1,
16  const bool isLinear=false)
17  : p0_(p0), p1_(p1), linear_(isLinear) {}
18 
19  inline double operator()(const double x) const
20  {
21  const double scale = linear_ ? p0_*x + p1_ : p0_*(1.0 - exp(-x/p1_));
22  return scale*x;
23  }
24 
25  inline bool operator==(const ScalingExponential& r) const
26  {return p0_ == r.p0_ && p1_ == r.p1_ && linear_ == r.linear_;}
27 
28  inline bool operator!=(const ScalingExponential& r) const
29  {return !(*this == r);}
30 
31 private:
32  double p0_;
33  double p1_;
34  uint8_t linear_;
35 
37 
38  template<class Archive>
39  inline void serialize(Archive & ar, unsigned /* version */)
40  {
41  ar & p0_ & p1_ & linear_;
42  }
43 };
44 
45 BOOST_CLASS_VERSION(ScalingExponential, 1)
46 
47 #endif // CondFormats_HcalObjects_ScalingExponential_h_
ScalingExponential(const double p0, const double p1, const bool isLinear=false)
bool operator==(const ScalingExponential &r) const
friend class boost::serialization::access
double operator()(const double x) const
void serialize(Archive &ar, unsigned)
bool operator!=(const ScalingExponential &r) const
double p1[4]
Definition: TauolaWrapper.h:89