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"
14 
15 // framework libraries
20 #include "fhiclcpp/types/Atom.h"
21 
22 // C/C++ standard libraries
23 #include <memory> // std::make_unique()
24 
25 
26 namespace lar {
27  namespace example {
28  namespace tests {
29 
30  // BEGIN RemoveIsolatedSpacePoints group ---------------------------------
31  /// @ingroup RemoveIsolatedSpacePoints
32  /// @{
33  /**
34  * @brief Creates a collection of space points
35  *
36  * A collection of space points is added to the event.
37  * The points are spaced by the value of the `spacing` configuration
38  * parameter, in a cubic grid. Each TPC is independently filled,
39  * so that the TPC centre hosts a space point.
40  *
41  * The space points are not associated to anything.
42  *
43  * Configuration parameters
44  * =========================
45  *
46  * * *spacing* (real, _mandatory_): spacing between the points [cm]
47  *
48  */
50 
51  public:
52 
53  struct Config {
54 
55  using Name = fhicl::Name;
57 
59  Name("spacing"),
60  Comment("spacing between points [cm]")
61  };
62 
63  }; // Config
64 
66 
67  /// Constructor; see the class documentation for the configuration
68  explicit SpacePointMaker(Parameters const& config);
69 
70  /// Create and add the points on each event (although they are the same)
71  virtual void produce(art::Event& event) override;
72 
73  private:
74 
75  double spacing; ///< step size [cm]
76 
77  }; // class SpacePointMaker
78 
79  /// @}
80  // END RemoveIsolatedSpacePoints group -----------------------------------
81 
82 
83  } // namespace tests
84  } // namespace example
85 } // namespace lar
86 
87 
88 //------------------------------------------------------------------------------
89 //--- module implementation
90 //---
91 
93  : EDProducer{config}
94  , spacing(config().spacing())
95 {
96  produces<std::vector<recob::SpacePoint>>();
97 } // lar::example::tests::SpacePointMaker::SpacePointMaker()
98 
99 
100 //------------------------------------------------------------------------------
102 
103  //
104  // set up
105  //
106 
107  // container for the data product
108  auto spacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
109 
110  // acquire the geometry information
111  auto const* geom = lar::providerFrom<geo::Geometry>();
112 
113  //
114  // creation of the points
115  //
116 
117  // fill each TPC independently
118  for (auto const& TPC: geom->IterateTPCs()) {
119 
120  FillSpacePointGrid(*spacePoints, TPC, spacing);
121 
122  } // for TPC
123 
124  //
125  // result storage
126  //
127  mf::LogInfo("SpacePointMaker")
128  << "Created " << spacePoints->size() << " space points using spacing "
129  << spacing << " cm";
130 
131  event.put(std::move(spacePoints));
132 
133 } // lar::example::tests::SpacePointMaker::produce()
134 
135 
136 //------------------------------------------------------------------------------
138 
139 //------------------------------------------------------------------------------
Utilities for tests based on space points.
Creates a collection of space points.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
ChannelGroupService::Name Name
art framework interface to geometry description
SpacePointMaker(Parameters const &config)
Constructor; see the class documentation for the configuration.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
static Config * config
Definition: config.cpp:1054
def move(depos, offset)
Definition: depos.py:107
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)
#define Comment
LArSoft-specific namespace.
Event finding and building.