All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lar::example::PointIsolationAlg< Coord > Class Template Reference

Algorithm to detect isolated space points. More...

#include <PointIsolationAlg.h>

Classes

struct  Configuration_t
 Type containing all configuration parameters of the algorithm. More...
 

Public Types

using Coord_t = Coord
 Type of coordinate. More...
 
using Range_t = CoordRange< Coord_t >
 

Public Member Functions

template<typename PointIter >
std::vector< size_t > removeIsolatedPoints (PointIter begin, PointIter end) const
 Returns the set of points that are not isolated. More...
 
template<typename Cont >
std::vector< size_t > removeIsolatedPoints (Cont const &points) const
 Returns the set of points that are not isolated. More...
 
template<typename PointIter >
std::vector< size_t > bruteRemoveIsolatedPoints (PointIter begin, PointIter end) const
 Brute-force reference algorithm. More...
 
template<typename PointIter >
Coord computeCellSize () const
 

Static Public Member Functions

static Coord_t maximumOptimalCellSize (Coord_t radius)
 Returns the maximum optimal cell size when using a isolation radius. More...
 

Private Types

using Indexer_t = ::util::GridContainer3DIndices
 type managing cell indices More...
 
using NeighAddresses_t = std::vector< Indexer_t::CellIndexOffset_t >
 type of neighbourhood cell offsets More...
 
template<typename PointIter >
using Partition_t = SpacePartition< PointIter >
 
template<typename PointIter >
using Point_t = decltype(*PointIter())
 

Private Member Functions

template<typename PointIter = std::array<double, 3> const*>
Coord_t computeCellSize () const
 Computes the cell size to be used. More...
 
NeighAddresses_t buildNeighborhood (Indexer_t const &indexer, unsigned int neighExtent) const
 Returns a list of cell offsets for the neighbourhood of given radius. More...
 
template<typename PointIter >
bool isPointIsolatedFrom (Point_t< PointIter > const &point, typename Partition_t< PointIter >::Cell_t const &otherPoints) const
 Returns whether a point is isolated with respect to all the others. More...
 
template<typename PointIter >
bool isPointIsolatedWithinNeighborhood (Partition_t< PointIter > const &partition, Indexer_t::CellIndex_t cellIndex, Point_t< PointIter > const &point, NeighAddresses_t const &neighList) const
 Returns whether a point is isolated in the specified neighbourhood. More...
 
template<typename Point >
bool closeEnough (Point const &A, Point const &B) const
 Returns whether A and B are close enough to be considered non-isolated. More...
 

Static Private Member Functions

static std::string rangeString (Coord_t from, Coord_t to)
 Helper function. Returns a string "(\<from\> to \<to\>)" More...
 
static std::string rangeString (Range_t range)
 Helper function. Returns a string "(\<from\> to \<to\>)" More...
 

Private Attributes

Configuration_t config
 all configuration data More...
 

Configuration

 PointIsolationAlg (Configuration_t const &first_config)
 Constructor with configuration validation. More...
 
void reconfigure (Configuration_t const &new_config)
 
Configuration_tconfiguration () const
 
static void validateConfiguration (Configuration_t const &config)
 

Detailed Description

template<typename Coord = double>
class lar::example::PointIsolationAlg< Coord >

Algorithm to detect isolated space points.

Template Parameters
Coordtype of the coordinate
See Also
RemoveIsolatedSpacePoints example overview

This algorithm returns a selection of the input points which are not isolated. Point $ i $ is defined as isolated if: $ \min \left\{ \left| \vec{r}_{i} - \vec{r_{j}} \right| \right\}_{i \neq j} < R $ where $ \vec{r_{k}} $ describes the position of the point $ k $ in space and $ R $ is the isolation radius.

This class must be configured by providing a complete Configuration_t object. Configuration can be changed at any time after that.

The configuration information (Configuration_t) defines the volume the points span and the square of the isolation radius. The information on the volume may be used to optimise the algorithm, and it is not checked. If that information is wrong (that means input points lie outside that volume), the result is undefined. No check is automatically performed to assess if the configuration is valid.

The algorithm can be run on any collection of points, as long as the point class supports the PositionExtractor class. A typical cycle of use is:

// creation and configuration
lar::examples::PointIsolationAlg<float>::Configuration_t config;
config.rangeX = { -1., 1. };
config.rangeY = { -1., 1. };
config.rangeZ = { -5., 5. };
config.radius2 = 0.25;
lar::examples::PointIsolationAlg<float> algo(config);
// preparation/retrieval of input
std::vector<std::array<float, 3>> points;
// points are filled here
// execution
std::vector<size_t> indices
= algo.removeIsolatedPoints(points.begin(), points.end());
// utilization of the result;
// - e.g., create a collection of non-isolated points...
std::vector<std::array<float, 3>> nonIsolatedPoints;
nonIsolatedPoints.reserve(indices.size());
for (size_t index: indices)
nonIsolatedPoints.push_back(points[index]);
// - ... or their pointers
std::vector<std::array<float, 3> const*> nonIsolatedPointPtrs;
nonIsolatedPointPtrs.reserve(indices.size());
for (size_t index: indices)
nonIsolatedPointPtrs.push_back(&(points[index]));

The point type here is std::array<float, 3>, for which a lar::examples::PositionExtractor<std::array<float, 3>> is defined in this same library. The algorithm can be executed multiple times, and the configuration can be changed at any time (reconfigure()).

Validation of the configuration is optional, and needs to be explicitly called if desired (validateConfiguration()).

Description of the algorithm

The basic method to determine the isolation of a point is by brute force, by computing the distance with all others and, as soon as one of them is found too close, declare the point non-isolated.

A refinement is implemented: the points are grouped in cubic "cells" and points in cells that are farther than isolation radius are not checked against each other. This requires some memory to allocate the structure, that can become huge. The maximum memory parameter keeps this sane.

Other refinements are not implemented. When a point is found non-isolated also the point that makes it non-isolated should also be marked so. Cell radius might be tuned to be smaller. Some of the neighbour cells may be too far and should not be checked. The grid allocates a vector for each cell, whether it's empty or not; using a sparse structure might reduce the memory; also if the grid contains pointers to vectors instead of vectors, and the grid is very sparse, there should still be some memory saving.

Definition at line 127 of file PointIsolationAlg.h.

Member Typedef Documentation

template<typename Coord = double>
using lar::example::PointIsolationAlg< Coord >::Coord_t = Coord

Type of coordinate.

Definition at line 131 of file PointIsolationAlg.h.

template<typename Coord = double>
using lar::example::PointIsolationAlg< Coord >::Indexer_t = ::util::GridContainer3DIndices
private

type managing cell indices

Definition at line 241 of file PointIsolationAlg.h.

template<typename Coord = double>
using lar::example::PointIsolationAlg< Coord >::NeighAddresses_t = std::vector<Indexer_t::CellIndexOffset_t>
private

type of neighbourhood cell offsets

Definition at line 244 of file PointIsolationAlg.h.

template<typename Coord = double>
template<typename PointIter >
using lar::example::PointIsolationAlg< Coord >::Partition_t = SpacePartition<PointIter>
private

Definition at line 247 of file PointIsolationAlg.h.

template<typename Coord = double>
template<typename PointIter >
using lar::example::PointIsolationAlg< Coord >::Point_t = decltype(*PointIter())
private

Definition at line 250 of file PointIsolationAlg.h.

template<typename Coord = double>
using lar::example::PointIsolationAlg< Coord >::Range_t = CoordRange<Coord_t>

Definition at line 132 of file PointIsolationAlg.h.

Constructor & Destructor Documentation

template<typename Coord = double>
lar::example::PointIsolationAlg< Coord >::PointIsolationAlg ( Configuration_t const &  first_config)
inline

Constructor with configuration validation.

Parameters
first_configconfiguration parameter structure

For the configuration, see SpacePointIsolationAlg documentation. No validation is performed on the configuration.

Definition at line 155 of file PointIsolationAlg.h.

156  : config(first_config)
157  {}
Configuration_t config
all configuration data

Member Function Documentation

template<typename Coord >
template<typename PointIter >
std::vector< size_t > lar::example::PointIsolationAlg< Coord >::bruteRemoveIsolatedPoints ( PointIter  begin,
PointIter  end 
) const

Brute-force reference algorithm.

Template Parameters
PointIterrandom access iterator to a point type
Parameters
beginiterator to the first point to be considered
enditerator after the last point to be considered
Returns
a list of indices of non-isolated points in the input range
See Also
removeIsolatedPoints

This algorithm executes the task in a $ N^{2} $ way, slow and supposedly reliable. The interface is the same as removeIsolatedPoints. Use this only for tests.

Definition at line 575 of file PointIsolationAlg.h.

576 {
577  //
578  // reference implementation: brute force dumb one
579  //
580 
581  std::vector<size_t> nonIsolated;
582 
583  size_t i = 0;
584  for (auto it = begin; it != end; ++it, ++i) {
585 
586  for (auto ioth = begin; ioth != end; ++ioth) {
587  if (it == ioth) continue;
588 
589  if (closeEnough(*it, *ioth)) {
590  nonIsolated.push_back(i);
591  break;
592  }
593 
594  } // for oth
595 
596  } // for (it)
597 
598  return nonIsolated;
599 } // lar::example::PointIsolationAlg::bruteRemoveIsolatedPoints()
bool closeEnough(Point const &A, Point const &B) const
Returns whether A and B are close enough to be considered non-isolated.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
template<typename Coord >
lar::example::PointIsolationAlg< Coord >::NeighAddresses_t lar::example::PointIsolationAlg< Coord >::buildNeighborhood ( Indexer_t const &  indexer,
unsigned int  neighExtent 
) const
private

Returns a list of cell offsets for the neighbourhood of given radius.

Definition at line 482 of file PointIsolationAlg.h.

483 {
484  unsigned int const neighSize = 1 + 2 * neighExtent;
485  NeighAddresses_t neighList;
486  neighList.reserve(neighSize * neighSize * neighSize - 1);
487 
488  using CellID_t = Indexer_t::CellID_t;
489  using CellDimIndex_t = Indexer_t::CellDimIndex_t;
490 
491  //
492  // optimisation (speed): reshape the neighbourhood
493  // neighbourhood might cut out cells close to the vertices
494  //
495 
496  // TODO
497 
498  CellDimIndex_t const ext = neighExtent; // convert into the right signedness
499 
500  CellID_t center{{ 0, 0, 0 }}, cellID;
501  for (CellDimIndex_t ixOfs = -ext; ixOfs <= ext; ++ixOfs) {
502  cellID[0] = ixOfs;
503  for (CellDimIndex_t iyOfs = -ext; iyOfs <= ext; ++iyOfs) {
504  cellID[1] = iyOfs;
505  for (CellDimIndex_t izOfs = -ext; izOfs <= ext; ++izOfs) {
506  if ((ixOfs == 0) && (iyOfs == 0) && (izOfs == 0)) continue;
507  cellID[2] = izOfs;
508 
509  neighList.push_back(indexer.offset(center, cellID));
510 
511  } // for ixOfs
512  } // for iyOfs
513  } // for izOfs
514 
515  return neighList;
516 } // lar::example::PointIsolationAlg<Coord>::buildNeighborhood()
CellIndexOffset_t CellDimIndex_t
type of difference between indices along a dimension
std::array< CellDimIndex_t, dims()> CellID_t
type of cell coordinate (x, y, z)
std::vector< Indexer_t::CellIndexOffset_t > NeighAddresses_t
type of neighbourhood cell offsets
template<typename Coord >
template<typename Point >
bool lar::example::PointIsolationAlg< Coord >::closeEnough ( Point const &  A,
Point const &  B 
) const
private

Returns whether A and B are close enough to be considered non-isolated.

Definition at line 606 of file PointIsolationAlg.h.

607 {
608  return cet::sum_of_squares(
612  ) <= config.radius2;
613 } // lar::example::PointIsolationAlg<Point>::closeEnough()
Coord_t radius2
square of isolation radius [cm^2]
auto extractPositionY(Point const &point)
auto extractPositionX(Point const &point)
Configuration_t config
all configuration data
float A
Definition: dedx.py:137
auto extractPositionZ(Point const &point)
template<typename Coord = double>
template<typename PointIter = std::array<double, 3> const*>
Coord_t lar::example::PointIsolationAlg< Coord >::computeCellSize ( ) const
private

Computes the cell size to be used.

template<typename Coord = double>
template<typename PointIter >
Coord lar::example::PointIsolationAlg< Coord >::computeCellSize ( ) const

Definition at line 439 of file PointIsolationAlg.h.

439  {
440 
441  Coord_t const R = std::sqrt(config.radius2);
442 
443  // maximum: the maximum distance between two points in the cell (that is,
444  // the diagonal of the cell) must be no larger than the isolation radius R;
445  // minimum: needs tuning
446  Coord_t cellSize = maximumOptimalCellSize(R); // try the minimum for now
447 
448  //
449  // optimisation (memory): determine minimum size of box
450  //
451 
452  // TODO
453 
454  if (config.maxMemory == 0) return cellSize;
455 
456  do {
457  std::array<size_t, 3> partition = details::diceVolume(
458  CoordRangeCells<Coord_t>{ config.rangeX, cellSize },
459  CoordRangeCells<Coord_t>{ config.rangeY, cellSize },
460  CoordRangeCells<Coord_t>{ config.rangeZ, cellSize }
461  );
462 
463  size_t const nCells = partition[0] * partition[1] * partition[2];
464  if (nCells <= 1) break; // we can't reduce it any further
465 
466  // is memory low enough?
467  size_t const memory
468  = nCells * sizeof(typename SpacePartition<PointIter>::Cell_t);
469  if (memory < config.maxMemory) break;
470 
471  cellSize *= 2;
472  } while (true);
473 
474  return cellSize;
475 } // lar::example::PointIsolationAlg<Coord>::computeCellSize()
Coord Coord_t
Type of coordinate.
Coord_t radius2
square of isolation radius [cm^2]
size_t maxMemory
grid smaller than this number of bytes (100 MiB)
Range_t rangeY
range in Y of the covered volume
Range_t rangeX
range in X of the covered volume
std::array< size_t, 3 > diceVolume(CoordRangeCells< Coord > const &rangeX, CoordRangeCells< Coord > const &rangeY, CoordRangeCells< Coord > const &rangeZ)
Returns the dimensions of a grid diced with the specified size.
Range_t rangeZ
range in Z of the covered volume
Configuration_t config
all configuration data
static Coord_t maximumOptimalCellSize(Coord_t radius)
Returns the maximum optimal cell size when using a isolation radius.
template<typename Coord = double>
Configuration_t& lar::example::PointIsolationAlg< Coord >::configuration ( ) const
inline

Returns a constant reference to the current configuration

See Also
reconfigure()

Definition at line 168 of file PointIsolationAlg.h.

168 { return config; }
Configuration_t config
all configuration data
template<typename Coord >
template<typename PointIter >
bool lar::example::PointIsolationAlg< Coord >::isPointIsolatedFrom ( Point_t< PointIter > const &  point,
typename Partition_t< PointIter >::Cell_t const &  otherPoints 
) const
private

Returns whether a point is isolated with respect to all the others.

Definition at line 522 of file PointIsolationAlg.h.

526 {
527 
528  for (auto const& otherPointPtr: otherPoints) {
529  // make sure that we did not compare the point with itself
530  if (closeEnough(point, *otherPointPtr) && (&point != &*otherPointPtr))
531  return false;
532  }
533 
534  return true;
535 
536 } // lar::example::PointIsolationAlg<Coord>::isPointIsolatedFrom()
bool closeEnough(Point const &A, Point const &B) const
Returns whether A and B are close enough to be considered non-isolated.
template<typename Coord >
template<typename PointIter >
bool lar::example::PointIsolationAlg< Coord >::isPointIsolatedWithinNeighborhood ( Partition_t< PointIter > const &  partition,
Indexer_t::CellIndex_t  cellIndex,
Point_t< PointIter > const &  point,
NeighAddresses_t const &  neighList 
) const
private

Returns whether a point is isolated in the specified neighbourhood.

Definition at line 542 of file PointIsolationAlg.h.

548 {
549 
550  // check in all cells of the neighbourhood
551  for (Indexer_t::CellIndexOffset_t neighOfs: neighList) {
552 
553  //
554  // optimisation (speed): have neighbour offsets so that the invalid ones
555  // are all at the beginning and at the end, so that skipping is faster
556  //
557 
558  if (!partition.has(cellIndex + neighOfs)) continue;
559  auto const& neighCellPoints = partition[cellIndex + neighOfs];
560 
561  if (!isPointIsolatedFrom<PointIter>(point, neighCellPoints)) return false;
562 
563  } // for neigh cell
564 
565  return true;
566 
567 } // lar::example::PointIsolationAlg<Coord>::isPointIsolatedWithinNeighborhood()
std::ptrdiff_t CellIndexOffset_t
type of difference between indices
template<typename Coord = double>
static Coord_t lar::example::PointIsolationAlg< Coord >::maximumOptimalCellSize ( Coord_t  radius)
inlinestatic

Returns the maximum optimal cell size when using a isolation radius.

Definition at line 235 of file PointIsolationAlg.h.

236  { return radius / std::sqrt(3.); }
template<typename Coord >
std::string lar::example::PointIsolationAlg< Coord >::rangeString ( Coord_t  from,
Coord_t  to 
)
staticprivate

Helper function. Returns a string "(\<from\> to \<to\>)"

Definition at line 619 of file PointIsolationAlg.h.

620  { return "(" + std::to_string(from) + " to " + std::to_string(to) + ")"; }
std::string to_string(WindowPattern const &pattern)
template<typename Coord = double>
static std::string lar::example::PointIsolationAlg< Coord >::rangeString ( Range_t  range)
inlinestaticprivate

Helper function. Returns a string "(\<from\> to \<to\>)"

Definition at line 290 of file PointIsolationAlg.h.

291  { return rangeString(range.lower, range.upper); }
static std::string rangeString(Coord_t from, Coord_t to)
Helper function. Returns a string &quot;(\&lt;from\&gt; to \&lt;to\&gt;)&quot;
template<typename Coord = double>
void lar::example::PointIsolationAlg< Coord >::reconfigure ( Configuration_t const &  new_config)
inline

Reconfigures the algorithm with the specified configuration (no validation is performed)

See Also
configuration()

Definition at line 162 of file PointIsolationAlg.h.

163  { config = new_config; }
Configuration_t config
all configuration data
template<typename Coord >
template<typename PointIter >
std::vector< size_t > lar::example::PointIsolationAlg< Coord >::removeIsolatedPoints ( PointIter  begin,
PointIter  end 
) const

Returns the set of points that are not isolated.

Template Parameters
PointIterrandom access iterator to a point type
Parameters
beginiterator to the first point to be considered
enditerator after the last point to be considered
Returns
a list of indices of non-isolated points in the input range

This method is the operating core of the algorithm.

The input is two iterators. The output is a collection of the indices of the elements that are not isolated. The index is equivalent to std::distance(begin, point). The order of the elements in the collection is not specified.

This method can use any collection of input data, as long as a PositionExtractor object is available for it.

Definition at line 311 of file PointIsolationAlg.h.

312 {
313 
314  std::vector<size_t> nonIsolated;
315 
316  Coord_t const R = std::sqrt(config.radius2);
317 
318  //
319  // determine space partition settings: cell size
320  //
321  // maximum: the volume of a single cell must be contained in a sphere with
322  // radius equal to the isolation radius R
323  //
324  // minimum: needs tuning
325  //
326 
327  Coord_t cellSize = computeCellSize<PointIter>();
328  assert(cellSize > 0);
329  Partition_t<PointIter> partition(
330  { config.rangeX, cellSize },
331  { config.rangeY, cellSize },
332  { config.rangeZ, cellSize }
333  );
334 
335  // if a cell is contained in a sphere with
336  bool const cellContainedInIsolationSphere
337  = (cellSize <= maximumOptimalCellSize(R));
338 
339  //
340  // determine neighbourhood
341  // the neighbourhood is the number of cells that might contain points closer
342  // than R to a cell; it is equal to R in cell size units, rounded up;
343  // it's expressed as a list of coordinate shifts from a base cell to all the
344  // others in the neighbourhood; it is contained in a cube
345  //
346  unsigned int const neighExtent = (int) std::ceil(R / cellSize);
347  NeighAddresses_t neighList
348  = buildNeighborhood(partition.indexManager(), neighExtent);
349 
350  // if a cell is not fully contained in a isolation radius, we need to check
351  // the points of the cell with each other: their cell becomes part of the
352  // neighbourhood
353  if (!cellContainedInIsolationSphere)
354  neighList.insert(neighList.begin(), { 0, 0, 0 });
355 
356  //
357  // populate the partition
358  //
359  partition.fill(begin, end);
360 
361  //
362  // for each cell in the partition:
363  //
364  size_t const nCells = partition.indexManager().size();
365  for (Indexer_t::CellIndex_t cellIndex = 0; cellIndex < nCells; ++cellIndex) {
366  auto const& cellPoints = partition[cellIndex];
367 
368  //
369  // if the cell has more than one element, mark all points as non-isolated;
370  // true only if the cell is completely contained within a R rßadius
371  //
372  if (cellContainedInIsolationSphere && (cellPoints.size() > 1)) {
373  for (auto const& pointPtr: cellPoints)
374  nonIsolated.push_back(std::distance(begin, pointPtr));
375  continue;
376  } // if all non-isolated
377 
378  //
379  // brute force approach: try all the points in this cell against all the
380  // points in the neighbourhood
381  //
382  for (auto const pointPtr: cellPoints) {
383  //
384  // optimisation (speed): mark the points from other cells as non-isolated
385  // when they trigger non-isolation in points of the current one
386  //
387 
388  // TODO
389 
391  (partition, cellIndex, *pointPtr, neighList)
392  )
393  {
394  nonIsolated.push_back(std::distance(begin, pointPtr));
395  }
396  } // for points in cell
397 
398  } // for cell
399 
400  return nonIsolated;
401 } // lar::example::PointIsolationAlg::removeIsolatedPoints()
Coord Coord_t
Type of coordinate.
Coord_t radius2
square of isolation radius [cm^2]
typename IndexManager_t::LinIndex_t CellIndex_t
type of index for direct access to the cell
Range_t rangeY
range in Y of the covered volume
NeighAddresses_t buildNeighborhood(Indexer_t const &indexer, unsigned int neighExtent) const
Returns a list of cell offsets for the neighbourhood of given radius.
Range_t rangeX
range in X of the covered volume
std::vector< Indexer_t::CellIndexOffset_t > NeighAddresses_t
type of neighbourhood cell offsets
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
Range_t rangeZ
range in Z of the covered volume
Configuration_t config
all configuration data
bool isPointIsolatedWithinNeighborhood(Partition_t< PointIter > const &partition, Indexer_t::CellIndex_t cellIndex, Point_t< PointIter > const &point, NeighAddresses_t const &neighList) const
Returns whether a point is isolated in the specified neighbourhood.
static Coord_t maximumOptimalCellSize(Coord_t radius)
Returns the maximum optimal cell size when using a isolation radius.
template<typename Coord = double>
template<typename Cont >
std::vector<size_t> lar::example::PointIsolationAlg< Coord >::removeIsolatedPoints ( Cont const &  points) const
inline

Returns the set of points that are not isolated.

Parameters
pointslist of the reconstructed space points
Returns
a list of indices of non-isolated points in the vector
See Also
removeIsolatedPoints(PointIter begin, PointIter end) const

Definition at line 202 of file PointIsolationAlg.h.

203  { return removeIsolatedPoints(std::cbegin(points), std::cend(points)); }
auto cbegin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:567
auto cend(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:579
std::vector< size_t > removeIsolatedPoints(PointIter begin, PointIter end) const
Returns the set of points that are not isolated.
template<typename Coord >
void lar::example::PointIsolationAlg< Coord >::validateConfiguration ( Configuration_t const &  config)
static

Throws an exception if the configuration is invalid

Exceptions
std::runtime_errorif configuration is invalid

Definition at line 407 of file PointIsolationAlg.h.

408 {
409  std::vector<std::string> errors;
410  if (config.radius2 < Coord_t(0)) {
411  errors.push_back
412  ("invalid radius squared (" + std::to_string(config.radius2) + ")");
413  }
414  if (!config.rangeX.valid()) {
415  errors.push_back("invalid x range " + rangeString(config.rangeX));
416  }
417  if (!config.rangeY.valid()) {
418  errors.push_back("invalid y range " + rangeString(config.rangeY));
419  }
420  if (!config.rangeZ.valid()) {
421  errors.push_back("invalid z range " + rangeString(config.rangeZ));
422  }
423 
424  if (errors.empty()) return;
425 
426  // compose the full error message as concatenation:
427  std::string message
428  (std::to_string(errors.size()) + " configuration errors found:");
429 
430  for (auto const& error: errors) message += "\n * " + error;
431  throw std::runtime_error(message);
432 
433 } // lar::example::PointIsolationAlg::validateConfiguration()
Coord Coord_t
Type of coordinate.
Coord_t radius2
square of isolation radius [cm^2]
Range_t rangeY
range in Y of the covered volume
static std::string rangeString(Coord_t from, Coord_t to)
Helper function. Returns a string &quot;(\&lt;from\&gt; to \&lt;to\&gt;)&quot;
Range_t rangeX
range in X of the covered volume
bool valid() const
Returns whether the range is valid (empty is also valid)
std::string to_string(WindowPattern const &pattern)
Range_t rangeZ
range in Z of the covered volume
Configuration_t config
all configuration data

Member Data Documentation

template<typename Coord = double>
Configuration_t lar::example::PointIsolationAlg< Coord >::config
private

all configuration data

Definition at line 253 of file PointIsolationAlg.h.


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