RemoveIsolatedSpacePoints_module.cc
Go to the documentation of this file.
1 /**
2  * @file RemoveIsolatedSpacePoints_module.cc
3  * @brief Module running `lar::example::SpacePointIsolationAlg` algorithm
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date June 3, 2016
6  * @ingroup RemoveIsolatedSpacePoints
7  *
8  * Provides:
9  *
10  * * `lar::example::RemoveIsolatedSpacePoints` module
11  *
12  */
13 
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 <memory> // std::make_unique()
31 
32 
33 namespace lar {
34  namespace example {
35 
36  /**
37  * @brief _art_ module: removes isolated space points.
38  * @see @ref RemoveIsolatedSpacePoints "RemoveIsolatedSpacePoints example overview"
39  * @ingroup RemoveIsolatedSpacePoints
40  *
41  * A new collection of space points is added to the event, that contains
42  * only the space points that are not isolated.
43  *
44  * Isolation is determined by the `SpacePointIsolationAlg` algorithm.
45  *
46  * The space points are not associated to anything.
47  *
48  * Input
49  * ------
50  *
51  * A collection of `recob::SpacePoint` is required.
52  *
53  *
54  * Output
55  * ------
56  *
57  * A collection of `recob::SpacePoint` is produced, containing copies of
58  * the non-isolated inpt points.
59  *
60  *
61  * Configuration parameters
62  * =========================
63  *
64  * * *spacePoints* (input tag, _mandatory_): label of the data product with
65  * input space points
66  * * *isolation* (parameter set, _mandatory_): configuration for the
67  * isolation algorithm (see `SpacePointIsolationAlg` documentation)
68  *
69  */
71 
72  public:
73 
74  /// Module configuration data
75  struct Config {
76 
77  using Name = fhicl::Name;
79 
81  Name("spacePoints"),
82  Comment("the space points to be filtered")
83  };
84 
86  Name("isolation"),
87  Comment("settings for the isolation algorithm")
88  };
89 
90  }; // Config
91 
92  /// Standard _art_ alias for module configuration table
94 
95  /// Constructor; see the class documentation for the configuration
97 
98 
99  virtual void produce(art::Event& event) override;
100 
101 
102  private:
103  art::InputTag spacePointsLabel; ///< label of the input data product
104 
105  SpacePointIsolationAlg isolAlg; ///< instance of the algorithm
106 
107  }; // class RemoveIsolatedSpacePoints
108 
109 
110  } // namespace example
111 } // namespace lar
112 
113 
114 
115 //------------------------------------------------------------------------------
116 //--- RemoveIsolatedSpacePoints
117 //---
120  : EDProducer{config}
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
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
ChannelGroupService::Name Name
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.
std::string encode() const
Definition: InputTag.cc:97
art framework interface to geometry description
Algorithm(s) dealing with space point isolation in space.
Algorithm to detect isolated space points.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
static Config * config
Definition: config.cpp:1054
def move(depos, offset)
Definition: depos.py:107
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.
#define Comment
LArSoft-specific namespace.
virtual void produce(art::Event &event) override
Event finding and building.