LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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...
 

Protected Attributes

GridAxisClass wire_axis
 
GridAxisClass tdc_axis
 

Detailed Description

Manages a grid-like division of 2D space.

Definition at line 405 of file RawDataDrawer.cxx.

Constructor & Destructor Documentation

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

Default constructor: invalid ranges.

Definition at line 409 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 1919 of file RawDataDrawer.cxx.

1920  : wire_axis((size_t) nWires, 0., float(nWires))
1921  , tdc_axis((size_t) nTDC, 0., float(nTDC))
1922  {
1923  } // 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 1927 of file RawDataDrawer.cxx.

1931  : wire_axis((size_t) nWires, min_wire, max_wire)
1932  , tdc_axis((size_t) nTDC, min_tdc, max_tdc)
1933  {
1934  } // 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 453 of file RawDataDrawer.cxx.

454  {
455  std::ptrdiff_t cell = GetCell(wire, tick);
456  if (cell < 0) return false;
457  cont[(size_t) cell] += v;
458  return true;
459  } // Add()
std::ptrdiff_t GetCell(float wire, float tick) const
Returns the index of specified cell, or -1 if out of range.
template<typename Stream >
void evd::details::CellGridClass::Dump ( Stream &&  out) const

Prints the current axes on the specified stream.

Definition at line 1966 of file RawDataDrawer.cxx.

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

1966  {
1967  out << "Wire axis: ";
1968  WireAxis().Dump(out);
1969  out << "; time axis: ";
1970  TDCAxis().Dump(out);
1971  } // 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 1938 of file RawDataDrawer.cxx.

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

1938  {
1939  std::ptrdiff_t iWireCell = wire_axis.GetCell(wire);
1940  if (!wire_axis.hasCell(iWireCell)) return std::ptrdiff_t(-1);
1941  std::ptrdiff_t iTDCCell = tdc_axis.GetCell(tick);
1942  if (!tdc_axis.hasCell(iTDCCell)) return std::ptrdiff_t(-1);
1943  return iWireCell * TDCAxis().NCells() + iTDCCell;
1944  } // CellGridClass::GetCell()
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 1949 of file RawDataDrawer.cxx.

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

Referenced by GetCell(), and evd::RawDataDrawer::QueueDrawingBoxes().

1950  {
1951  // { w1, t1, w2, t2 }
1952  size_t const nTDCCells = TDCAxis().NCells();
1953  std::ptrdiff_t iWireCell = (std::ptrdiff_t) (iCell / nTDCCells),
1954  iTDCCell = (std::ptrdiff_t) (iCell % nTDCCells);
1955 
1956 
1957  return std::tuple<float, float, float, float>(
1958  WireAxis().LowerEdge(iWireCell), TDCAxis().LowerEdge(iTDCCell),
1959  WireAxis().UpperEdge(iWireCell), TDCAxis().UpperEdge(iTDCCell)
1960  );
1961  } // 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 445 of file RawDataDrawer.cxx.

445 { return tdc_axis.hasCoord(tick); }
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 446 of file RawDataDrawer.cxx.

References hasTick().

Referenced by hasTick().

446 { return hasTick((float) tick); }
bool hasTick(float tick) const
Returns whether the range includes the specified wire.
bool evd::details::CellGridClass::hasWire ( float  wire) const
inline

Returns whether the range includes the specified wire.

Definition at line 439 of file RawDataDrawer.cxx.

439 { 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 440 of file RawDataDrawer.cxx.

References hasWire().

Referenced by hasWire().

440 { 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 421 of file RawDataDrawer.cxx.

421 { 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 511 of file RawDataDrawer.cxx.

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

512  { 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 507 of file RawDataDrawer.cxx.

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

508  { 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 485 of file RawDataDrawer.cxx.

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

486  { 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 489 of file RawDataDrawer.cxx.

490  { tdc_axis.Init(nTDC, min_tdc, max_tdc); }
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 493 of file RawDataDrawer.cxx.

494  { 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 498 of file RawDataDrawer.cxx.

499  {
500  tdc_axis.Init(nTDC, min_tdc, max_tdc);
501  tdc_axis.SetMinCellSize(min_size);
502  }
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 465 of file RawDataDrawer.cxx.

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

466  { 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 469 of file RawDataDrawer.cxx.

470  { 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 473 of file RawDataDrawer.cxx.

474  { wire_axis.Init(nWires, min_wire, max_wire); }
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 478 of file RawDataDrawer.cxx.

479  {
480  wire_axis.Init(nWires, min_wire, max_wire);
481  wire_axis.SetMinCellSize(min_size);
482  }
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 427 of file RawDataDrawer.cxx.

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

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

Return the information about the wires.

Definition at line 424 of file RawDataDrawer.cxx.

Referenced by Dump(), and GetCellBox().

424 { return wire_axis; }

Member Data Documentation

GridAxisClass evd::details::CellGridClass::tdc_axis
protected

Definition at line 520 of file RawDataDrawer.cxx.

Referenced by GetCell().

GridAxisClass evd::details::CellGridClass::wire_axis
protected

Definition at line 519 of file RawDataDrawer.cxx.

Referenced by GetCell().


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