CMS 3D CMS Logo

CircularMapper1d.h
Go to the documentation of this file.
1 #ifndef NPSTAT_CIRCULARMAPPER1D_HH_
2 #define NPSTAT_CIRCULARMAPPER1D_HH_
3 
14 #include <cmath>
15 
17 
18 namespace npstat {
24  {
25  public:
26  inline CircularMapper1d() : a_(1.0), b_(0.0), period_(2.0*M_PI) {}
27 
28  inline CircularMapper1d(const double ca, const double cb,
29  const double cperiod)
30  : a_(ca), b_(cb), period_(std::abs(cperiod)) {check();}
31 
32  inline CircularMapper1d(const LinearMapper1d& mapper,
33  const double cperiod)
34  : a_(mapper.a()), b_(mapper.b()),
35  period_(std::abs(cperiod)) {check();}
36 
37  inline double operator()(const double& x) const
38  {
39  double value = a_*x + b_;
40  value -= period_*floor(value/period_);
41  if (value > period_/2.0)
42  value -= period_;
43  return value;
44  }
45 
46  inline double a() const {return a_;}
47  inline double b() const {return b_;}
48  inline double period() const {return period_;}
50  {return LinearMapper1d(a_, b_);}
51 
52  private:
53  inline void check()
54  {
56  "In npstat::CircularMapper1d constructor: "
57  "invalid period argument (can not be 0)");
58  }
59 
60  double a_;
61  double b_;
62  double period_;
63  };
64 }
65 
66 #endif // NPSTAT_CIRCULARMAPPER1D_HH_
67 
CircularMapper1d(const double ca, const double cb, const double cperiod)
double operator()(const double &x) const
Linear transformation functor.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: value.py:1
#define M_PI
CircularMapper1d(const LinearMapper1d &mapper, const double cperiod)
LinearMapper1d linearMapper() const