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