15 #include "art/Framework/Core/EDAnalyzer.h"
16 #include "art/Framework/Core/ModuleMacros.h"
17 #include "art/Framework/Principal/Event.h"
18 #include "art/Framework/Principal/Handle.h"
19 #include "canvas/Utilities/InputTag.h"
22 #include "fhiclcpp/types/Atom.h"
23 #include "fhiclcpp/types/Name.h"
24 #include "fhiclcpp/types/Comment.h"
25 #include "messagefacility/MessageLogger/MessageLogger.h"
57 using Digit_t = raw::RawDigit::ADCvector_t::value_type;
69 Name(
"DetSimModuleLabel"),
70 Comment(
"tag of producer used to create the raw::RawDigit collection"),
75 Name(
"OutputCategory"),
76 Comment(
"the messagefacility category used for the output"),
81 Name(
"DigitsPerLine"),
82 Comment(
"number of digits printed per line (0: don't print digits)"),
88 Comment(
"digit values are written relative to this number"),
104 virtual void analyze (art::Event
const&
evt)
override;
114 template <
typename Stream>
117 std::string indent =
" ", std::string firstIndent =
" "
129 : EDAnalyzer (config)
130 , fDetSimModuleLabel(config().DetSimModuleLabel())
131 , fOutputCategory (config().OutputCategory())
132 , fDigitsPerLine (config().DigitsPerLine())
133 , fPedestal (config().Pedestal())
140 if (fPedestal != 0) {
141 mf::LogVerbatim(fOutputCategory) <<
"A pedestal of " << fPedestal
142 <<
" will be subtracted from all raw digits";
151 auto const& RawDigits
152 = *(evt.getValidHandle<std::vector<raw::RawDigit>>(fDetSimModuleLabel));
154 mf::LogVerbatim(fOutputCategory) <<
"Event " << evt.id()
155 <<
" contains " << RawDigits.size() <<
" '" << fDetSimModuleLabel.encode()
159 PrintRawDigit(mf::LogVerbatim(fOutputCategory), digits);
167 template <
typename Stream>
170 std::string indent , std::string firstIndent
183 <<
" #" << digits.
Channel() <<
": " << ADCs.size() <<
" time ticks";
184 if (digits.
Samples() != ADCs.size())
185 out <<
" [!!! EXPECTED " << digits.
Samples() <<
"] ";
187 <<
" (" << digits.
NADC() <<
" after compression); compression type: ";
189 case raw::kNone: out <<
"no compression";
break;
196 out <<
"unknown (#" << ((int) digits.
Compression()) <<
")";
break;
200 if (fDigitsPerLine > 0) {
201 std::vector<Digit_t> DigitBuffer(fDigitsPerLine), LastBuffer;
203 unsigned int repeat_count = 0;
204 unsigned int index = 0;
206 out <<
"\n" << indent
207 <<
"content of the channel (" << fDigitsPerLine <<
" ticks per line):";
208 auto iTick = ADCs.cbegin(), tend = ADCs.cend();
209 while (iTick != tend) {
211 unsigned int line_size
212 = std::min(fDigitsPerLine, (
unsigned int) ADCs.size() - index);
213 if (line_size == 0)
break;
216 DigitBuffer.resize(line_size);
217 auto iBuf = DigitBuffer.begin(), bend = DigitBuffer.end();
218 while ((iBuf != bend) && (iTick != tend))
219 Extrema.
add(*(iBuf++) = (*(iTick++) - fPedestal));
223 if (DigitBuffer == LastBuffer) {
230 if (repeat_count > 0) {
231 out <<
"\n" << indent
232 <<
" [ ... repeated " << repeat_count <<
" more times, "
233 << (repeat_count * LastBuffer.size()) <<
" ticks ]";
238 out <<
"\n" << indent <<
" ";
239 for (
auto digit: DigitBuffer)
240 out <<
" " << std::setw(4) << digit;
244 std::swap(LastBuffer, DigitBuffer);
247 if (repeat_count > 0) {
248 out <<
"\n" << indent
249 <<
" [ ... repeated " << repeat_count <<
" more times to the end ]";
251 if (Extrema.
min() < Extrema.
max()) {
252 out <<
"\n" << indent
253 <<
" range of " << index
254 <<
" samples: [" << Extrema.
min() <<
";" << Extrema.
max() <<
"]";
Data_t max() const
Returns the accumulated maximum, or a very small number if no values.
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
Digit_t Pedestal_t
Type to represent a pedestal.
This_t & add(Data_t value)
Include a single value in the statistics.
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Collection of charge vs time digitized from a single readout channel.
art::InputTag fDetSimModuleLabel
Tag for digits data product.
virtual void analyze(art::Event const &evt) override
Does the printing.
art::EDAnalyzer::Table< Config > Parameters
fhicl::Atom< art::InputTag > DetSimModuleLabel
std::string fOutputCategory
Category for LogVerbatim output.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
fhicl::Atom< unsigned int > DigitsPerLine
Definition of basic raw digits.
Zero Suppression followed by Huffman Encoding.
Classes gathering simple statistics.
raw::RawDigit::ADCvector_t::value_type Digit_t
Type to represent a digit.
unsigned int fDigitsPerLine
Ticks/digits per line in the output.
DumpRawDigits(Parameters const &config)
Constructor.
Zero Suppression algorithm.
Keeps track of the minimum and maximum value we observed.
Pedestal_t fPedestal
ADC pedestal, will be subtracted from digits.
Data_t min() const
Returns the accumulated minimum, or a very large number if no values.
fhicl::Atom< std::string > OutputCategory
Collect all the RawData header files together.
size_t NADC() const
Number of elements in the compressed ADC sample vector.
virtual void beginJob() override
Prints an introduction.
Prints the content of all the raw digits on screen.
BEGIN_PROLOG vertical distance to the surface Name
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
void PrintRawDigit(Stream &&out, raw::RawDigit const &digits, std::string indent=" ", std::string firstIndent=" ") const
Dumps a single recob:Wire to the specified output stream.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
fhicl::Atom< Pedestal_t > Pedestal