Public Member Functions | Private Attributes | List of all members
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
 
bool hasTick (float tick) const
 Returns whether the range includes the specified wire. More...
 
bool hasTick (int tick) const
 
Setters

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

void SetWireRange (unsigned int nWires)
 
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 492 of file RawDataDrawer.cxx.

Constructor & Destructor Documentation

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

Default constructor: invalid ranges.

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

2088  : wire_axis((size_t)nWires, 0., float(nWires)), tdc_axis((size_t)nTDC, 0., float(nTDC))
2089  {} // 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 2092 of file RawDataDrawer.cxx.

2098  : wire_axis((size_t)nWires, min_wire, max_wire), tdc_axis((size_t)nTDC, min_tdc, max_tdc)
2099  {} // 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 567 of file RawDataDrawer.cxx.

568  {
569  std::ptrdiff_t cell = GetCell(wire, tick);
570  if (cell < 0) return false;
571  cont[(size_t)cell] += v;
572  return true;
573  } // 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:75
template<typename Stream >
void evd::details::CellGridClass::Dump ( Stream &&  out) const

Prints the current axes on the specified stream.

Definition at line 2130 of file RawDataDrawer.cxx.

2131  {
2132  out << "Wire axis: ";
2133  WireAxis().Dump(out);
2134  out << "; time axis: ";
2135  TDCAxis().Dump(out);
2136  } // 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 2103 of file RawDataDrawer.cxx.

2104  {
2105  std::ptrdiff_t iWireCell = wire_axis.GetCell(wire);
2106  if (!wire_axis.hasCell(iWireCell)) return std::ptrdiff_t(-1);
2107  std::ptrdiff_t iTDCCell = tdc_axis.GetCell(tick);
2108  if (!tdc_axis.hasCell(iTDCCell)) return std::ptrdiff_t(-1);
2109  return iWireCell * TDCAxis().NCells() + iTDCCell;
2110  } // CellGridClass::GetCell()
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
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 2114 of file RawDataDrawer.cxx.

2115  {
2116  // { w1, t1, w2, t2 }
2117  size_t const nTDCCells = TDCAxis().NCells();
2118  std::ptrdiff_t iWireCell = (std::ptrdiff_t)(iCell / nTDCCells),
2119  iTDCCell = (std::ptrdiff_t)(iCell % nTDCCells);
2120 
2121  return std::tuple<float, float, float, float>(WireAxis().LowerEdge(iWireCell),
2122  TDCAxis().LowerEdge(iTDCCell),
2123  WireAxis().UpperEdge(iWireCell),
2124  TDCAxis().UpperEdge(iTDCCell));
2125  } // 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 552 of file RawDataDrawer.cxx.

553  {
554  return tdc_axis.hasCoord(tick);
555  }
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
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

Definition at line 557 of file RawDataDrawer.cxx.

558  {
559  return hasTick((float)tick);
560  }
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:75
bool evd::details::CellGridClass::hasWire ( float  wire) const
inline

Returns whether the range includes the specified wire.

Definition at line 538 of file RawDataDrawer.cxx.

539  {
540  return wire_axis.hasCoord(wire);
541  }
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

Definition at line 543 of file RawDataDrawer.cxx.

544  {
545  return hasWire((float)wire);
546  }
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 510 of file RawDataDrawer.cxx.

511  {
512  return wire_axis.NCells() * tdc_axis.NCells();
513  }
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 646 of file RawDataDrawer.cxx.

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

Sets the minimum size for wire cells.

Definition at line 639 of file RawDataDrawer.cxx.

640  {
641  return wire_axis.SetMinCellSize(min_size);
642  }
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 608 of file RawDataDrawer.cxx.

609  {
610  SetTDCRange(0., (float)nTDC, nTDC);
611  }
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 615 of file RawDataDrawer.cxx.

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

623  {
624  tdc_axis.SetLimits(min_tdc, max_tdc);
625  }
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 629 of file RawDataDrawer.cxx.

630  {
631  tdc_axis.Init(nTDC, min_tdc, max_tdc);
632  tdc_axis.SetMinCellSize(min_size);
633  }
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

Definition at line 579 of file RawDataDrawer.cxx.

580  {
581  SetWireRange(0., (float)nWires, nWires);
582  }
void SetWireRange(unsigned int nWires)
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 586 of file RawDataDrawer.cxx.

587  {
588  wire_axis.SetLimits(min_wire, max_wire);
589  }
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 593 of file RawDataDrawer.cxx.

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

601  {
602  wire_axis.Init(nWires, min_wire, max_wire);
603  wire_axis.SetMinCellSize(min_size);
604  }
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 524 of file RawDataDrawer.cxx.

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

Return the information about the wires.

Definition at line 517 of file RawDataDrawer.cxx.

518  {
519  return wire_axis;
520  }

Member Data Documentation

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

Definition at line 657 of file RawDataDrawer.cxx.

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

Definition at line 656 of file RawDataDrawer.cxx.


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