CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
npstat::LinearMapper1d Class Reference

#include <LinearMapper1d.h>

Public Member Functions

double a () const
 
double b () const
 
LinearMapper1d inverse () const
 
 LinearMapper1d ()
 
 LinearMapper1d (const double ca, const double cb)
 
 LinearMapper1d (const double x0, const double y0, const double x1, const double y1)
 
double operator() (const double &x) const
 
LinearMapper1d operator* (const LinearMapper1d &r) const
 

Private Attributes

double a_
 
double b_
 

Detailed Description

Functor which performs linear mapping in 1-d

Definition at line 18 of file LinearMapper1d.h.

Constructor & Destructor Documentation

◆ LinearMapper1d() [1/3]

npstat::LinearMapper1d::LinearMapper1d ( )
inline

Default constructor builds an identity transformation

Definition at line 21 of file LinearMapper1d.h.

21 : a_(1.0), b_(0.0) {}

Referenced by inverse(), and operator*().

◆ LinearMapper1d() [2/3]

npstat::LinearMapper1d::LinearMapper1d ( const double  x0,
const double  y0,
const double  x1,
const double  y1 
)
inline

Transform definition from two points. The point at x0 is mapped into y0, the point at x1 is mapped into y1. The linear transformation is thus fully defined.

Definition at line 28 of file LinearMapper1d.h.

28  {
29  const double dx = x1 - x0;
30  if (!dx)
32  "In npstat::LinearMapper1d constructor: "
33  "invalid arguments (x0 == x1)");
34  a_ = (y1 - y0) / dx;
35  b_ = ((y0 + y1) - a_ * (x0 + x1)) / 2.0;
36  }

References a_, b_, PVValHelper::dx, testProducerWithPsetDescEmpty_cfi::x1, and testProducerWithPsetDescEmpty_cfi::y1.

◆ LinearMapper1d() [3/3]

npstat::LinearMapper1d::LinearMapper1d ( const double  ca,
const double  cb 
)
inline

Explicitly provide the transform coefficients as in y = ca*x + cb

Definition at line 39 of file LinearMapper1d.h.

39 : a_(ca), b_(cb) {}

Member Function Documentation

◆ a()

double npstat::LinearMapper1d::a ( ) const
inline

Get the linear coefficient of the transform

Definition at line 45 of file LinearMapper1d.h.

45 { return a_; }

References a_.

◆ b()

double npstat::LinearMapper1d::b ( ) const
inline

Get the transform constant

Definition at line 48 of file LinearMapper1d.h.

48 { return b_; }

References b_.

◆ inverse()

LinearMapper1d npstat::LinearMapper1d::inverse ( ) const
inline

Create the inverse transform

Definition at line 51 of file LinearMapper1d.h.

51  {
52  if (!a_)
54  "In npstat::LinearMapper1d::inverse: "
55  "mapping is not invertible");
56  return LinearMapper1d(1.0 / a_, -b_ / a_);
57  }

References a_, b_, and LinearMapper1d().

◆ operator()()

double npstat::LinearMapper1d::operator() ( const double &  x) const
inline

Perform the transformation

Definition at line 42 of file LinearMapper1d.h.

42 { return a_ * x + b_; }

References a_, and b_.

◆ operator*()

LinearMapper1d npstat::LinearMapper1d::operator* ( const LinearMapper1d r) const
inline

Sequence of two transforms: the one on the right is applied first

Definition at line 60 of file LinearMapper1d.h.

60 { return LinearMapper1d(a_ * r.a_, a_ * r.b_ + b_); }

References a_, b_, LinearMapper1d(), and alignCSCRings::r.

Member Data Documentation

◆ a_

double npstat::LinearMapper1d::a_
private

Definition at line 63 of file LinearMapper1d.h.

Referenced by a(), inverse(), LinearMapper1d(), operator()(), and operator*().

◆ b_

double npstat::LinearMapper1d::b_
private

Definition at line 64 of file LinearMapper1d.h.

Referenced by b(), inverse(), LinearMapper1d(), operator()(), and operator*().

DDAxes::x
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
npstat::NpstatInvalidArgument
Definition: NpstatException.h:38
npstat::LinearMapper1d::b_
double b_
Definition: LinearMapper1d.h:64
npstat::LinearMapper1d::a_
double a_
Definition: LinearMapper1d.h:63
alignCSCRings.r
r
Definition: alignCSCRings.py:93
npstat::LinearMapper1d::LinearMapper1d
LinearMapper1d()
Definition: LinearMapper1d.h:21
PVValHelper::dx
Definition: PVValidationHelpers.h:49