All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Public 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

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...
 
Construction and configuration
 SpacePointIsolationAlg (Config const &config)
 Constructor with configuration validation. More...
 
 SpacePointIsolationAlg (fhicl::ParameterSet const &pset)
 Constructor with configuration validation. More...
 

Public 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_t > 
isolationAlg
 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:
fhicl::ParameterSet config
= 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.

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.

135  : radius2(cet::square(config.radius()))
136  {}
Coord_t radius2
square of isolation radius [cm^2]
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.

149  : SpacePointIsolationAlg(fhicl::Table<Config>(pset, {})())
SpacePointIsolationAlg(Config const &config)
Constructor with configuration validation.

Member Function Documentation

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

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.
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 ( )

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 {
37  PointIsolationAlg_t::validateConfiguration(config);
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]
void fillAlgConfigFromGeometry(PointIsolationAlg_t::Configuration_t &config)
Detects the boundaries of the volume to be sorted from the geometry.
std::unique_ptr< PointIsolationAlg_t > isolationAlg
the actual generic algorithm
do i e

Member Data Documentation

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

Pointer to the geometry to be used.

Definition at line 210 of file SpacePointIsolationAlg.h.

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

the actual generic algorithm

Definition at line 215 of file SpacePointIsolationAlg.h.

Coord_t lar::example::SpacePointIsolationAlg::radius2

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: