All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DumpChargedSpacePoints_module.cc
Go to the documentation of this file.
1 /**
2  * @file DumpChargedSpacePoints_module.cc
3  * @brief Dumps on screen the content of space points and associated charge.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date December 22nd, 2017
6  */
7 
8 // LArSoft includes
11 
12 // art libraries
13 #include "canvas/Utilities/InputTag.h"
14 #include "art/Framework/Core/EDAnalyzer.h"
15 #include "art/Framework/Core/ModuleMacros.h"
16 #include "art/Framework/Principal/Event.h"
17 
18 // support libraries
19 #include "messagefacility/MessageLogger/MessageLogger.h"
20 #include "fhiclcpp/types/Atom.h" // also pulls in fhicl::Name and fhicl::Comment
21 
22 // C//C++ standard libraries
23 #include <string>
24 
25 
26 namespace recob {
27 
28  /**
29  * @brief Prints the content of all the space points and charge on screen.
30  *
31  * This analyser prints the content of all the space points into the
32  * LogInfo/LogVerbatim stream.
33  *
34  * The space point and charge data products must fulfil the requirements of
35  * the `proxy::ChargedSpacePoints` proxy.
36  *
37  * Configuration parameters
38  * =========================
39  *
40  * - *SpacePointLabel* (`art::InputTag`, mandatory): label of the
41  * producer used to create the `recob::SpacePoint` _and_
42  * `recob::PointCharge` collections to be dumped
43  * - *OutputCategory* (string, default: "DumpChargedSpacePoints"): the
44  * category used for the output (useful for filtering)
45  *
46  */
47  class DumpChargedSpacePoints: public art::EDAnalyzer {
48  public:
49 
50  /// Configuration parameters
51  struct Config {
52  using Name = fhicl::Name;
53  using Comment = fhicl::Comment;
54 
55  fhicl::Atom<art::InputTag> SpacePointTag {
56  Name ("SpacePointLabel"),
57  Comment(
58  "label of the producer used to create"
59  " the recob::SpacePoint collection to be dumped"
60  )
61  };
62  fhicl::Atom<std::string> OutputCategory {
63  Name ("OutputCategory"),
64  Comment("the category used for the output (useful for filtering)"),
65  "DumpChargedSpacePoints" /* default value */
66  };
67 
68  }; // struct Config
69 
70  using Parameters = art::EDAnalyzer::Table<Config>;
71 
72 
73  /// Constructor.
74  explicit DumpChargedSpacePoints(Parameters const& config);
75 
76  /// Does the printing.
77  virtual void analyze (art::Event const& event) override;
78 
79  private:
80 
81  art::InputTag fInputTag; ///< Input tag of the SpacePoint product.
82  std::string fOutputCategory; ///< Category for LogInfo output.
83 
84  }; // class DumpChargedSpacePoints
85 
86 } // namespace recob
87 
88 
89 //==============================================================================
90 //=== Implementation section
91 //==============================================================================
92 
93 //----------------------------------------------------------------------------
95  (art::EDAnalyzer::Table<Config> const& config)
96  : EDAnalyzer(config)
97  , fInputTag(config().SpacePointTag())
98  , fOutputCategory(config().OutputCategory())
99  {}
100 
101 
102 //----------------------------------------------------------------------------
103 void recob::DumpChargedSpacePoints::analyze(art::Event const& event) {
104 
105  //
106  // collect all the available information
107  //
108  // fetch the data to be dumped on screen
109  auto const& points = proxy::getChargedSpacePoints(event, fInputTag);
110 
111  size_t const nPoints = points.size();
112  mf::LogVerbatim log(fOutputCategory);
113  log
114  << "The event " << event.id()
115  << " contains " << nPoints
116  << " space points from '" << fInputTag.encode() << "'";
117 
118  for (auto const& point: points) {
119 
120  log << "\n [#" << point.index() << "] "
121  << point.point() << " " << point.charge();
122 
123  } // for
124 
125  log << "\n"; // two empty lines
126 
127 } // DumpChargedSpacePoints::analyze()
128 
129 
130 //----------------------------------------------------------------------------
131 DEFINE_ART_MODULE(recob::DumpChargedSpacePoints)
132 
133 
134 //----------------------------------------------------------------------------
auto getChargedSpacePoints(Event const &event, art::InputTag inputTag, Args &&...withArgs)
Creates and returns a proxy to space points with associated charge.
Prints the content of all the space points and charge on screen.
Offers proxy::ChargedSpacePoints and proxy::SpacePointWithCharge class for recob::SpacePoint with rec...
virtual void analyze(art::Event const &event) override
Does the printing.
BEGIN_PROLOG vertical distance to the surface Name
art::EDAnalyzer::Table< Config > Parameters
std::string fOutputCategory
Category for LogInfo output.
DumpChargedSpacePoints(Parameters const &config)
Constructor.
art::InputTag fInputTag
Input tag of the SpacePoint product.