All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
caldata::DumpWires Class Reference

Prints the content of all the wires on screen. More...

Inheritance diagram for caldata::DumpWires:

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 DumpWires (Parameters const &config)
 Constructor. More...
 
virtual void analyze (art::Event const &evt) override
 Does the printing. More...
 

Private Member Functions

template<typename Stream >
void PrintWire (Stream &&out, recob::Wire const &wire, std::string indent=" ", std::string firstIndent=" ") const
 Dumps a single recob:Wire to the specified output stream. More...
 

Private Attributes

art::InputTag fCalWireModuleLabel
 Input tag for wires. More...
 
std::string fOutputCategory
 Category for LogVerbatim output. More...
 
unsigned int fDigitsPerLine
 Ticks/digits per line in the output. More...
 

Detailed Description

Prints the content of all the wires on screen.

This analyser prints the content of all the wires into the LogVerbatim stream.

Configuration parameters

Definition at line 71 of file DumpWires_module.cc.

Member Typedef Documentation

using caldata::DumpWires::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 98 of file DumpWires_module.cc.

Constructor & Destructor Documentation

caldata::DumpWires::DumpWires ( Parameters const &  config)
explicit

Constructor.

Definition at line 128 of file DumpWires_module.cc.

129  : EDAnalyzer (config)
130  , fCalWireModuleLabel(config().CalWireModuleLabel())
131  , fOutputCategory (config().OutputCategory())
132  , fDigitsPerLine (config().DigitsPerLine())
133  {}
art::InputTag fCalWireModuleLabel
Input tag for wires.
std::string fOutputCategory
Category for LogVerbatim output.
unsigned int fDigitsPerLine
Ticks/digits per line in the output.

Member Function Documentation

void caldata::DumpWires::analyze ( art::Event const &  evt)
overridevirtual

Does the printing.

Definition at line 137 of file DumpWires_module.cc.

137  {
138 
139  auto const& Wires
140  = *(evt.getValidHandle<std::vector<recob::Wire>>(fCalWireModuleLabel));
141 
142  mf::LogVerbatim(fOutputCategory) << "Event " << evt.id()
143  << " contains " << Wires.size() << " '" << fCalWireModuleLabel.encode()
144  << "' wires";
145 
146  for (recob::Wire const& wire: Wires) {
147 
148  PrintWire(mf::LogVerbatim(fOutputCategory), wire);
149 
150  } // for wire
151 
152 } // caldata::DumpWires::analyze()
art::InputTag fCalWireModuleLabel
Input tag for wires.
std::string fOutputCategory
Category for LogVerbatim output.
void PrintWire(Stream &&out, recob::Wire const &wire, std::string indent=" ", std::string firstIndent=" ") const
Dumps a single recob:Wire to the specified output stream.
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
TCEvent evt
Definition: DataStructs.cxx:8
template<typename Stream >
void caldata::DumpWires::PrintWire ( Stream &&  out,
recob::Wire const &  wire,
std::string  indent = "  ",
std::string  firstIndent = "  " 
) const
private

Dumps a single recob:Wire to the specified output stream.

Definition at line 157 of file DumpWires_module.cc.

160  {
161 
162  using RegionsOfInterest_t = recob::Wire::RegionsOfInterest_t;
163 
164  RegionsOfInterest_t const & RoIs = wire.SignalROI();
165 
166  //
167  // print a header for the wire
168  //
169  out << firstIndent << "channel #" << wire.Channel() << " on view "
170  << ViewName(wire.View()) << "; " << wire.NSignal() << " time ticks";
171  if (wire.NSignal() != RoIs.size())
172  out << " [!!! EXPECTED " << RoIs.size() << "]";
173  if (RoIs.n_ranges() == 0) {
174  out << " with nothing in them";
175  return;
176  }
177  out << " with " << RoIs.n_ranges() << " regions of interest:";
178 
179  //
180  // print the list of regions of interest
181  //
182  for (RegionsOfInterest_t::datarange_t const& RoI: RoIs.get_ranges()) {
183  out << "\n" << indent
184  << " from " << RoI.offset << " for " << RoI.size() << " ticks";
185  } // for
186 
187  //
188  // print the content of the wire
189  //
190  if (fDigitsPerLine > 0) {
191 
192  std::vector<RegionsOfInterest_t::value_type> DigitBuffer(fDigitsPerLine),
193  LastBuffer;
194 
195  unsigned int repeat_count = 0; // additional lines like the last one
196  unsigned int index = 0;
198  out << "\n" << indent
199  << " content of the wire (" << fDigitsPerLine << " ticks per line):";
200  auto iTick = RoIs.cbegin(), tend = RoIs.cend();
201  while (iTick != tend) {
202  // the next line will show at most fDigitsPerLine ticks
203  unsigned int line_size
204  = std::min(fDigitsPerLine, (unsigned int) RoIs.size() - index);
205  if (line_size == 0) break; // no more ticks
206 
207  // fill the new buffer (iTick will move forward)
208  DigitBuffer.resize(line_size);
209  auto iBuf = DigitBuffer.begin(), bend = DigitBuffer.end();
210  while ((iBuf != bend) && (iTick != tend))
211  Extrema.add(*(iBuf++) = *(iTick++));
212  index += line_size;
213 
214  // if the new buffer is the same as the old one, just mark it
215  if (DigitBuffer == LastBuffer) {
216  repeat_count += 1;
217  continue;
218  }
219 
220  // if there are previous repeats, write that on screen
221  // before the new, different line
222  if (repeat_count > 0) {
223  out << "\n" << indent
224  << " [ ... repeated " << repeat_count << " more times, "
225  << (repeat_count * LastBuffer.size()) << " ticks ]";
226  repeat_count = 0;
227  }
228 
229  // dump the new line of ticks
230  out << "\n" << indent
231  << " " << std::fixed << std::setprecision(3);
232  for (auto digit: DigitBuffer) out << std::setw(8) << digit;
233 
234  // quick way to assign DigitBuffer to LastBuffer
235  // (we don't care we lose the former)
236  std::swap(LastBuffer, DigitBuffer);
237 
238  } // while
239  if (repeat_count > 0) {
240  out << "\n" << indent
241  << " [ ... repeated " << repeat_count << " more times to the end ]";
242  }
243  if (Extrema.min() < Extrema.max()) {
244  out << "\n" << indent
245  << " range of " << index
246  << " samples: [" << Extrema.min() << ";" << Extrema.max() << "]";
247  }
248  } // if dumping the ticks
249 
250 } // caldata::DumpWires::PrintWire()
Data_t max() const
Returns the accumulated maximum, or a very small number if no values.
This_t & add(Data_t value)
Include a single value in the statistics.
size_type size() const
Returns the size of the vector.
lar::sparse_vector< float > RegionsOfInterest_t
a region of interest is a pair (TDC offset, readings)
Definition: Wire.h:121
Keeps track of the minimum and maximum value we observed.
Data_t min() const
Returns the accumulated minimum, or a very large number if no values.
unsigned int fDigitsPerLine
Ticks/digits per line in the output.

Member Data Documentation

art::InputTag caldata::DumpWires::fCalWireModuleLabel
private

Input tag for wires.

Definition at line 109 of file DumpWires_module.cc.

unsigned int caldata::DumpWires::fDigitsPerLine
private

Ticks/digits per line in the output.

Definition at line 111 of file DumpWires_module.cc.

std::string caldata::DumpWires::fOutputCategory
private

Category for LogVerbatim output.

Definition at line 110 of file DumpWires_module.cc.


The documentation for this class was generated from the following file: