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) const
 returns valid index, or -1 if the value is outside range +/- one cell. More...
 
int index (Scalar a, Scalar &f) const
 
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

◆ Scalar

typedef float Grid1D::Scalar

Definition at line 9 of file Grid1D.h.

Constructor & Destructor Documentation

◆ Grid1D() [1/2]

Grid1D::Grid1D ( )
inline

Definition at line 12 of file Grid1D.h.

12 {}

◆ Grid1D() [2/2]

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  }

References class-composition::nodes, and pileupCalc::upper.

Member Function Documentation

◆ cells()

int Grid1D::cells ( ) const
inline

Definition at line 22 of file Grid1D.h.

22 { return edges_ + 1; }

◆ closestNode()

Scalar Grid1D::closestNode ( Scalar  a) const
inline

Definition at line 46 of file Grid1D.h.

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  }

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

◆ index() [1/2]

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.

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  }

References a, cells, SiStripPI::max, and min().

Referenced by BeautifulSoup.PageElement::insert().

◆ index() [2/2]

int Grid1D::index ( Scalar  a,
Scalar f 
) const
inline

Definition at line 29 of file Grid1D.h.

29  {
30  Scalar b;
31  f = modff((a - lower()) * stepinv_, &b);
32  return b;
33  }

References a, b, and f.

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

◆ inRange()

bool Grid1D::inRange ( int  i) const
inline

Definition at line 26 of file Grid1D.h.

26 { return i >= 0 && i <= edges_; }

References mps_fire::i.

◆ lower()

Scalar Grid1D::lower ( ) const
inline

◆ node()

Scalar Grid1D::node ( int  i) const
inline

Definition at line 24 of file Grid1D.h.

24 { return i * step() + lower(); }

References mps_fire::i.

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

◆ nodes()

int Grid1D::nodes ( ) const
inline

◆ normalize()

void Grid1D::normalize ( int &  ind,
Scalar f 
) const
inline

Definition at line 36 of file Grid1D.h.

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  }

References f.

Referenced by LinearGridInterpolator3D::interpolate().

◆ step()

Scalar Grid1D::step ( ) const
inline

◆ upper()

Scalar Grid1D::upper ( ) const
inline

Member Data Documentation

◆ edges_

int Grid1D::edges_
private

Definition at line 69 of file Grid1D.h.

◆ lower_

Scalar Grid1D::lower_
private

Definition at line 67 of file Grid1D.h.

◆ stepinv_

Scalar Grid1D::stepinv_
private

Definition at line 66 of file Grid1D.h.

◆ upper_

Scalar Grid1D::upper_
private

Definition at line 68 of file Grid1D.h.

mps_fire.i
i
Definition: mps_fire.py:428
Grid1D::lower_
Scalar lower_
Definition: Grid1D.h:67
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
min
T min(T a, T b)
Definition: MathUtil.h:58
Grid1D::nodes
int nodes() const
Definition: Grid1D.h:21
Grid1D::upper
Scalar upper() const
Definition: Grid1D.h:20
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
Grid1D::step
Scalar step() const
Definition: Grid1D.h:18
b
double b
Definition: hdecay.h:118
a
double a
Definition: hdecay.h:119
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
Grid1D::Scalar
float Scalar
Definition: Grid1D.h:9
Grid1D::upper_
Scalar upper_
Definition: Grid1D.h:68
std
Definition: JetResolutionObject.h:76
Grid1D::stepinv_
Scalar stepinv_
Definition: Grid1D.h:66
Grid1D::cells
int cells() const
Definition: Grid1D.h:22
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
Grid1D::edges_
int edges_
Definition: Grid1D.h:69
Grid1D::lower
Scalar lower() const
Definition: Grid1D.h:19