LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
evd::details::GridAxisClass Class Reference

Manages a cell-like division of a coordinate. More...

Public Member Functions

 GridAxisClass ()
 Default constructor: an invalid range. More...
 
 GridAxisClass (size_t nDiv, float new_min, float new_max)
 Constructor: sets the limits and the number of cells. More...
 
bool hasCell (std::ptrdiff_t iCell) const
 Returns whether the cell is present or not. More...
 
bool hasCoord (float coord) const
 Returns whether the coordinate is included in the range or not. More...
 
float Length () const
 Returns the length of the axis. More...
 
size_t NCells () const
 Returns the length of the axis. More...
 
bool isEmpty () const
 Returns whether minimum and maximum match. More...
 
float CellSize () const
 Returns the cell size. More...
 
float LowerEdge (std::ptrdiff_t iCell) const
 Returns the lower edge of the cell. More...
 
float UpperEdge (std::ptrdiff_t iCell) const
 Returns the upper edge of the cell. More...
 
bool Init (size_t nDiv, float new_min, float new_max)
 Initialize the axis, returns whether cell size is finite. More...
 
bool SetLimits (float new_min, float new_max)
 Initialize the axis limits, returns whether cell size is finite. More...
 
bool SetMinCellSize (float min_size)
 
bool SetMaxCellSize (float max_size)
 
bool SetCellSizeBoundary (float min_size, float max_size)
 
template<typename Stream >
void Dump (Stream &&out) const
 
std::ptrdiff_t GetCell (float coord) const
 Returns the index of the specified cell. More...
 
std::ptrdiff_t operator() (float coord) const
 Returns the index of the specified cell. More...
 
float Min () const
 Returns the extremes of the axis. More...
 
float Max () const
 Returns the extremes of the axis. More...
 

Private Attributes

size_t n_cells
 number of cells in the axis More...
 
float min
 
float max
 extremes of the axis More...
 
float cell_size
 size of each cell More...
 

Detailed Description

Manages a cell-like division of a coordinate.

Definition at line 307 of file RawDataDrawer.cxx.

Constructor & Destructor Documentation

evd::details::GridAxisClass::GridAxisClass ( )
inline

Default constructor: an invalid range.

Definition at line 310 of file RawDataDrawer.cxx.

310 { Init(0, 0., 0.); }
bool Init(size_t nDiv, float new_min, float new_max)
Initialize the axis, returns whether cell size is finite.
evd::details::GridAxisClass::GridAxisClass ( size_t  nDiv,
float  new_min,
float  new_max 
)
inline

Constructor: sets the limits and the number of cells.

Definition at line 313 of file RawDataDrawer.cxx.

References geo::vect::coord().

313 { Init(nDiv, new_min, new_max); }
bool Init(size_t nDiv, float new_min, float new_max)
Initialize the axis, returns whether cell size is finite.

Member Function Documentation

float evd::details::GridAxisClass::CellSize ( ) const
inline

Returns the cell size.

Definition at line 346 of file RawDataDrawer.cxx.

346 { return cell_size; }
float cell_size
size of each cell
template<typename Stream >
void evd::details::GridAxisClass::Dump ( Stream &&  out) const

Definition at line 1734 of file RawDataDrawer.cxx.

References tca::Length().

Referenced by evd::details::CellGridClass::Dump().

1735  {
1736  out << NCells() << " cells from " << Min() << " to " << Max() << " (length: " << Length()
1737  << ")";
1738  } // GridAxisClass::Dump()
float Min() const
Returns the extremes of the axis.
float Length() const
Returns the length of the axis.
float Max() const
Returns the extremes of the axis.
size_t NCells() const
Returns the length of the axis.
std::ptrdiff_t evd::details::GridAxisClass::GetCell ( float  coord) const

Returns the index of the specified cell.

Definition at line 1680 of file RawDataDrawer.cxx.

Referenced by evd::details::CellGridClass::GetCell().

1681  {
1682  return std::ptrdiff_t((coord - min) / cell_size); // truncate
1683  } // GridAxisClass::GetCell()
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
float cell_size
size of each cell
bool evd::details::GridAxisClass::hasCell ( std::ptrdiff_t  iCell) const
inline

Returns whether the cell is present or not.

Definition at line 322 of file RawDataDrawer.cxx.

Referenced by evd::details::CellGridClass::GetCell().

323  {
324  return (iCell >= 0) && ((size_t)iCell < NCells());
325  }
size_t NCells() const
Returns the length of the axis.
bool evd::details::GridAxisClass::hasCoord ( float  coord) const
inline

Returns whether the coordinate is included in the range or not.

Definition at line 328 of file RawDataDrawer.cxx.

328 { return (coord >= Min()) && (coord < Max()); }
float Min() const
Returns the extremes of the axis.
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
float Max() const
Returns the extremes of the axis.
bool evd::details::GridAxisClass::Init ( size_t  nDiv,
float  new_min,
float  new_max 
)

Initialize the axis, returns whether cell size is finite.

Definition at line 1686 of file RawDataDrawer.cxx.

1687  {
1688 
1689  n_cells = std::max(nDiv, size_t(1));
1690  return SetLimits(new_min, new_max);
1691 
1692  } // GridAxisClass::Init()
size_t n_cells
number of cells in the axis
bool SetLimits(float new_min, float new_max)
Initialize the axis limits, returns whether cell size is finite.
bool evd::details::GridAxisClass::isEmpty ( ) const
inline

Returns whether minimum and maximum match.

Definition at line 343 of file RawDataDrawer.cxx.

343 { return max == min; }
float max
extremes of the axis
float evd::details::GridAxisClass::Length ( ) const
inline

Returns the length of the axis.

Definition at line 337 of file RawDataDrawer.cxx.

337 { return max - min; }
float max
extremes of the axis
float evd::details::GridAxisClass::LowerEdge ( std::ptrdiff_t  iCell) const
inline

Returns the lower edge of the cell.

Definition at line 349 of file RawDataDrawer.cxx.

Referenced by evd::details::CellGridClass::GetCellBox().

349 { return Min() + CellSize() * iCell; }
float Min() const
Returns the extremes of the axis.
float CellSize() const
Returns the cell size.
float evd::details::GridAxisClass::Max ( ) const
inline

Returns the extremes of the axis.

Definition at line 333 of file RawDataDrawer.cxx.

333 { return max; }
float max
extremes of the axis
float evd::details::GridAxisClass::Min ( ) const
inline

Returns the extremes of the axis.

Definition at line 332 of file RawDataDrawer.cxx.

332 { return min; }
size_t evd::details::GridAxisClass::NCells ( ) const
inline

Returns the length of the axis.

Definition at line 340 of file RawDataDrawer.cxx.

Referenced by evd::details::CellGridClass::GetCell(), and evd::details::CellGridClass::GetCellBox().

340 { return n_cells; }
size_t n_cells
number of cells in the axis
std::ptrdiff_t evd::details::GridAxisClass::operator() ( float  coord) const
inline

Returns the index of the specified cell.

Definition at line 318 of file RawDataDrawer.cxx.

318 { return GetCell(coord); }
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
std::ptrdiff_t GetCell(float coord) const
Returns the index of the specified cell.
bool evd::details::GridAxisClass::SetCellSizeBoundary ( float  min_size,
float  max_size 
)
inline

Expands the cell (at fixed range) to meet maximum cell size

Returns
Whether the cell size was changed

Definition at line 370 of file RawDataDrawer.cxx.

371  {
372  return SetMinCellSize(min_size) || SetMaxCellSize(max_size);
373  }
bool SetMaxCellSize(float max_size)
bool SetMinCellSize(float min_size)
bool evd::details::GridAxisClass::SetLimits ( float  new_min,
float  new_max 
)

Initialize the axis limits, returns whether cell size is finite.

Definition at line 1695 of file RawDataDrawer.cxx.

References tca::Length().

1696  {
1697  min = new_min;
1698  max = new_max;
1699  cell_size = Length() / float(n_cells);
1700 
1701  return std::isnormal(cell_size);
1702  } // GridAxisClass::SetLimits()
float cell_size
size of each cell
size_t n_cells
number of cells in the axis
float Length() const
Returns the length of the axis.
float max
extremes of the axis
bool evd::details::GridAxisClass::SetMaxCellSize ( float  max_size)

Expands the cell (at fixed range) to meet maximum cell size

Returns
Whether the cell size was changed

Definition at line 1719 of file RawDataDrawer.cxx.

References tca::Length().

1720  {
1721  if (cell_size <= max_size) return false;
1722 
1723  // n_cells gets rounded up
1724  n_cells = (size_t)std::max(std::ceil(Length() / max_size), 1.0F);
1725 
1726  // reevaluate cell size, that might be different than max_size
1727  // because of n_cells rounding or minimum value
1728  cell_size = Length() / float(n_cells);
1729  return true;
1730  } // GridAxisClass::SetMaxCellSize()
float cell_size
size of each cell
size_t n_cells
number of cells in the axis
float Length() const
Returns the length of the axis.
bool evd::details::GridAxisClass::SetMinCellSize ( float  min_size)

Expands the cell (at fixed range) to meet minimum cell size

Returns
Whether the cell size was changed

Definition at line 1705 of file RawDataDrawer.cxx.

References tca::Length().

1706  {
1707  if (cell_size >= min_size) return false;
1708 
1709  // n_cells gets truncated
1710  n_cells = (size_t)std::max(std::floor(Length() / min_size), 1.0F);
1711 
1712  // reevaluate cell size, that might be different than min_size
1713  // because of n_cells truncation or minimum value
1714  cell_size = Length() / float(n_cells);
1715  return true;
1716  } // GridAxisClass::SetMinCellSize()
float cell_size
size of each cell
size_t n_cells
number of cells in the axis
float Length() const
Returns the length of the axis.
float evd::details::GridAxisClass::UpperEdge ( std::ptrdiff_t  iCell) const
inline

Returns the upper edge of the cell.

Definition at line 352 of file RawDataDrawer.cxx.

Referenced by evd::details::CellGridClass::GetCellBox().

352 { return LowerEdge(iCell + 1); }
float LowerEdge(std::ptrdiff_t iCell) const
Returns the lower edge of the cell.

Member Data Documentation

float evd::details::GridAxisClass::cell_size
private

size of each cell

Definition at line 382 of file RawDataDrawer.cxx.

float evd::details::GridAxisClass::max
private

extremes of the axis

Definition at line 380 of file RawDataDrawer.cxx.

float evd::details::GridAxisClass::min
private

Definition at line 380 of file RawDataDrawer.cxx.

size_t evd::details::GridAxisClass::n_cells
private

number of cells in the axis

Definition at line 379 of file RawDataDrawer.cxx.


The documentation for this class was generated from the following file: