CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
Grid1D Class Reference

#include <Grid1D.h>

Public Types

typedef float Scalar
 

Public Member Functions

int cells () const
 
Scalar closestNode (Scalar a) const
 
 Grid1D ()
 
 Grid1D (Scalar lower, Scalar upper, int nodes)
 
int index (Scalar a, Scalar &f) const
 
int index (Scalar a) const
 returns valid index, or -1 if the value is outside range +/- one cell. More...
 
bool inRange (int i) const
 
Scalar lower () const
 
Scalar node (int i) const
 
int nodes () const
 
void normalize (int &ind, Scalar &f) const
 
Scalar step () const
 
Scalar upper () const
 

Private Attributes

int edges_
 
Scalar lower_
 
Scalar stepinv_
 
Scalar upper_
 

Detailed Description

Definition at line 7 of file Grid1D.h.

Member Typedef Documentation

typedef float Grid1D::Scalar

Definition at line 9 of file Grid1D.h.

Constructor & Destructor Documentation

Grid1D::Grid1D ( )
inline

Definition at line 12 of file Grid1D.h.

12 {}
Grid1D::Grid1D ( Scalar  lower,
Scalar  upper,
int  nodes 
)
inline

Definition at line 14 of file Grid1D.h.

14  : lower_(lower), upper_(upper), edges_(nodes - 2) {
15  stepinv_ = (nodes - 1) / (upper - lower);
16  }
int edges_
Definition: Grid1D.h:69
Scalar stepinv_
Definition: Grid1D.h:66
int nodes() const
Definition: Grid1D.h:21
Scalar lower() const
Definition: Grid1D.h:19
Scalar upper_
Definition: Grid1D.h:68
Scalar lower_
Definition: Grid1D.h:67
Scalar upper() const
Definition: Grid1D.h:20

Member Function Documentation

int Grid1D::cells ( ) const
inline

Definition at line 22 of file Grid1D.h.

22 { return edges_ + 1; }
int edges_
Definition: Grid1D.h:69
Scalar Grid1D::closestNode ( Scalar  a) const
inline

Definition at line 46 of file Grid1D.h.

References b, HltBtagPostValidation_cff::c, f, SiStripPI::max, min(), class-composition::nodes, and createJobs::tmp.

46  {
47  Scalar b = (a - lower()) / step();
48  Scalar c = floor(b);
49  Scalar tmp = (b - c < 0.5) ? std::max(c, 0.f) : std::min(c + 1.f, static_cast<Scalar>(nodes() - 1));
50  return tmp * step() + lower();
51  }
Scalar step() const
Definition: Grid1D.h:18
float Scalar
Definition: Grid1D.h:9
int nodes() const
Definition: Grid1D.h:21
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
Scalar lower() const
Definition: Grid1D.h:19
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
tmp
align.sh
Definition: createJobs.py:716
int Grid1D::index ( Scalar  a,
Scalar f 
) const
inline

Definition at line 29 of file Grid1D.h.

References b.

Referenced by BeautifulSoup.PageElement::insert(), LinearGridInterpolator3D::interpolate(), and RectangularCylindricalMFGrid::uncheckedValueInTesla().

29  {
30  Scalar b;
31  f = modff((a - lower()) * stepinv_, &b);
32  return b;
33  }
float Scalar
Definition: Grid1D.h:9
Scalar stepinv_
Definition: Grid1D.h:66
double f[11][100]
Scalar lower() const
Definition: Grid1D.h:19
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
int Grid1D::index ( Scalar  a) const
inline

returns valid index, or -1 if the value is outside range +/- one cell.

Definition at line 54 of file Grid1D.h.

References postprocess-scan-build::cells, SiStripPI::max, and min().

Referenced by BeautifulSoup.PageElement::insert().

54  {
55  int ind = static_cast<int>((a - lower()) / step());
56  // FIXME: this causes an exception to be thrown later. Should be tested
57  // more carefully before release
58  // if (ind < -1 || ind > cells()) {
59  // std::cout << "**** ind = " << ind << " cells: " << cells() << std::endl;
60  // return -1;
61  // }
62  return std::max(0, std::min(cells() - 1, ind));
63  }
Scalar step() const
Definition: Grid1D.h:18
int cells() const
Definition: Grid1D.h:22
T min(T a, T b)
Definition: MathUtil.h:58
Scalar lower() const
Definition: Grid1D.h:19
double a
Definition: hdecay.h:119
bool Grid1D::inRange ( int  i) const
inline

Definition at line 26 of file Grid1D.h.

26 { return i >= 0 && i <= edges_; }
int edges_
Definition: Grid1D.h:69
Scalar Grid1D::lower ( ) const
inline
Scalar Grid1D::node ( int  i) const
inline

Definition at line 24 of file Grid1D.h.

Referenced by Grid3D::dump(), grid1d_t(), LinearGridInterpolator3D::interpolate(), and RectangularCylindricalMFGrid::uncheckedValueInTesla().

24 { return i * step() + lower(); }
Scalar step() const
Definition: Grid1D.h:18
Scalar lower() const
Definition: Grid1D.h:19
int Grid1D::nodes ( ) const
inline
void Grid1D::normalize ( int &  ind,
Scalar f 
) const
inline

Definition at line 36 of file Grid1D.h.

Referenced by LinearGridInterpolator3D::interpolate().

36  {
37  if (ind < 0) {
38  f -= ind;
39  ind = 0;
40  } else if (ind > edges_) {
41  f += ind - edges_;
42  ind = edges_;
43  }
44  }
int edges_
Definition: Grid1D.h:69
double f[11][100]
Scalar Grid1D::step ( ) const
inline
Scalar Grid1D::upper ( ) const
inline

Member Data Documentation

int Grid1D::edges_
private

Definition at line 69 of file Grid1D.h.

Scalar Grid1D::lower_
private

Definition at line 67 of file Grid1D.h.

Scalar Grid1D::stepinv_
private

Definition at line 66 of file Grid1D.h.

Scalar Grid1D::upper_
private

Definition at line 68 of file Grid1D.h.