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
17 
18 // support libraries
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  */
48  public:
49 
50  /// Configuration parameters
51  struct Config {
52  using Name = fhicl::Name;
54 
56  Name ("SpacePointLabel"),
57  Comment(
58  "label of the producer used to create"
59  " the recob::SpacePoint collection to be dumped"
60  )
61  };
63  Name ("OutputCategory"),
64  Comment("the category used for the output (useful for filtering)"),
65  "DumpChargedSpacePoints" /* default value */
66  };
67 
68  }; // struct Config
69 
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 //----------------------------------------------------------------------------
96  : EDAnalyzer(config)
99  {}
100 
101 
102 //----------------------------------------------------------------------------
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();
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 //----------------------------------------------------------------------------
132 
133 
134 //----------------------------------------------------------------------------
auto getChargedSpacePoints(Event const &event, art::InputTag inputTag, Args &&...withArgs)
Creates and returns a proxy to space points with associated charge.
Reconstruction base classes.
std::string string
Definition: nybbler.cc:12
Prints the content of all the space points and charge on screen.
ChannelGroupService::Name Name
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string encode() const
Definition: InputTag.cc:97
Offers proxy::ChargedSpacePoints and proxy::SpacePointWithCharge class for recob::SpacePoint with rec...
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
virtual void analyze(art::Event const &event) override
Does the printing.
static Config * config
Definition: config.cpp:1054
std::string fOutputCategory
Category for LogInfo output.
DumpChargedSpacePoints(Parameters const &config)
Constructor.
#define Comment
art::InputTag fInputTag
Input tag of the SpacePoint product.
Event finding and building.