LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DumpOpHits_module.cc
Go to the documentation of this file.
1 
8 // LArSoft libraries
11 
12 // art libraries
17 
18 // support libraries
19 #include "fhiclcpp/types/Atom.h"
20 #include "fhiclcpp/types/Comment.h"
21 #include "fhiclcpp/types/Name.h"
23 
24 // C//C++ standard libraries
25 #include <ostream>
26 #include <string>
27 #include <vector>
28 
29 // -----------------------------------------------------------------------------
30 namespace ophit {
31  class DumpOpHits;
32 }
33 
50 public:
51  struct Config {
52  using Name = fhicl::Name;
54 
56  Name{"OpHitModuleLabel"},
57  Comment{"tag of the recob::OpHit collection to be dumped"}};
58 
60  Name("OutputCategory"),
61  Comment("the messagefacility category used for the output"),
62  "DumpOpHits"};
63 
64  }; // Config
65 
67 
69  explicit DumpOpHits(Parameters const& config);
70 
72  void analyze(const art::Event& evt) override;
73 
74 private:
76  std::string const fOutputCategory;
77 
78 }; // class ophit::DumpOpHits
79 
80 // -----------------------------------------------------------------------------
81 // --- implementation
82 // -----------------------------------------------------------------------------
84  : art::EDAnalyzer(config)
85  , fOpHitModuleTag(config().OpHitModuleLabel())
86  , fOutputCategory(config().OutputCategory())
87 {
88  consumes<std::vector<recob::OpHit>>(fOpHitModuleTag);
89 }
90 
91 //------------------------------------------------------------------------------
93 {
94 
95  // fetch the data to be dumped on screen
96  auto const& OpHits = event.getProduct<std::vector<recob::OpHit>>(fOpHitModuleTag);
97 
98  mf::LogVerbatim(fOutputCategory) << "Event " << event.id() << " contains " << OpHits.size()
99  << " '" << fOpHitModuleTag.encode() << "' optical hits.";
100 
101  for (auto const& [iHit, hit] : util::enumerate(OpHits))
102  mf::LogVerbatim(fOutputCategory) << "OpHit #" << iHit << ": " << hit;
103 
104 } // ophit::DumpOpHits::analyze()
105 
106 //------------------------------------------------------------------------------
108 
109 //------------------------------------------------------------------------------
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Definition of util::enumerate().
DumpOpHits(Parameters const &config)
Default constructor.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
std::string encode() const
Definition: InputTag.cc:97
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:65
Prints the content of all the hits on screen.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
fhicl::Atom< std::string > OutputCategory
void analyze(const art::Event &evt) override
Does the printing.
Detector simulation of raw signals on wires.
std::string const fOutputCategory
Category for mf::LogInfo output.
Definition: MVAAlg.h:12
fhicl::Atom< art::InputTag > OpHitModuleLabel
TCEvent evt
Definition: DataStructs.cxx:8
Event finding and building.
art::InputTag const fOpHitModuleTag
Optical hit data product tag.