DumpOpDetDivRecs_module.cc
Go to the documentation of this file.
1 /**
2  * @file DumpOpDetDivRecs_module.cc
3  * @brief Module dumping OpDetDivRecs information on screen
4  * @date August 8, 2016
5  * @author Jason Stock (jason.stock@mines.sdsmt.edu)
6  * Module based closely on the DumpOpDetBacktrackerRecords by Lucas Mendes Santos
7  *
8  */
9 
10 
11 // nutools libraries
13 
14 // framework libraries
20 #include "fhiclcpp/ParameterSet.h"
21 #include "fhiclcpp/types/Atom.h"
23 
24 
25 namespace sim {
26  class DumpOpDetDivRecs;
27 } // namespace sim
28 
29 namespace {
30  using namespace fhicl;
31 
32  /// Collection of configuration parameters for the module
33  struct Config {
34  using Name = fhicl::Name;
35  using Comment = fhicl::Comment;
36 
37  fhicl::Atom<art::InputTag> InputOpDetDivRecs {
38  Name("InputOpDetDivRecs"),
39  Comment("data product with the OpDetDivRecs to be dumped")
40  };
41 
42  fhicl::Atom<std::string> OutputCategory {
43  Name("OutputCategory"),
44  Comment("name of the output stream (managed by the message facility)"),
45  "DumpOpDetDivRecs" /* default value */
46  };
47 
48  }; // struct Config
49 
50 
51 } // local namespace
52 
53 
55  public:
56  // type to enable module parameters description by art
58 
59  /// Configuration-checking constructor
60  explicit DumpOpDetDivRecs(Parameters const& config);
61 
62  // Plugins should not be copied or assigned.
63  DumpOpDetDivRecs(DumpOpDetDivRecs const&) = delete;
67 
68 
69  // Operates on the event
70  void analyze(art::Event const& event) override;
71 
72 
73  /**
74  * @brief Dumps the content of the specified OpDetDivRecs in the output stream
75  * @tparam Stream the type of output stream
76  * @param out the output stream
77  * @param simchannel the OpDetDivRecs to be dumped
78  * @param indent base indentation string (default: none)
79  * @param bIndentFirst if first output line should be indented (default: yes)
80  *
81  * The indent string is prepended to every line of output, with the possible
82  * exception of the first one, in case bIndentFirst is true.
83  *
84  * The output starts on the current line, and the last line is NOT broken.
85  */
86  template <typename Stream>
87  void DumpOpDetDivRec(
88  Stream&& out, sim::OpDetDivRec const& simchannel,
89  std::string indent = "", bool bIndentFirst = true
90  ) const;
91 
92 
93  private:
94 
95  art::InputTag fInputChannels; ///< name of OpDetDivRecs's data product
96  std::string fOutputCategory; ///< name of the stream for output
97 
98 }; // class sim::DumpOpDetDivRecs
99 
100 
101 //------------------------------------------------------------------------------
102 //--- module implementation
103 //---
104 //------------------------------------------------------------------------------
106  : EDAnalyzer(config)
107  , fInputChannels(config().InputOpDetDivRecs())
108  , fOutputCategory(config().OutputCategory())
109 {}
110 
111 
112 //------------------------------------------------------------------------------
113 template <typename Stream>
115  Stream&& out, sim::OpDetDivRec const& channel,
116  std::string indent /* = "" */, bool bIndentFirst /* = true */
117 ) const {
118  if (bIndentFirst) out << indent;
119  channel.Dump(out, indent);
120 } // sim::DumpOpDetDivRecs::DumpOpDetDivRecs()
121 
122 
123 //------------------------------------------------------------------------------
125 
126  // get the particles from the event
127  auto const& OpDetDivRecs
128  = *(event.getValidHandle<std::vector<sim::OpDetDivRec>>(fInputChannels));
129 
130  mf::LogVerbatim(fOutputCategory) << "Event " << event.id()
131  << " : data product '" << fInputChannels.encode() << "' contains "
132  << OpDetDivRecs.size() << " OpDetDivRecs";
133 
134  unsigned int iOpDetDivRec = 0;
135  for (sim::OpDetDivRec const& div_rec: OpDetDivRecs) {
136 
137  // a bit of a header
139  log << "[#" << (iOpDetDivRec++) << "] ";
140  DumpOpDetDivRec(log, div_rec, " ", false);
141 
142  } // for
144 
145 } // sim::DumpOpDetDivRecs::analyze()
146 
147 
148 //------------------------------------------------------------------------------
150 
151 //------------------------------------------------------------------------------
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
DumpOpDetDivRecs & operator=(DumpOpDetDivRecs const &)=delete
std::string string
Definition: nybbler.cc:12
std::string fOutputCategory
name of the stream for output
ChannelGroupService::Name Name
uint8_t channel
Definition: CRTFragment.hh:201
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string encode() const
Definition: InputTag.cc:97
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
static Config * config
Definition: config.cpp:1054
art::InputTag fInputChannels
name of OpDetDivRecs&#39;s data product
Code to link reconstructed objects back to the MC truth information.
void analyze(art::Event const &event) override
#define Comment
void Dump(Stream &&out, std::string indent, std::string first_indent) const
Definition: OpDetDivRec.h:147
DumpOpDetDivRecs(Parameters const &config)
Configuration-checking constructor.
Event finding and building.
void DumpOpDetDivRec(Stream &&out, sim::OpDetDivRec const &simchannel, std::string indent="", bool bIndentFirst=true) const
Dumps the content of the specified OpDetDivRecs in the output stream.