DumpOpDetBacktrackerRecords_module.cc
Go to the documentation of this file.
1 /**
2  * @file DumpOpDetBacktrackerRecords_module.cc
3  * @brief Module dumping OpDetBacktrackerRecords information on screen
4  * @date August 8, 2016
5  * @author Lucas Mendes Santos (lmendes@ifi.unicamp.br)
6  *
7  */
8 
9 
10 // lardataobj libraries
12 
13 // framework libraries
19 
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 
31  /// Collection of configuration parameters for the module
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 
58  /// Configuration-checking constructor
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 
72  /**
73  * @brief Dumps the content of the specified OpDetBacktrackerRecord in the output stream
74  * @tparam Stream the type of output stream
75  * @param out the output stream
76  * @param simchannel the OpDetBacktrackerRecord to be dumped
77  * @param indent base indentation string (default: none)
78  * @param bIndentFirst if first output line should be indented (default: yes)
79  *
80  * The indent string is prepended to every line of output, with the possible
81  * exception of the first one, in case bIndentFirst is true.
82  *
83  * The output starts on the current line, and the last line is NOT broken.
84  */
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 
94  art::InputTag fInputChannels; ///< name of OpDetBacktrackerRecord's data product
95  std::string fOutputCategory; ///< name of the stream for output
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
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
DumpOpDetBacktrackerRecords(Parameters const &config)
Configuration-checking constructor.
uint8_t channel
Definition: CRTFragment.hh:201
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
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
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void Dump(Stream &&out, std::string indent, std::string first_indent) const
Dumps the full content of the OpDetBacktrackerRecord into a stream.
static Config * config
Definition: config.cpp:1054
void analyze(art::Event const &event) override
Code to link reconstructed objects back to the MC truth information.
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.
#define Comment
Event finding and building.
std::string fOutputCategory
name of the stream for output