LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 323 of file RawDataDrawer.cxx.

Constructor & Destructor Documentation

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

Default constructor: an invalid range.

Definition at line 326 of file RawDataDrawer.cxx.

326 { 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 329 of file RawDataDrawer.cxx.

References geo::vect::coord().

330  { 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 363 of file RawDataDrawer.cxx.

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

Definition at line 1910 of file RawDataDrawer.cxx.

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

1910  {
1911  out << NCells() << " cells from " << Min() << " to " << Max()
1912  << " (length: " << Length() << ")";
1913  } // 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 1856 of file RawDataDrawer.cxx.

References min.

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

1856  {
1857  return std::ptrdiff_t((coord - min) / cell_size); // truncate
1858  } // 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 339 of file RawDataDrawer.cxx.

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

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

References min.

344  { 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 1862 of file RawDataDrawer.cxx.

References max.

1862  {
1863 
1864  n_cells = std::max(nDiv, size_t(1));
1865  return SetLimits(new_min, new_max);
1866 
1867  } // GridAxisClass::Init()
size_t n_cells
number of cells in the axis
Int_t max
Definition: plot.C:27
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 360 of file RawDataDrawer.cxx.

References max, and min.

360 { 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 354 of file RawDataDrawer.cxx.

References max, and min.

354 { 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 366 of file RawDataDrawer.cxx.

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

367  { 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 350 of file RawDataDrawer.cxx.

References max.

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

Returns the extremes of the axis.

Definition at line 349 of file RawDataDrawer.cxx.

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

Returns the length of the axis.

Definition at line 357 of file RawDataDrawer.cxx.

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

357 { 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 335 of file RawDataDrawer.cxx.

335 { 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 389 of file RawDataDrawer.cxx.

390  { return SetMinCellSize(min_size) || SetMaxCellSize(max_size); }
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 1871 of file RawDataDrawer.cxx.

References max, and min.

1871  {
1872  min = new_min;
1873  max = new_max;
1874  cell_size = Length() / float(n_cells);
1875 
1876  return std::isnormal(cell_size);
1877  } // 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 1895 of file RawDataDrawer.cxx.

References max.

1895  {
1896  if (cell_size <= max_size) return false;
1897 
1898  // n_cells gets rounded up
1899  n_cells = (size_t) std::max(std::ceil(Length() / max_size), 1.0F);
1900 
1901  // reevaluate cell size, that might be different than max_size
1902  // because of n_cells rounding or minimum value
1903  cell_size = Length() / float(n_cells);
1904  return true;
1905  } // GridAxisClass::SetMaxCellSize()
float cell_size
size of each cell
size_t n_cells
number of cells in the axis
Int_t max
Definition: plot.C:27
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 1881 of file RawDataDrawer.cxx.

References max.

1881  {
1882  if (cell_size >= min_size) return false;
1883 
1884  // n_cells gets truncated
1885  n_cells = (size_t) std::max(std::floor(Length() / min_size), 1.0F);
1886 
1887  // reevaluate cell size, that might be different than min_size
1888  // because of n_cells truncation or minimum value
1889  cell_size = Length() / float(n_cells);
1890  return true;
1891  } // GridAxisClass::SetMinCellSize()
float cell_size
size of each cell
size_t n_cells
number of cells in the axis
Int_t max
Definition: plot.C:27
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 370 of file RawDataDrawer.cxx.

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

371  { 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 399 of file RawDataDrawer.cxx.

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

extremes of the axis

Definition at line 397 of file RawDataDrawer.cxx.

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

Definition at line 397 of file RawDataDrawer.cxx.

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

number of cells in the axis

Definition at line 396 of file RawDataDrawer.cxx.


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