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

Manages a grid-like division of 2D space. More...

Public Member Functions

 CellGridClass ()
 Default constructor: invalid ranges. More...
 
 CellGridClass (unsigned int nWires, unsigned int nTDC)
 Constructor: sets the extremes and assumes one cell for each element. More...
 
 CellGridClass (float min_wire, float max_wire, unsigned int nWires, float min_tdc, float max_tdc, unsigned int nTDC)
 Constructor: sets the wire and TDC ranges in detail. More...
 
size_t NCells () const
 Returns the total number of cells in the grid. More...
 
GridAxisClass const & WireAxis () const
 Return the information about the wires. More...
 
GridAxisClass const & TDCAxis () const
 Return the information about the TDCs. More...
 
std::ptrdiff_t GetCell (float wire, float tick) const
 Returns the index of specified cell, or -1 if out of range. More...
 
std::tuple< float, float, float, float > GetCellBox (std::ptrdiff_t iCell) const
 Returns the coordinates { w1, t1, w2, t2 } of specified cell. More...
 
template<typename CONT >
bool Add (CONT &cont, float wire, float tick, typename CONT::value_type v)
 
bool SetMinWireCellSize (float min_size)
 Sets the minimum size for wire cells. More...
 
bool SetMinTDCCellSize (float min_size)
 Sets the minimum size for TDC cells. More...
 
template<typename Stream >
void Dump (Stream &&out) const
 Prints the current axes on the specified stream. More...
 
bool hasWire (float wire) const
 Returns whether the range includes the specified wire. More...
 
bool hasWire (int wire) const
 Returns whether the range includes the specified wire. More...
 
bool hasTick (float tick) const
 Returns whether the range includes the specified wire. More...
 
bool hasTick (int tick) const
 Returns whether the range includes the specified wire. More...
 
Setters

Sets a simple wire range: all the wires, one cell per wire

void SetWireRange (unsigned int nWires)
 Sets the wire range, leaving the number of wire cells unchanged. More...
 
void SetWireRange (float min_wire, float max_wire)
 Sets the wire range, leaving the number of wire cells unchanged. More...
 
void SetWireRange (float min_wire, float max_wire, unsigned int nWires)
 Sets the complete wire range. More...
 
void SetWireRange (float min_wire, float max_wire, unsigned int nWires, float min_size)
 Sets the complete wire range, with minimum cell size. More...
 
void SetTDCRange (unsigned int nTDC)
 Sets a simple TDC range: all the ticks, one cell per tick. More...
 
void SetTDCRange (float min_tdc, float max_tdc, unsigned int nTDC)
 Sets the complete TDC range. More...
 
void SetTDCRange (float min_tdc, float max_tdc)
 Sets the TDC range, leaving the number of ticks unchanged. More...
 
void SetTDCRange (float min_tdc, float max_tdc, unsigned int nTDC, float min_size)
 Sets the complete TDC range, with minimum cell size. More...
 

Private Attributes

GridAxisClass wire_axis
 
GridAxisClass tdc_axis
 

Detailed Description

Manages a grid-like division of 2D space.

Definition at line 386 of file RawDataDrawer.cxx.

Constructor & Destructor Documentation

evd::details::CellGridClass::CellGridClass ( )
inline

Default constructor: invalid ranges.

Definition at line 389 of file RawDataDrawer.cxx.

evd::details::CellGridClass::CellGridClass ( unsigned int  nWires,
unsigned int  nTDC 
)

Constructor: sets the extremes and assumes one cell for each element.

Definition at line 1843 of file RawDataDrawer.cxx.

1844  : wire_axis((size_t)nWires, 0., float(nWires)), tdc_axis((size_t)nTDC, 0., float(nTDC))
1845  {} // CellGridClass::CellGridClass(int, int)
evd::details::CellGridClass::CellGridClass ( float  min_wire,
float  max_wire,
unsigned int  nWires,
float  min_tdc,
float  max_tdc,
unsigned int  nTDC 
)

Constructor: sets the wire and TDC ranges in detail.

Definition at line 1848 of file RawDataDrawer.cxx.

1854  : wire_axis((size_t)nWires, min_wire, max_wire), tdc_axis((size_t)nTDC, min_tdc, max_tdc)
1855  {} // CellGridClass::CellGridClass({ float, float, int } x 2)

Member Function Documentation

template<typename CONT >
bool evd::details::CellGridClass::Add ( CONT &  cont,
float  wire,
float  tick,
typename CONT::value_type  v 
)
inline

Increments the specified cell of cont with the value v

Returns
whether there was such a cell

Definition at line 432 of file RawDataDrawer.cxx.

433  {
434  std::ptrdiff_t cell = GetCell(wire, tick);
435  if (cell < 0) return false;
436  cont[(size_t)cell] += v;
437  return true;
438  } // Add()
std::ptrdiff_t GetCell(float wire, float tick) const
Returns the index of specified cell, or -1 if out of range.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:73
template<typename Stream >
void evd::details::CellGridClass::Dump ( Stream &&  out) const

Prints the current axes on the specified stream.

Definition at line 1883 of file RawDataDrawer.cxx.

References evd::details::GridAxisClass::Dump(), TDCAxis(), and WireAxis().

1884  {
1885  out << "Wire axis: ";
1886  WireAxis().Dump(out);
1887  out << "; time axis: ";
1888  TDCAxis().Dump(out);
1889  } // CellGridClass::Dump()
GridAxisClass const & WireAxis() const
Return the information about the wires.
void Dump(Stream &&out) const
GridAxisClass const & TDCAxis() const
Return the information about the TDCs.
std::ptrdiff_t evd::details::CellGridClass::GetCell ( float  wire,
float  tick 
) const

Returns the index of specified cell, or -1 if out of range.

Definition at line 1858 of file RawDataDrawer.cxx.

References evd::details::GridAxisClass::GetCell(), evd::details::GridAxisClass::hasCell(), evd::details::GridAxisClass::NCells(), tdc_axis, TDCAxis(), and wire_axis.

1859  {
1860  std::ptrdiff_t iWireCell = wire_axis.GetCell(wire);
1861  if (!wire_axis.hasCell(iWireCell)) return std::ptrdiff_t(-1);
1862  std::ptrdiff_t iTDCCell = tdc_axis.GetCell(tick);
1863  if (!tdc_axis.hasCell(iTDCCell)) return std::ptrdiff_t(-1);
1864  return iWireCell * TDCAxis().NCells() + iTDCCell;
1865  } // CellGridClass::GetCell()
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:73
bool hasCell(std::ptrdiff_t iCell) const
Returns whether the cell is present or not.
size_t NCells() const
Returns the length of the axis.
GridAxisClass const & TDCAxis() const
Return the information about the TDCs.
std::ptrdiff_t GetCell(float coord) const
Returns the index of the specified cell.
std::tuple< float, float, float, float > evd::details::CellGridClass::GetCellBox ( std::ptrdiff_t  iCell) const

Returns the coordinates { w1, t1, w2, t2 } of specified cell.

Definition at line 1868 of file RawDataDrawer.cxx.

References evd::details::GridAxisClass::LowerEdge(), evd::details::GridAxisClass::NCells(), TDCAxis(), evd::details::GridAxisClass::UpperEdge(), and WireAxis().

Referenced by evd::RawDataDrawer::QueueDrawingBoxes().

1869  {
1870  // { w1, t1, w2, t2 }
1871  size_t const nTDCCells = TDCAxis().NCells();
1872  std::ptrdiff_t iWireCell = (std::ptrdiff_t)(iCell / nTDCCells),
1873  iTDCCell = (std::ptrdiff_t)(iCell % nTDCCells);
1874 
1875  return std::tuple<float, float, float, float>(WireAxis().LowerEdge(iWireCell),
1876  TDCAxis().LowerEdge(iTDCCell),
1877  WireAxis().UpperEdge(iWireCell),
1878  TDCAxis().UpperEdge(iTDCCell));
1879  } // CellGridClass::GetCellBox()
GridAxisClass const & WireAxis() const
Return the information about the wires.
float UpperEdge(std::ptrdiff_t iCell) const
Returns the upper edge of the cell.
float LowerEdge(std::ptrdiff_t iCell) const
Returns the lower edge of the cell.
size_t NCells() const
Returns the length of the axis.
GridAxisClass const & TDCAxis() const
Return the information about the TDCs.
bool evd::details::CellGridClass::hasTick ( float  tick) const
inline

Returns whether the range includes the specified wire.

Definition at line 425 of file RawDataDrawer.cxx.

425 { return tdc_axis.hasCoord(tick); }
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:73
bool hasCoord(float coord) const
Returns whether the coordinate is included in the range or not.
bool evd::details::CellGridClass::hasTick ( int  tick) const
inline

Returns whether the range includes the specified wire.

Definition at line 426 of file RawDataDrawer.cxx.

References hasTick().

Referenced by hasTick().

426 { return hasTick((float)tick); }
bool hasTick(float tick) const
Returns whether the range includes the specified wire.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:73
bool evd::details::CellGridClass::hasWire ( float  wire) const
inline

Returns whether the range includes the specified wire.

Definition at line 419 of file RawDataDrawer.cxx.

419 { return wire_axis.hasCoord(wire); }
bool hasCoord(float coord) const
Returns whether the coordinate is included in the range or not.
bool evd::details::CellGridClass::hasWire ( int  wire) const
inline

Returns whether the range includes the specified wire.

Definition at line 420 of file RawDataDrawer.cxx.

References hasWire().

Referenced by hasWire().

420 { return hasWire((float)wire); }
bool hasWire(float wire) const
Returns whether the range includes the specified wire.
size_t evd::details::CellGridClass::NCells ( ) const
inline

Returns the total number of cells in the grid.

Definition at line 403 of file RawDataDrawer.cxx.

403 { return wire_axis.NCells() * tdc_axis.NCells(); }
size_t NCells() const
Returns the length of the axis.
bool evd::details::CellGridClass::SetMinTDCCellSize ( float  min_size)
inline

Sets the minimum size for TDC cells.

Definition at line 486 of file RawDataDrawer.cxx.

Referenced by evd::RawDataDrawer::SetDrawingLimits().

486 { return tdc_axis.SetMinCellSize(min_size); }
bool SetMinCellSize(float min_size)
bool evd::details::CellGridClass::SetMinWireCellSize ( float  min_size)
inline

Sets the minimum size for wire cells.

Definition at line 483 of file RawDataDrawer.cxx.

Referenced by evd::RawDataDrawer::SetDrawingLimits().

483 { return wire_axis.SetMinCellSize(min_size); }
bool SetMinCellSize(float min_size)
void evd::details::CellGridClass::SetTDCRange ( unsigned int  nTDC)
inline

Sets a simple TDC range: all the ticks, one cell per tick.

Definition at line 462 of file RawDataDrawer.cxx.

References SetTDCRange().

Referenced by evd::RawDataDrawer::ExtractRange(), evd::RawDataDrawer::SetDrawingLimits(), and SetTDCRange().

462 { SetTDCRange(0., (float)nTDC, nTDC); }
void SetTDCRange(unsigned int nTDC)
Sets a simple TDC range: all the ticks, one cell per tick.
void evd::details::CellGridClass::SetTDCRange ( float  min_tdc,
float  max_tdc,
unsigned int  nTDC 
)
inline

Sets the complete TDC range.

Definition at line 465 of file RawDataDrawer.cxx.

466  {
467  tdc_axis.Init(nTDC, min_tdc, max_tdc);
468  }
bool Init(size_t nDiv, float new_min, float new_max)
Initialize the axis, returns whether cell size is finite.
void evd::details::CellGridClass::SetTDCRange ( float  min_tdc,
float  max_tdc 
)
inline

Sets the TDC range, leaving the number of ticks unchanged.

Definition at line 471 of file RawDataDrawer.cxx.

471 { tdc_axis.SetLimits(min_tdc, max_tdc); }
bool SetLimits(float new_min, float new_max)
Initialize the axis limits, returns whether cell size is finite.
void evd::details::CellGridClass::SetTDCRange ( float  min_tdc,
float  max_tdc,
unsigned int  nTDC,
float  min_size 
)
inline

Sets the complete TDC range, with minimum cell size.

Definition at line 474 of file RawDataDrawer.cxx.

475  {
476  tdc_axis.Init(nTDC, min_tdc, max_tdc);
477  tdc_axis.SetMinCellSize(min_size);
478  }
bool Init(size_t nDiv, float new_min, float new_max)
Initialize the axis, returns whether cell size is finite.
bool SetMinCellSize(float min_size)
void evd::details::CellGridClass::SetWireRange ( unsigned int  nWires)
inline

Sets the wire range, leaving the number of wire cells unchanged.

Definition at line 443 of file RawDataDrawer.cxx.

References SetWireRange().

Referenced by evd::RawDataDrawer::ExtractRange(), evd::RawDataDrawer::SetDrawingLimits(), and SetWireRange().

443 { SetWireRange(0., (float)nWires, nWires); }
void SetWireRange(unsigned int nWires)
Sets the wire range, leaving the number of wire cells unchanged.
void evd::details::CellGridClass::SetWireRange ( float  min_wire,
float  max_wire 
)
inline

Sets the wire range, leaving the number of wire cells unchanged.

Definition at line 446 of file RawDataDrawer.cxx.

446 { wire_axis.SetLimits(min_wire, max_wire); }
bool SetLimits(float new_min, float new_max)
Initialize the axis limits, returns whether cell size is finite.
void evd::details::CellGridClass::SetWireRange ( float  min_wire,
float  max_wire,
unsigned int  nWires 
)
inline

Sets the complete wire range.

Definition at line 449 of file RawDataDrawer.cxx.

450  {
451  wire_axis.Init(nWires, min_wire, max_wire);
452  }
bool Init(size_t nDiv, float new_min, float new_max)
Initialize the axis, returns whether cell size is finite.
void evd::details::CellGridClass::SetWireRange ( float  min_wire,
float  max_wire,
unsigned int  nWires,
float  min_size 
)
inline

Sets the complete wire range, with minimum cell size.

Definition at line 455 of file RawDataDrawer.cxx.

456  {
457  wire_axis.Init(nWires, min_wire, max_wire);
458  wire_axis.SetMinCellSize(min_size);
459  }
bool Init(size_t nDiv, float new_min, float new_max)
Initialize the axis, returns whether cell size is finite.
bool SetMinCellSize(float min_size)
GridAxisClass const& evd::details::CellGridClass::TDCAxis ( ) const
inline

Return the information about the TDCs.

Definition at line 409 of file RawDataDrawer.cxx.

Referenced by Dump(), GetCell(), and GetCellBox().

409 { return tdc_axis; }
GridAxisClass const& evd::details::CellGridClass::WireAxis ( ) const
inline

Return the information about the wires.

Definition at line 406 of file RawDataDrawer.cxx.

Referenced by Dump(), and GetCellBox().

406 { return wire_axis; }

Member Data Documentation

GridAxisClass evd::details::CellGridClass::tdc_axis
private

Definition at line 494 of file RawDataDrawer.cxx.

Referenced by GetCell().

GridAxisClass evd::details::CellGridClass::wire_axis
private

Definition at line 493 of file RawDataDrawer.cxx.

Referenced by GetCell().


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