Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
lar::example::SpacePointIsolationAlg Class Reference

Algorithm to detect isolated space points. More...

#include <SpacePointIsolationAlg.h>

Classes

struct  Config
 Algorithm configuration. More...
 

Public Types

using Coord_t = std::decay_t< decltype(recob::SpacePoint().XYZ()[0])>
 Type of coordinate in recob::SpacePoint (double in LArSoft 5) More...
 

Public Member Functions

template<typename PointIter >
std::vector< size_t > removeIsolatedPoints (PointIter begin, PointIter end) const
 Returns the set of reconstructed 3D points that are not isolated. More...
 
std::vector< size_t > removeIsolatedPoints (std::vector< recob::SpacePoint > const &points) const
 Returns the set of reconstructed 3D points that are not isolated. More...
 
Construction and configuration
 SpacePointIsolationAlg (Config const &config)
 Constructor with configuration validation. More...
 
 SpacePointIsolationAlg (fhicl::ParameterSet const &pset)
 Constructor with configuration validation. More...
 
Set up
void setup (geo::GeometryCore const &geometry)
 Sets up the algorithm. More...
 

Private Types

using PointIsolationAlg_t = PointIsolationAlg< Coord_t >
 Type of isolation algorithm. More...
 

Private Member Functions

void initialize ()
 Initialises the algorithm with the current configuration and setup. More...
 
void fillAlgConfigFromGeometry (PointIsolationAlg_t::Configuration_t &config)
 Detects the boundaries of the volume to be sorted from the geometry. More...
 

Private Attributes

geo::GeometryCore const * geom = nullptr
 Pointer to the geometry to be used. More...
 
Coord_t radius2
 square of isolation radius [cm^2] More...
 
std::unique_ptr< PointIsolationAlg_tisolationAlg
 the actual generic algorithm More...
 

Detailed Description

Algorithm to detect isolated space points.

See also
RemoveIsolatedSpacePoints example overview

This algorithm applies the isolation algorithm implemented in PointIsolationAlg to a collection of recob::SpacePoint objects.

Usage example

//
// preparation
//
// get the algorithm configuration; in art:
= pset.get<fhicl::ParameterSet>("isolation");
// get the geometry service provider; in art:
geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
// get the input data; in art:
std::vector<recob::SpacePoint> const& points
= *(event.getValidHandle<std::vector<recob::SpacePoint>>("sps"));
//
// algorithm execution
//
// construct and configure
lar::examples::SpacePointIsolationAlg algo(config);
// set up
// (might be needed again if geometry changed, e.g. between runs)
algo.Setup(*geom);
// execution
std::vector<size_t> nonIsolatedPointIndices
= algo.removeIsolatedPoints(points);
//
// use of results
//
// e.g. create a collection of pointers to non-isolated points
std::vector<recob::SpacePoint const*> nonIsolatedPoints;
nonIsolatedPoints.reserve(nonIsolatedPointIndices.size());
recob::SpacePoint const* basePoint = &(points.front());
for (size_t index: nonIsolatedPointIndices)
nonIsolatedPoints.push_back(basePoint + index);

Configuration parameters

Definition at line 104 of file SpacePointIsolationAlg.h.

Member Typedef Documentation

using lar::example::SpacePointIsolationAlg::Coord_t = std::decay_t<decltype(recob::SpacePoint().XYZ()[0])>

Type of coordinate in recob::SpacePoint (double in LArSoft 5)

Definition at line 108 of file SpacePointIsolationAlg.h.

Type of isolation algorithm.

Definition at line 207 of file SpacePointIsolationAlg.h.

Constructor & Destructor Documentation

lar::example::SpacePointIsolationAlg::SpacePointIsolationAlg ( Config const &  config)
inline

Constructor with configuration validation.

Parameters
configconfiguration parameter structure

For the configuration, see SpacePointIsolationAlg documentation.

Definition at line 134 of file SpacePointIsolationAlg.h.

136  {}
Coord_t radius2
square of isolation radius [cm^2]
constexpr T square(T x)
Definition: pow.h:21
static Config * config
Definition: config.cpp:1054
lar::example::SpacePointIsolationAlg::SpacePointIsolationAlg ( fhicl::ParameterSet const &  pset)
inline

Constructor with configuration validation.

Parameters
psetFHiCL configuration parameter set
See also
SpacePointIsolationAlg(Config const&)

Translates the parameter set into a configuration object and uses the validating constructor to initialise the object.

For the configuration, see SpacePointIsolationAlg documentation.

Definition at line 148 of file SpacePointIsolationAlg.h.

150  {}
SpacePointIsolationAlg(Config const &config)
Constructor with configuration validation.

Member Function Documentation

void lar::example::SpacePointIsolationAlg::fillAlgConfigFromGeometry ( PointIsolationAlg_t::Configuration_t config)
private

Detects the boundaries of the volume to be sorted from the geometry.

Definition at line 51 of file SpacePointIsolationAlg.cxx.

52 {
53  // merge the volumes from all TPCs
54  auto iTPC = geom->begin_TPC(), tpcend = geom->end_TPC();
55 
56  // a TPC is (also) a bounded box:
58 
59  while (++iTPC != tpcend) box.ExtendToInclude(*iTPC);
60 
61  // convert the box into the configuration structure
62  config.rangeX = { box.MinX(), box.MaxX() };
63  config.rangeY = { box.MinY(), box.MaxY() };
64  config.rangeZ = { box.MinZ(), box.MaxZ() };
65 
66 } // lar::example::SpacePointIsolationAlg::fillAlgConfigFromGeometry()
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
TPC_iterator begin_TPC() const
Returns an iterator pointing to the first TPC in the detector.
static Config * config
Definition: config.cpp:1054
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxY() const
Returns the world y coordinate of the end of the box.
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:33
double MaxZ() const
Returns the world z coordinate of the end of the box.
void ExtendToInclude(Coord_t x, Coord_t y, Coord_t z)
Extends the current box to also include the specified point.
double MinY() const
Returns the world y coordinate of the start of the box.
TPC_iterator end_TPC() const
Returns an iterator pointing after the last TPC in the detector.
geo::GeometryCore const * geom
Pointer to the geometry to be used.
void lar::example::SpacePointIsolationAlg::initialize ( )
private

Initialises the algorithm with the current configuration and setup.

Definition at line 28 of file SpacePointIsolationAlg.cxx.

28  {
29 
30  PointIsolationAlg_t::Configuration_t config;
31 
32  config.radius2 = radius2; // square of isolation radius [cm^2]
34 
35  // proceed to validate the configuration we are going to use
36  try {
38  }
39  catch (std::runtime_error const& e) {
40  throw cet::exception("SpacePointIsolationAlg")
41  << "Error in PointIsolationAlg configuration: " << e.what() << "\n";
42  }
43 
44  if (isolationAlg) isolationAlg->reconfigure(config);
45  else isolationAlg = std::make_unique<PointIsolationAlg_t>(config);
46 
47 } // lar::example::SpacePointIsolationAlg::initialize()
Coord_t radius2
square of isolation radius [cm^2]
const double e
void fillAlgConfigFromGeometry(PointIsolationAlg_t::Configuration_t &config)
Detects the boundaries of the volume to be sorted from the geometry.
static Config * config
Definition: config.cpp:1054
std::unique_ptr< PointIsolationAlg_t > isolationAlg
the actual generic algorithm
static void validateConfiguration(Configuration_t const &config)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename PointIter >
std::vector<size_t> lar::example::SpacePointIsolationAlg::removeIsolatedPoints ( PointIter  begin,
PointIter  end 
) const
inline

Returns the set of reconstructed 3D points that are not isolated.

Template Parameters
PointIterrandom access iterator to a space point
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
PointIsolationAlg::removeIsolatedPoints(PointIter, PointIter) const

This method can use iterators from any collection of input space points.

Definition at line 183 of file SpacePointIsolationAlg.h.

184  {
185  static_assert(
186  std::is_base_of<recob::SpacePoint, std::decay_t<decltype(*begin)>>::value,
187  "iterator does not point to recob::SpacePoint"
188  );
189  return isolationAlg->removeIsolatedPoints(begin, end);
190  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::unique_ptr< PointIsolationAlg_t > isolationAlg
the actual generic algorithm
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
std::vector<size_t> lar::example::SpacePointIsolationAlg::removeIsolatedPoints ( std::vector< recob::SpacePoint > const &  points) const
inline

Returns the set of reconstructed 3D 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, PointIter) const

Definition at line 200 of file SpacePointIsolationAlg.h.

201  { return removeIsolatedPoints(points.begin(), points.end()); }
std::vector< size_t > removeIsolatedPoints(PointIter begin, PointIter end) const
Returns the set of reconstructed 3D points that are not isolated.
void lar::example::SpacePointIsolationAlg::setup ( geo::GeometryCore const &  geometry)
inline

Sets up the algorithm.

Parameters
geometrythe geometry service provider

Acquires the geometry description. This method must be called every time the geometry is changed.

Definition at line 164 of file SpacePointIsolationAlg.h.

165  { geom = &geometry; initialize(); }
void initialize()
Initialises the algorithm with the current configuration and setup.
geo::GeometryCore const * geom
Pointer to the geometry to be used.

Member Data Documentation

geo::GeometryCore const* lar::example::SpacePointIsolationAlg::geom = nullptr
private

Pointer to the geometry to be used.

Definition at line 210 of file SpacePointIsolationAlg.h.

std::unique_ptr<PointIsolationAlg_t> lar::example::SpacePointIsolationAlg::isolationAlg
private

the actual generic algorithm

Definition at line 215 of file SpacePointIsolationAlg.h.

Coord_t lar::example::SpacePointIsolationAlg::radius2
private

square of isolation radius [cm^2]

Definition at line 212 of file SpacePointIsolationAlg.h.


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