LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
SpacePointIsolationAlg.h
Go to the documentation of this file.
1 
10 #ifndef LAREXAMPLES_ALGORITHMS_REMOVEISOLATEDSPACEPOINTS_SPACEPOINTISOLATIONALG_H
11 #define LAREXAMPLES_ALGORITHMS_REMOVEISOLATEDSPACEPOINTS_SPACEPOINTISOLATIONALG_H
12 
13 
14 // LArSoft libraries
17 
18 
19 // infrastructure and utilities
20 #include "cetlib/pow.h" // cet::square()
21 #include "fhiclcpp/types/Comment.h"
22 #include "fhiclcpp/types/Name.h"
23 #include "fhiclcpp/types/Atom.h"
24 #include "fhiclcpp/types/Table.h"
25 #include "fhiclcpp/ParameterSet.h"
26 
27 // C/C++ standard libraries
28 #include <vector>
29 #include <type_traits> // std::decay_t<>, std::is_base_of<>
30 #include <memory> // std::unique_ptr<>
31 
32 
33 // forward declarations
34 namespace geo { class GeometryCore; }
35 
36 
37 namespace lar {
38  namespace example {
39 
40  // BEGIN RemoveIsolatedSpacePoints group -----------------------------------
43 
105 
106  public:
108  using Coord_t = std::decay_t<decltype(recob::SpacePoint().XYZ()[0])>;
109 
110 
112  struct Config {
113 
114  using Name = fhicl::Name;
116 
118  Name("radius"),
119  Comment("the radius for the isolation [cm]")
120  };
121 
122  }; // Config
123 
124 
127 
135  : radius2(cet::square(config.radius()))
136  {}
137 
149  : SpacePointIsolationAlg(fhicl::Table<Config>(pset, {})())
150  {}
151 
153 
156 
164  void setup(geo::GeometryCore const& geometry)
165  { geom = &geometry; initialize(); }
166 
168 
169 
181  template <typename PointIter>
182  std::vector<size_t> removeIsolatedPoints
183  (PointIter begin, PointIter end) const
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  }
191 
192 
199  std::vector<size_t> removeIsolatedPoints
200  (std::vector<recob::SpacePoint> const& points) const
201  { return removeIsolatedPoints(points.begin(), points.end()); }
202 
203 
204 
205  private:
208 
210  geo::GeometryCore const* geom = nullptr;
211 
213 
215  std::unique_ptr<PointIsolationAlg_t> isolationAlg;
216 
218  void initialize();
219 
221  void fillAlgConfigFromGeometry
223 
224  }; // class SpacePointIsolationAlg
225 
226 
227  //--------------------------------------------------------------------------
228  //--- PositionExtractor<recob::SpacePoint>
229 
235  template <>
236  struct PositionExtractor<recob::SpacePoint> {
237 
239  static double x(recob::SpacePoint const& p) { return p.XYZ()[0]; }
240 
242  static double y(recob::SpacePoint const& p) { return p.XYZ()[1]; }
243 
245  static double z(recob::SpacePoint const& p) { return p.XYZ()[2]; }
246 
247  }; // PositionExtractor<recob::SpacePoint>
248 
250  // END RemoveIsolatedSpacePoints group -------------------------------------
251 
252  } // namespace example
253 } // namespace lar
254 
255 
256 
257 
258 
259 #endif // LAREXAMPLES_ALGORITHMS_REMOVEISOLATEDSPACEPOINTS_SPACEPOINTISOLATIONALG_H
Algorithm to detect isolated space points.
SpacePointIsolationAlg(fhicl::ParameterSet const &pset)
Constructor with configuration validation.
Coord_t radius2
square of isolation radius [cm^2]
Reconstruction base classes.
static double x(recob::SpacePoint const &p)
Return x coordinate of the space point position.
std::decay_t< decltype(recob::SpacePoint().XYZ()[0])> Coord_t
Type of coordinate in recob::SpacePoint (double in LArSoft 5)
Helper extractor for point coordinates.
void setup(geo::GeometryCore const &geometry)
Sets up the algorithm.
Algorithm to detect isolated space points.
std::unique_ptr< PointIsolationAlg_t > isolationAlg
the actual generic algorithm
parameter set interface
Type containing all configuration parameters of the algorithm.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
const Double32_t * XYZ() const
Definition: SpacePoint.h:65
Double_t radius
Description of geometry of one entire detector.
static double y(recob::SpacePoint const &p)
Return y coordinate of the space point position.
Algorithm(s) dealing with point isolation in space.
std::string value(boost::any const &)
LArSoft-specific namespace.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
static double z(recob::SpacePoint const &p)
Return z coordinate of the space point position.
Namespace collecting geometry-related classes utilities.
SpacePointIsolationAlg(Config const &config)
Constructor with configuration validation.