All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChargedSpacePointProxyInputMaker_module.cc
Go to the documentation of this file.
1 /**
2  * @file ChargedSpacePointProxyInputMaker_module.cc
3  * @brief Test producer creating a few dummy space points and charges.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date December 20, 2017
6  *
7  */
8 
9 // LArSoft libraries
13 
14 // framework libraries
15 #include "art/Framework/Core/EDProducer.h"
16 #include "art/Framework/Core/ModuleMacros.h"
17 #include "art/Framework/Principal/Event.h"
18 
19 #include "messagefacility/MessageLogger/MessageLogger.h"
20 #include "fhiclcpp/types/Atom.h"
21 #include "fhiclcpp/types/Name.h"
22 #include "fhiclcpp/types/Comment.h"
23 
24 // Boost libraries
25 #include "boost/test/unit_test.hpp"
26 
27 // C/C++ standard libraries
28 #include <memory> // std::make_unique()
29 
30 
31 namespace lar {
32  namespace test {
33 
34  // -------------------------------------------------------------------------
35  /**
36  * @brief Creates some dummy space points and charge.
37  *
38  * The produced space points and charges have completely dummy content.
39  * They are implicitly associated and the amount of charge is as much as
40  * the ID of the space point.
41  *
42  * Configuration parameters
43  * =========================
44  *
45  * * *nPoints* (unsigned integer, default: 10): number of space points to
46  * generate
47  *
48  */
49  class ChargedSpacePointProxyInputMaker: public art::EDProducer {
50  public:
51 
52  struct Config {
53  using Name = fhicl::Name;
54  using Comment = fhicl::Comment;
55 
56  fhicl::Atom<unsigned int> nPoints {
57  Name("nPoints"),
58  Comment("number of points to generate."),
59  10U // default
60  };
61 
62  }; // struct Config
63 
64  using Parameters = art::EDProducer::Table<Config>;
65 
66  explicit ChargedSpacePointProxyInputMaker(Parameters const& config);
67 
68  virtual void produce(art::Event& event) override;
69 
70  private:
71  unsigned int nPoints; ///< Number of points to generate.
72 
73  }; // ChargedSpacePointProxyInputMaker
74 
75  // -------------------------------------------------------------------------
76 
77 
78  } // namespace test
79 } // namespace lar
80 
81 
82 // -----------------------------------------------------------------------------
84  (Parameters const& config)
85  : EDProducer{config}
86  , nPoints(config().nPoints())
87 {
88 
89  // declare production of recob::SpacePoint and recob::PointCharge collections:
91 
92 } // ChargedSpacePointProxyInputMaker::ChargedSpacePointProxyInputMaker()
93 
94 // -----------------------------------------------------------------------------
96 
98 
99  BOOST_TEST(spacePoints.empty());
100 
101  const double err[6U] = { 1.0, 0.0, 1.0, 0.0, 0.0, 1.0 };
102 
103  for (unsigned int iPoint = 0; iPoint < nPoints; ++iPoint) {
104  BOOST_TEST(spacePoints.size() == (std::size_t) iPoint);
105 
106  double const pos[3U]
107  = { double(iPoint), double(2.0 * iPoint), double(4.0 * iPoint) };
108 
109  spacePoints.add(
110  { pos, err, 1.0 /* chisq */, int(iPoint) /* id */ }, // space point
111  { recob::PointCharge::Charge_t(iPoint) } // charge
112  );
113 
114  mf::LogVerbatim("ChargedSpacePointProxyInputMaker")
115  << "[#" << iPoint << "] point: " << spacePoints.lastSpacePoint()
116  << " (ptr: " << spacePoints.lastSpacePointPtr()
117  << "); charge: " << spacePoints.lastCharge()
118  << " (ptr: " << spacePoints.lastChargePtr() << ")";
119 
120  } // for (iPoint)
121  BOOST_TEST(spacePoints.size() == (std::size_t) nPoints);
122 
123  mf::LogInfo("ChargedSpacePointProxyInputMaker")
124  << "Produced " << spacePoints.size() << " points and charges.";
125 
126  spacePoints.put();
127  BOOST_TEST(spacePoints.empty());
128 
129 } // lar::test::ChargedSpacePointProxyInputMaker::produce()
130 
EResult err(const char *call)
static void produces(art::ProducesCollector &producesCollector, std::string const &instanceName={})
Declares the data products being produced.
Information about charge reconstructed in the active volume.
BEGIN_PROLOG vertical distance to the surface Name
float Charge_t
Type for the amount of reconstructed charge.
Definition: PointCharge.h:35
static ChargedSpacePointCollectionCreator forPtrs(art::Event &event, std::string const &instanceName={})
Static function binding a new object to a specific art event.
Helpers to create space points with associated charge.
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test