LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DumpOpDetBacktrackerRecords_module.cc
Go to the documentation of this file.
1 
9 // lardataobj libraries
11 
12 // framework libraries
18 
19 #include "fhiclcpp/types/Atom.h"
21 
22 namespace sim {
23  class DumpOpDetBacktrackerRecords;
24 } // namespace sim
25 
26 namespace {
27  using namespace fhicl;
28 
30  struct Config {
31  using Name = fhicl::Name;
32  using Comment = fhicl::Comment;
33 
34  fhicl::Atom<art::InputTag> InputOpDetBacktrackerRecord{
35  Name("InputOpDetBacktrackerRecord"),
36  Comment("data product with the OpDetBacktrackerRecord to be dumped")};
37 
38  fhicl::Atom<std::string> OutputCategory{
39  Name("OutputCategory"),
40  Comment("name of the output stream (managed by the message facility)"),
41  "DumpOpDetBacktrackerRecords" /* default value */
42  };
43 
44  }; // struct Config
45 
46 } // local namespace
47 
49 public:
50  // type to enable module parameters description by art
52 
54  explicit DumpOpDetBacktrackerRecords(Parameters const& config);
55 
56  // Plugins should not be copied or assigned.
61 
62  // Operates on the event
63  void analyze(art::Event const& event) override;
64 
78  template <typename Stream>
79  void DumpOpDetBacktrackerRecord(Stream&& out,
80  sim::OpDetBacktrackerRecord const& simchannel,
81  std::string indent = "",
82  bool bIndentFirst = true) const;
83 
84 private:
86  std::string fOutputCategory;
87 
88 }; // class sim::DumpOpDetBacktrackerRecords
89 
90 //------------------------------------------------------------------------------
91 //--- module implementation
92 //---
93 //------------------------------------------------------------------------------
95  : EDAnalyzer(config)
96  , fInputChannels(config().InputOpDetBacktrackerRecord())
97  , fOutputCategory(config().OutputCategory())
98 {}
99 
100 //------------------------------------------------------------------------------
101 template <typename Stream>
103  Stream&& out,
104  sim::OpDetBacktrackerRecord const& channel,
105  std::string indent /* = "" */,
106  bool bIndentFirst /* = true */
107 ) const
108 {
109  if (bIndentFirst) out << indent;
110  channel.Dump(out, indent);
111 } // sim::DumpOpDetBacktrackerRecords::DumpOpDetBacktrackerRecords()
112 
113 //------------------------------------------------------------------------------
115 {
116 
117  // get the particles from the event
118  auto const& OpDetBacktrackerRecord =
119  *(event.getValidHandle<std::vector<sim::OpDetBacktrackerRecord>>(fInputChannels));
120 
122  << "Event " << event.id() << " : data product '" << fInputChannels.encode() << "' contains "
123  << OpDetBacktrackerRecord.size() << " OpDetBacktrackerRecord";
124 
125  unsigned int iOpDetBacktrackerRecord = 0;
126  for (sim::OpDetBacktrackerRecord const& simChannel : OpDetBacktrackerRecord) {
127 
128  // a bit of a header
130  log << "[#" << (iOpDetBacktrackerRecord++) << "] ";
131  DumpOpDetBacktrackerRecord(log, simChannel, " ", false);
132 
133  } // for
135 
136 } // sim::DumpOpDetBacktrackerRecords::analyze()
137 
138 //------------------------------------------------------------------------------
140 
141 //------------------------------------------------------------------------------
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
DumpOpDetBacktrackerRecords(Parameters const &config)
Configuration-checking constructor.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
art::InputTag fInputChannels
name of OpDetBacktrackerRecord&#39;s data product
std::string encode() const
Definition: InputTag.cc:97
Energy deposited on a readout Optical Detector by simulated tracks.
DumpOpDetBacktrackerRecords & operator=(DumpOpDetBacktrackerRecords const &)=delete
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
void Dump(Stream &&out, std::string indent, std::string first_indent) const
Dumps the full content of the OpDetBacktrackerRecord into a stream.
parameter set interface
std::string indent(std::size_t const i)
void analyze(art::Event const &event) override
Monte Carlo Simulation.
void DumpOpDetBacktrackerRecord(Stream &&out, sim::OpDetBacktrackerRecord const &simchannel, std::string indent="", bool bIndentFirst=true) const
Dumps the content of the specified OpDetBacktrackerRecord in the output stream.
Event finding and building.
std::string fOutputCategory
name of the stream for output