CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

Grid1D Class Reference

#include <Grid1D.h>

List of all members.

Public Types

typedef float Scalar

Public Member Functions

int cells () const
Scalar closestNode (Scalar a) const
 Grid1D (Scalar lower, Scalar upper, int nodes)
 Grid1D ()
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.
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.

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

Definition at line 15 of file Grid1D.h.


Member Function Documentation

int Grid1D::cells ( ) const [inline]

Definition at line 25 of file Grid1D.h.

{return  edges_+1;}
Scalar Grid1D::closestNode ( Scalar  a) const [inline]

Definition at line 53 of file Grid1D.h.

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

                                      {
    Scalar b = (a-lower())/step();
    Scalar c = floor(b);
    Scalar tmp = (b-c < 0.5) ? std::max(c,0.f) : std::min(c+1.f,static_cast<Scalar>(nodes()-1));
    return tmp*step()+lower();
  }
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 relval_parameters_module::step.

                             {
    int ind = static_cast<int>((a-lower())/step());
    // FIXME: this causes an exception to be thrown later. Should be tested
    // more carefully before release
    //  if (ind < -1 || ind > cells()) {
    //     std::cout << "**** ind = " << ind << " cells: " << cells() << std::endl;
    //    return -1;
    //  }
    return std::max(0, std::min( cells()-1, ind));
  }
int Grid1D::index ( Scalar  a,
Scalar f 
) const [inline]

Definition at line 34 of file Grid1D.h.

References b.

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

                                        {
    Scalar b;
    f = modff((a-lower())*stepinv_, &b);
    return b;
  }
bool Grid1D::inRange ( int  i) const [inline]

Definition at line 29 of file Grid1D.h.

                            {
    return i>=0 && i<=edges_;
  }
Scalar Grid1D::lower ( ) const [inline]
Scalar Grid1D::node ( int  i) const [inline]
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().

                                               {
    if (ind<0) {
      f -= ind;
      ind = 0;
    }
    else if (ind>edges_) {
      f += ind-edges_;
      ind = edges_;
    }
  }
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.

Definition at line 76 of file Grid1D.h.

Definition at line 75 of file Grid1D.h.

Definition at line 77 of file Grid1D.h.