14 #include "art/Framework/Core/EDAnalyzer.h"
15 #include "art/Framework/Core/ModuleMacros.h"
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Principal/Handle.h"
18 #include "canvas/Utilities/InputTag.h"
21 #include "fhiclcpp/types/Atom.h"
22 #include "fhiclcpp/types/Name.h"
23 #include "fhiclcpp/types/Comment.h"
24 #include "messagefacility/MessageLogger/MessageLogger.h"
79 Name(
"CalWireModuleLabel"),
80 Comment(
"tag of producer used to create the recob::Wire collection"),
85 Name(
"OutputCategory"),
86 Comment(
"the messagefacility category used for the output"),
91 Name(
"DigitsPerLine"),
92 Comment(
"number of digits printed per line (0: don't print digits)"),
105 virtual void analyze (art::Event
const&
evt)
override;
114 template <
typename Stream>
117 std::string indent =
" ", std::string firstIndent =
" "
129 : EDAnalyzer (config)
130 , fCalWireModuleLabel(config().CalWireModuleLabel())
131 , fOutputCategory (config().OutputCategory())
132 , fDigitsPerLine (config().DigitsPerLine())
140 = *(evt.getValidHandle<std::vector<recob::Wire>>(fCalWireModuleLabel));
142 mf::LogVerbatim(fOutputCategory) <<
"Event " << evt.id()
143 <<
" contains " << Wires.size() <<
" '" << fCalWireModuleLabel.encode()
148 PrintWire(mf::LogVerbatim(fOutputCategory), wire);
156 template <
typename Stream>
159 std::string indent , std::string firstIndent
164 RegionsOfInterest_t
const & RoIs = wire.
SignalROI();
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";
177 out <<
" with " << RoIs.n_ranges() <<
" regions of interest:";
182 for (RegionsOfInterest_t::datarange_t
const& RoI: RoIs.get_ranges()) {
183 out <<
"\n" << indent
184 <<
" from " << RoI.offset <<
" for " << RoI.size() <<
" ticks";
190 if (fDigitsPerLine > 0) {
192 std::vector<RegionsOfInterest_t::value_type> DigitBuffer(fDigitsPerLine),
195 unsigned int repeat_count = 0;
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) {
203 unsigned int line_size
204 = std::min(fDigitsPerLine, (
unsigned int) RoIs.size() - index);
205 if (line_size == 0)
break;
208 DigitBuffer.resize(line_size);
209 auto iBuf = DigitBuffer.begin(), bend = DigitBuffer.end();
210 while ((iBuf != bend) && (iTick != tend))
211 Extrema.
add(*(iBuf++) = *(iTick++));
215 if (DigitBuffer == LastBuffer) {
222 if (repeat_count > 0) {
223 out <<
"\n" << indent
224 <<
" [ ... repeated " << repeat_count <<
" more times, "
225 << (repeat_count * LastBuffer.size()) <<
" ticks ]";
230 out <<
"\n" << indent
231 <<
" " << std::fixed << std::setprecision(3);
232 for (
auto digit: DigitBuffer) out << std::setw(8) << digit;
236 std::swap(LastBuffer, DigitBuffer);
239 if (repeat_count > 0) {
240 out <<
"\n" << indent
241 <<
" [ ... repeated " << repeat_count <<
" more times to the end ]";
243 if (Extrema.
min() < Extrema.
max()) {
244 out <<
"\n" << indent
245 <<
" range of " << index
246 <<
" samples: [" << Extrema.
min() <<
";" << Extrema.
max() <<
"]";
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.
Prints the content of all the wires on screen.
fhicl::Atom< std::string > OutputCategory
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
art::InputTag fCalWireModuleLabel
Input tag for wires.
Planes which measure Z direction.
lar::sparse_vector< float > RegionsOfInterest_t
a region of interest is a pair (TDC offset, readings)
Classes gathering simple statistics.
3-dimensional objects, potentially hits, clusters, prongs, etc.
geo::View_t View() const
Returns the view the channel belongs to.
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.
fhicl::Atom< art::InputTag > CalWireModuleLabel
std::string fOutputCategory
Category for LogVerbatim output.
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
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.
unsigned int fDigitsPerLine
Ticks/digits per line in the output.
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
BEGIN_PROLOG vertical distance to the surface Name
Definition of data types for geometry description.
DumpWires(Parameters const &config)
Constructor.
std::string to_string(WindowPattern const &pattern)
Class holding the regions of interest of signal from a channel.
virtual void analyze(art::Event const &evt) override
Does the printing.
Declaration of basic channel signal object.
fhicl::Atom< unsigned int > DigitsPerLine
process_name can override from command line with o or output caldata
art::EDAnalyzer::Table< Config > Parameters
std::size_t NSignal() const
Returns the number of time ticks, or samples, in the channel.