All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpacePointMaker_module.cc
Go to the documentation of this file.
1 /**
2  * @file SpacePointMaker_module.cc
3  * @brief Module creating space points for a test
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date June 3, 2016
6  * @ingroup RemoveIsolatedSpacePoints
7  *
8  */
9 
10 // LArSoft libraries
11 #include "SpacePointTestUtils.h"
15 
16 // framework libraries
17 #include "art/Framework/Core/EDProducer.h"
18 #include "art/Framework/Core/ModuleMacros.h"
19 #include "art/Framework/Principal/Event.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
21 #include "fhiclcpp/types/Atom.h"
22 
23 // C/C++ standard libraries
24 #include <memory> // std::make_unique()
25 
26 
27 namespace lar {
28  namespace example {
29  namespace tests {
30 
31  // BEGIN RemoveIsolatedSpacePoints group ---------------------------------
32  /// @ingroup RemoveIsolatedSpacePoints
33  /// @{
34  /**
35  * @brief Creates a collection of space points
36  *
37  * A collection of space points is added to the event.
38  * The points are spaced by the value of the `spacing` configuration
39  * parameter, in a cubic grid. Each TPC is independently filled,
40  * so that the TPC centre hosts a space point.
41  *
42  * The space points are not associated to anything.
43  *
44  * Configuration parameters
45  * =========================
46  *
47  * * *spacing* (real, _mandatory_): spacing between the points [cm]
48  *
49  */
50  class SpacePointMaker: public art::EDProducer {
51 
52  public:
53 
54  struct Config {
55 
56  using Name = fhicl::Name;
57  using Comment = fhicl::Comment;
58 
59  fhicl::Atom<double> spacing{
60  Name("spacing"),
61  Comment("spacing between points [cm]")
62  };
63 
64  }; // Config
65 
66  using Parameters = art::EDProducer::Table<Config>;
67 
68  /// Constructor; see the class documentation for the configuration
69  explicit SpacePointMaker(Parameters const& config);
70 
71  /// Create and add the points on each event (although they are the same)
72  virtual void produce(art::Event& event) override;
73 
74  private:
75 
76  double spacing; ///< step size [cm]
77 
78  }; // class SpacePointMaker
79 
80  /// @}
81  // END RemoveIsolatedSpacePoints group -----------------------------------
82 
83 
84  } // namespace tests
85  } // namespace example
86 } // namespace lar
87 
88 
89 //------------------------------------------------------------------------------
90 //--- module implementation
91 //---
92 
94  : EDProducer{config}
95  , spacing(config().spacing())
96 {
97  produces<std::vector<recob::SpacePoint>>();
98 } // lar::example::tests::SpacePointMaker::SpacePointMaker()
99 
100 
101 //------------------------------------------------------------------------------
103 
104  //
105  // set up
106  //
107 
108  // container for the data product
109  auto spacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
110 
111  // acquire the geometry information
112  auto const* geom = lar::providerFrom<geo::Geometry>();
113 
114  //
115  // creation of the points
116  //
117 
118  // fill each TPC independently
119  for (auto const& TPC: geom->IterateTPCs()) {
120 
121  FillSpacePointGrid(*spacePoints, TPC, spacing);
122 
123  } // for TPC
124 
125  //
126  // result storage
127  //
128  mf::LogInfo("SpacePointMaker")
129  << "Created " << spacePoints->size() << " space points using spacing "
130  << spacing << " cm";
131 
132  event.put(std::move(spacePoints));
133 
134 } // lar::example::tests::SpacePointMaker::produce()
135 
136 
137 //------------------------------------------------------------------------------
138 DEFINE_ART_MODULE(lar::example::tests::SpacePointMaker)
139 
140 //------------------------------------------------------------------------------
Utilities for tests based on space points.
Utilities related to art service access.
Creates a collection of space points.
BEGIN_PROLOG TPC
SpacePointMaker(Parameters const &config)
Constructor; see the class documentation for the configuration.
BEGIN_PROLOG vertical distance to the surface Name
unsigned int FillSpacePointGrid(std::vector< recob::SpacePoint > &spacePoints, geo::BoxBoundedGeo const &box, double stepSize)
Creates space points distributed in a grid.
virtual void produce(art::Event &event) override
Create and add the points on each event (although they are the same)
art::EDProducer::Table< Config > Parameters
art framework interface to geometry description