LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
DumpSimChannels_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 DumpSimChannels;
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> InputSimChannels {
37  Name("InputSimChannels"),
38  Comment("data product with the SimChannels 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  "DumpSimChannels" /* 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 DumpSimChannels(Parameters const& config);
60 
61  // Plugins should not be copied or assigned.
62  DumpSimChannels(DumpSimChannels const&) = delete;
63  DumpSimChannels(DumpSimChannels &&) = delete;
66 
67 
68  // Operates on the event
69  void analyze(art::Event const& event) override;
70 
71 
85  template <typename Stream>
86  void DumpSimChannel(
87  Stream&& out, sim::SimChannel const& simchannel,
88  std::string indent = "", bool bIndentFirst = true
89  ) const;
90 
91 
92  private:
93 
95  std::string fOutputCategory;
96 
97 }; // class sim::DumpSimChannels
98 
99 
100 //------------------------------------------------------------------------------
101 //--- module implementation
102 //---
103 //------------------------------------------------------------------------------
105  : EDAnalyzer(config)
106  , fInputChannels(config().InputSimChannels())
107  , fOutputCategory(config().OutputCategory())
108 {}
109 
110 
111 //------------------------------------------------------------------------------
112 template <typename Stream>
114  Stream&& out, sim::SimChannel const& channel,
115  std::string indent /* = "" */, bool bIndentFirst /* = true */
116 ) const {
117  if (bIndentFirst) out << indent;
118  channel.Dump(out, indent);
119 } // sim::DumpSimChannels::DumpSimChannels()
120 
121 
122 //------------------------------------------------------------------------------
124 
125  // get the particles from the event
126  auto const& SimChannels
127  = *(event.getValidHandle<std::vector<sim::SimChannel>>(fInputChannels));
128 
129  mf::LogVerbatim(fOutputCategory) << "Event " << event.id()
130  << " : data product '" << fInputChannels.encode() << "' contains "
131  << SimChannels.size() << " SimChannels";
132 
133  unsigned int iSimChannel = 0;
134  for (sim::SimChannel const& simChannel: SimChannels) {
135 
136  // a bit of a header
138  log << "[#" << (iSimChannel++) << "] ";
139  DumpSimChannel(log, simChannel, " ", false);
140 
141  } // for
143 
144 } // sim::DumpSimChannels::analyze()
145 
146 
147 //------------------------------------------------------------------------------
149 
150 //------------------------------------------------------------------------------
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:143
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:340
DumpSimChannels & operator=(DumpSimChannels const &)=delete
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
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
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.