LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
DumpOpDetBacktrackerRecords_module.cc
Go to the documentation of this file.
1 
10 // nutools libraries
12 
13 // framework libraries
19 #include "fhiclcpp/ParameterSet.h"
20 #include "fhiclcpp/types/Atom.h"
22 
23 
24 namespace sim {
25  class DumpOpDetBacktrackerRecords;
26 } // namespace sim
27 
28 namespace {
29  using namespace fhicl;
30 
32  struct Config {
33  using Name = fhicl::Name;
34  using Comment = fhicl::Comment;
35 
36  fhicl::Atom<art::InputTag> InputOpDetBacktrackerRecord {
37  Name("InputOpDetBacktrackerRecord"),
38  Comment("data product with the OpDetBacktrackerRecord to be dumped")
39  };
40 
41  fhicl::Atom<std::string> OutputCategory {
42  Name("OutputCategory"),
43  Comment("name of the output stream (managed by the message facility)"),
44  "DumpOpDetBacktrackerRecords" /* default value */
45  };
46 
47  }; // struct Config
48 
49 
50 } // local namespace
51 
52 
54  public:
55  // type to enable module parameters description by art
57 
59  explicit DumpOpDetBacktrackerRecords(Parameters const& config);
60 
61  // Plugins should not be copied or assigned.
66 
67 
68  // Operates on the event
69  void analyze(art::Event const& event) override;
70 
71 
85  template <typename Stream>
87  Stream&& out, sim::OpDetBacktrackerRecord const& simchannel,
88  std::string indent = "", bool bIndentFirst = true
89  ) const;
90 
91 
92  private:
93 
95  std::string fOutputCategory;
96 
97 }; // class sim::DumpOpDetBacktrackerRecords
98 
99 
100 //------------------------------------------------------------------------------
101 //--- module implementation
102 //---
103 //------------------------------------------------------------------------------
105  : EDAnalyzer(config)
106  , fInputChannels(config().InputOpDetBacktrackerRecord())
107  , fOutputCategory(config().OutputCategory())
108 {}
109 
110 
111 //------------------------------------------------------------------------------
112 template <typename Stream>
114  Stream&& out, sim::OpDetBacktrackerRecord const& channel,
115  std::string indent /* = "" */, bool bIndentFirst /* = true */
116 ) const {
117  if (bIndentFirst) out << indent;
118  channel.Dump(out, indent);
119 } // sim::DumpOpDetBacktrackerRecords::DumpOpDetBacktrackerRecords()
120 
121 
122 //------------------------------------------------------------------------------
124 
125  // get the particles from the event
126  auto const& OpDetBacktrackerRecord
127  = *(event.getValidHandle<std::vector<sim::OpDetBacktrackerRecord>>(fInputChannels));
128 
129  mf::LogVerbatim(fOutputCategory) << "Event " << event.id()
130  << " : data product '" << fInputChannels.encode() << "' contains "
131  << OpDetBacktrackerRecord.size() << " OpDetBacktrackerRecord";
132 
133  unsigned int iOpDetBacktrackerRecord = 0;
134  for (sim::OpDetBacktrackerRecord const& simChannel: OpDetBacktrackerRecord) {
135 
136  // a bit of a header
138  log << "[#" << (iOpDetBacktrackerRecord++) << "] ";
139  DumpOpDetBacktrackerRecord(log, simChannel, " ", false);
140 
141  } // for
143 
144 } // sim::DumpOpDetBacktrackerRecords::analyze()
145 
146 
147 //------------------------------------------------------------------------------
149 
150 //------------------------------------------------------------------------------
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
DumpOpDetBacktrackerRecords(Parameters const &config)
Configuration-checking constructor.
art::InputTag fInputChannels
name of OpDetBacktrackerRecord&#39;s data product
Energy deposited on a readout Optical Detector by simulated tracks.
DumpOpDetBacktrackerRecords & operator=(DumpOpDetBacktrackerRecords const &)=delete
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
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 encode() const
Definition: InputTag.cc:36
std::string indent(std::size_t const i)
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
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