test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 x0, const double y0, const double x1, const double y1)
 
 LinearMapper1d (const double ca, const double cb)
 
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

npstat::LinearMapper1d::LinearMapper1d ( )
inline

Default constructor builds an identity transformation

Definition at line 22 of file LinearMapper1d.h.

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

22 : a_(1.0), b_(0.0) {}
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 29 of file LinearMapper1d.h.

References a_, and b_.

31  {
32  const double dx = x1 - x0;
33  if (!dx) throw npstat::NpstatInvalidArgument(
34  "In npstat::LinearMapper1d constructor: "
35  "invalid arguments (x0 == x1)");
36  a_ = (y1 - y0)/dx;
37  b_ = ((y0 + y1) - a_*(x0 + x1))/2.0;
38  }
npstat::LinearMapper1d::LinearMapper1d ( const double  ca,
const double  cb 
)
inline

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

Definition at line 41 of file LinearMapper1d.h.

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

Member Function Documentation

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

Get the linear coefficient of the transform

Definition at line 48 of file LinearMapper1d.h.

References a_.

48 {return a_;}
double npstat::LinearMapper1d::b ( ) const
inline

Get the transform constant

Definition at line 51 of file LinearMapper1d.h.

References b_.

51 {return b_;}
LinearMapper1d npstat::LinearMapper1d::inverse ( ) const
inline

Create the inverse transform

Definition at line 54 of file LinearMapper1d.h.

References a_, b_, and LinearMapper1d().

Referenced by npstat::densityScanHistoMap().

55  {
57  "In npstat::LinearMapper1d::inverse: "
58  "mapping is not invertible");
59  return LinearMapper1d(1.0/a_, -b_/a_);
60  }
double npstat::LinearMapper1d::operator() ( const double &  x) const
inline

Perform the transformation

Definition at line 45 of file LinearMapper1d.h.

References a_, and b_.

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

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

Definition at line 63 of file LinearMapper1d.h.

References a_, b_, and LinearMapper1d().

64  {
65  return LinearMapper1d(a_*r.a_, a_*r.b_ + b_);
66  }

Member Data Documentation

double npstat::LinearMapper1d::a_
private

Definition at line 69 of file LinearMapper1d.h.

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

double npstat::LinearMapper1d::b_
private

Definition at line 70 of file LinearMapper1d.h.

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