LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
RemoveIsolatedSpacePoints_module.cc
Go to the documentation of this file.
1 
14 // LArSoft libraries
18 
19 // framework libraries
23 #include "art/Framework/Principal/Handle.h" // art::ValidHandle
26 #include "fhiclcpp/types/Atom.h"
27 #include "fhiclcpp/types/Table.h"
28 
29 // C/C++ standard libraries
30 #include <vector>
31 #include <memory> // std::make_unique()
32 
33 
34 namespace lar {
35  namespace example {
36 
72 
73  public:
74 
76  struct Config {
77 
78  using Name = fhicl::Name;
80 
82  Name("spacePoints"),
83  Comment("the space points to be filtered")
84  };
85 
87  Name("isolation"),
88  Comment("settings for the isolation algorithm")
89  };
90 
91  }; // Config
92 
95 
97  explicit RemoveIsolatedSpacePoints(Parameters const& config);
98 
99 
100  virtual void produce(art::Event& event) override;
101 
102 
103  private:
105 
107 
108  }; // class RemoveIsolatedSpacePoints
109 
110 
111  } // namespace example
112 } // namespace lar
113 
114 
115 
116 //------------------------------------------------------------------------------
117 //--- RemoveIsolatedSpacePoints
118 //---
120  (Parameters const& config)
121  : spacePointsLabel(config().spacePoints())
122  , isolAlg(config().isolation())
123 {
124  consumes<std::vector<recob::SpacePoint>>(spacePointsLabel);
125  produces<std::vector<recob::SpacePoint>>();
126 } // lar::example::RemoveIsolatedSpacePoints::RemoveIsolatedSpacePoints()
127 
128 
129 //------------------------------------------------------------------------------
131 
132  //
133  // read the input
134  //
135  auto spacePointHandle
136  = event.getValidHandle<std::vector<recob::SpacePoint>>(spacePointsLabel);
137 
138  //
139  // set up the algorithm
140  //
141  auto const* geom = lar::providerFrom<geo::Geometry>();
142  isolAlg.setup(*geom);
143 
144  //
145  // run the algorithm
146  //
147 
148  // the return value is a list of indices of non-isolated space points
149  auto const& spacePoints = *spacePointHandle;
150  std::vector<size_t> socialPointIndices
152 
153  //
154  // extract and save the results
155  //
156  auto socialSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
157 
158  socialSpacePoints->reserve(socialPointIndices.size()); // preallocate
159  for (size_t index: socialPointIndices)
160  socialSpacePoints->push_back(spacePoints[index]);
161 
162  mf::LogInfo("RemoveIsolatedSpacePoints")
163  << "Found " << socialSpacePoints->size() << "/" << spacePoints.size()
164  << " isolated space points in '" << spacePointsLabel.encode() << "'";
165 
166  event.put(std::move(socialSpacePoints));
167 
168 } // lar::example::RemoveIsolatedSpacePoints::produce()
169 
170 
171 //------------------------------------------------------------------------------
173 
174 
175 //------------------------------------------------------------------------------
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
fhicl::Table< SpacePointIsolationAlg::Config > isolation
void setup(geo::GeometryCore const &geometry)
Sets up the algorithm.
art::InputTag spacePointsLabel
label of the input data product
art module: removes isolated space points.
Algorithm(s) dealing with space point isolation in space.
Algorithm to detect isolated space points.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
std::string encode() const
Definition: InputTag.cc:36
SpacePointIsolationAlg isolAlg
instance of the algorithm
RemoveIsolatedSpacePoints(Parameters const &config)
Constructor; see the class documentation for the configuration.
std::vector< size_t > removeIsolatedPoints(PointIter begin, PointIter end) const
Returns the set of reconstructed 3D points that are not isolated.
LArSoft-specific namespace.
virtual void produce(art::Event &event) override
art framework interface to geometry description
Event finding and building.