LArSoft  v09_90_00
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 306 of file RawDataDrawer.cxx.

Constructor & Destructor Documentation

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

Default constructor: an invalid range.

Definition at line 309 of file RawDataDrawer.cxx.

309 { 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 312 of file RawDataDrawer.cxx.

References geo::vect::coord().

312 { 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 345 of file RawDataDrawer.cxx.

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

Definition at line 1834 of file RawDataDrawer.cxx.

References tca::Length().

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

1835  {
1836  out << NCells() << " cells from " << Min() << " to " << Max() << " (length: " << Length()
1837  << ")";
1838  } // 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 1780 of file RawDataDrawer.cxx.

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

1781  {
1782  return std::ptrdiff_t((coord - min) / cell_size); // truncate
1783  } // 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 321 of file RawDataDrawer.cxx.

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

322  {
323  return (iCell >= 0) && ((size_t)iCell < NCells());
324  }
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 327 of file RawDataDrawer.cxx.

327 { 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 1786 of file RawDataDrawer.cxx.

1787  {
1788 
1789  n_cells = std::max(nDiv, size_t(1));
1790  return SetLimits(new_min, new_max);
1791 
1792  } // 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 342 of file RawDataDrawer.cxx.

342 { 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 336 of file RawDataDrawer.cxx.

336 { 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 348 of file RawDataDrawer.cxx.

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

348 { 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 332 of file RawDataDrawer.cxx.

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

Returns the extremes of the axis.

Definition at line 331 of file RawDataDrawer.cxx.

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

Returns the length of the axis.

Definition at line 339 of file RawDataDrawer.cxx.

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

339 { 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 317 of file RawDataDrawer.cxx.

317 { 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 369 of file RawDataDrawer.cxx.

370  {
371  return SetMinCellSize(min_size) || SetMaxCellSize(max_size);
372  }
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 1795 of file RawDataDrawer.cxx.

References tca::Length().

1796  {
1797  min = new_min;
1798  max = new_max;
1799  cell_size = Length() / float(n_cells);
1800 
1801  return std::isnormal(cell_size);
1802  } // 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 1819 of file RawDataDrawer.cxx.

References tca::Length().

1820  {
1821  if (cell_size <= max_size) return false;
1822 
1823  // n_cells gets rounded up
1824  n_cells = (size_t)std::max(std::ceil(Length() / max_size), 1.0F);
1825 
1826  // reevaluate cell size, that might be different than max_size
1827  // because of n_cells rounding or minimum value
1828  cell_size = Length() / float(n_cells);
1829  return true;
1830  } // 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 1805 of file RawDataDrawer.cxx.

References tca::Length().

1806  {
1807  if (cell_size >= min_size) return false;
1808 
1809  // n_cells gets truncated
1810  n_cells = (size_t)std::max(std::floor(Length() / min_size), 1.0F);
1811 
1812  // reevaluate cell size, that might be different than min_size
1813  // because of n_cells truncation or minimum value
1814  cell_size = Length() / float(n_cells);
1815  return true;
1816  } // 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 351 of file RawDataDrawer.cxx.

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

351 { 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 381 of file RawDataDrawer.cxx.

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

extremes of the axis

Definition at line 379 of file RawDataDrawer.cxx.

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

Definition at line 379 of file RawDataDrawer.cxx.

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

number of cells in the axis

Definition at line 378 of file RawDataDrawer.cxx.


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