CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 10 of file Grid1D.h.

Constructor & Destructor Documentation

Grid1D::Grid1D ( )
inline

Definition at line 13 of file Grid1D.h.

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

Definition at line 15 of file Grid1D.h.

15  :
17  stepinv_ = (nodes-1)/(upper - lower);
18  }
int edges_
Definition: Grid1D.h:78
Scalar stepinv_
Definition: Grid1D.h:75
int nodes() const
Definition: Grid1D.h:24
Scalar lower() const
Definition: Grid1D.h:22
Scalar upper_
Definition: Grid1D.h:77
Scalar lower_
Definition: Grid1D.h:76
Scalar upper() const
Definition: Grid1D.h:23

Member Function Documentation

int Grid1D::cells ( ) const
inline

Definition at line 25 of file Grid1D.h.

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

Definition at line 53 of file Grid1D.h.

References b, trackerHits::c, f, max(), min, launcher::step, and tmp.

53  {
54  Scalar b = (a-lower())/step();
55  Scalar c = floor(b);
56  Scalar tmp = (b-c < 0.5) ? std::max(c,0.f) : std::min(c+1.f,static_cast<Scalar>(nodes()-1));
57  return tmp*step()+lower();
58  }
Scalar step() const
Definition: Grid1D.h:21
float Scalar
Definition: Grid1D.h:10
#define min(a, b)
Definition: mlp_lapack.h:161
const T & max(const T &a, const T &b)
int nodes() const
Definition: Grid1D.h:24
double f[11][100]
Scalar lower() const
Definition: Grid1D.h:22
double b
Definition: hdecay.h:120
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double a
Definition: hdecay.h:121
int Grid1D::index ( Scalar  a,
Scalar f 
) const
inline

Definition at line 34 of file Grid1D.h.

References b.

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

34  {
35  Scalar b;
36  f = modff((a-lower())*stepinv_, &b);
37  return b;
38  }
float Scalar
Definition: Grid1D.h:10
Scalar stepinv_
Definition: Grid1D.h:75
double f[11][100]
Scalar lower() const
Definition: Grid1D.h:22
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
int Grid1D::index ( Scalar  a) const
inline

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

Definition at line 61 of file Grid1D.h.

References max(), min, and launcher::step.

Referenced by BeautifulSoup.PageElement::_invert().

61  {
62  int ind = static_cast<int>((a-lower())/step());
63  // FIXME: this causes an exception to be thrown later. Should be tested
64  // more carefully before release
65  // if (ind < -1 || ind > cells()) {
66  // std::cout << "**** ind = " << ind << " cells: " << cells() << std::endl;
67  // return -1;
68  // }
69  return std::max(0, std::min( cells()-1, ind));
70  }
Scalar step() const
Definition: Grid1D.h:21
#define min(a, b)
Definition: mlp_lapack.h:161
const T & max(const T &a, const T &b)
int cells() const
Definition: Grid1D.h:25
Scalar lower() const
Definition: Grid1D.h:22
double a
Definition: hdecay.h:121
bool Grid1D::inRange ( int  i) const
inline

Definition at line 29 of file Grid1D.h.

29  {
30  return i>=0 && i<=edges_;
31  }
int i
Definition: DBlmapReader.cc:9
int edges_
Definition: Grid1D.h:78
Scalar Grid1D::lower ( ) const
inline
Scalar Grid1D::node ( int  i) const
inline

Definition at line 27 of file Grid1D.h.

References launcher::step.

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

27 { return i*step() + lower();}
Scalar step() const
Definition: Grid1D.h:21
int i
Definition: DBlmapReader.cc:9
Scalar lower() const
Definition: Grid1D.h:22
int Grid1D::nodes ( ) const
inline
void Grid1D::normalize ( int &  ind,
Scalar f 
) const
inline

Definition at line 41 of file Grid1D.h.

Referenced by LinearGridInterpolator3D::interpolate().

41  {
42  if (ind<0) {
43  f -= ind;
44  ind = 0;
45  }
46  else if (ind>edges_) {
47  f += ind-edges_;
48  ind = edges_;
49  }
50  }
int edges_
Definition: Grid1D.h:78
double f[11][100]
Scalar Grid1D::step ( ) const
inline
Scalar Grid1D::upper ( ) const
inline

Member Data Documentation

int Grid1D::edges_
private

Definition at line 78 of file Grid1D.h.

Scalar Grid1D::lower_
private

Definition at line 76 of file Grid1D.h.

Scalar Grid1D::stepinv_
private

Definition at line 75 of file Grid1D.h.

Scalar Grid1D::upper_
private

Definition at line 77 of file Grid1D.h.