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

Prints the content of all the raw digits on screen. More...

Inheritance diagram for detsim::DumpRawDigits:

Classes

struct  Config
 

Public Types

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

Public Member Functions

 DumpRawDigits (Parameters const &config)
 Constructor. More...
 
virtual void beginJob () override
 Prints an introduction. More...
 
virtual void analyze (art::Event const &evt) override
 Does the printing. More...
 

Private Types

using Digit_t = raw::RawDigit::ADCvector_t::value_type
 Type to represent a digit. More...
 
using Pedestal_t = Digit_t
 Type to represent a pedestal. More...
 

Private Member Functions

template<typename Stream >
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. More...
 

Private Attributes

art::InputTag fDetSimModuleLabel
 Tag for digits data product. More...
 
std::string fOutputCategory
 Category for LogVerbatim output. More...
 
unsigned int fDigitsPerLine
 Ticks/digits per line in the output. More...
 
Pedestal_t fPedestal
 ADC pedestal, will be subtracted from digits. More...
 

Detailed Description

Prints the content of all the raw digits on screen.

This analyser prints the content of all the raw digits into the LogVerbatim stream.

Configuration parameters

Definition at line 54 of file DumpRawDigits_module.cc.

Member Typedef Documentation

using detsim::DumpRawDigits::Digit_t = raw::RawDigit::ADCvector_t::value_type
private

Type to represent a digit.

Definition at line 57 of file DumpRawDigits_module.cc.

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

Definition at line 94 of file DumpRawDigits_module.cc.

Type to represent a pedestal.

Definition at line 60 of file DumpRawDigits_module.cc.

Constructor & Destructor Documentation

detsim::DumpRawDigits::DumpRawDigits ( Parameters const &  config)
explicit

Constructor.

Definition at line 128 of file DumpRawDigits_module.cc.

129  : EDAnalyzer (config)
130  , fDetSimModuleLabel(config().DetSimModuleLabel())
131  , fOutputCategory (config().OutputCategory())
132  , fDigitsPerLine (config().DigitsPerLine())
133  , fPedestal (config().Pedestal())
134  {}
art::InputTag fDetSimModuleLabel
Tag for digits data product.
std::string fOutputCategory
Category for LogVerbatim output.
unsigned int fDigitsPerLine
Ticks/digits per line in the output.
Pedestal_t fPedestal
ADC pedestal, will be subtracted from digits.

Member Function Documentation

void detsim::DumpRawDigits::analyze ( art::Event const &  evt)
overridevirtual

Does the printing.

Definition at line 149 of file DumpRawDigits_module.cc.

149  {
150 
151  auto const& RawDigits
152  = *(evt.getValidHandle<std::vector<raw::RawDigit>>(fDetSimModuleLabel));
153 
154  mf::LogVerbatim(fOutputCategory) << "Event " << evt.id()
155  << " contains " << RawDigits.size() << " '" << fDetSimModuleLabel.encode()
156  << "' waveforms";
157  for (raw::RawDigit const& digits: RawDigits) {
158 
159  PrintRawDigit(mf::LogVerbatim(fOutputCategory), digits);
160 
161  } // for digits
162 
163 } // caldata::DumpWires::analyze()
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
art::InputTag fDetSimModuleLabel
Tag for digits data product.
std::string fOutputCategory
Category for LogVerbatim output.
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.
TCEvent evt
Definition: DataStructs.cxx:8
void detsim::DumpRawDigits::beginJob ( )
overridevirtual

Prints an introduction.

Definition at line 138 of file DumpRawDigits_module.cc.

138  {
139 
140  if (fPedestal != 0) {
141  mf::LogVerbatim(fOutputCategory) << "A pedestal of " << fPedestal
142  << " will be subtracted from all raw digits";
143  } // if pedestal
144 
145 } // detsim::DumpRawDigits::beginJob()
std::string fOutputCategory
Category for LogVerbatim output.
Pedestal_t fPedestal
ADC pedestal, will be subtracted from digits.
template<typename Stream >
void detsim::DumpRawDigits::PrintRawDigit ( Stream &&  out,
raw::RawDigit const &  digits,
std::string  indent = "  ",
std::string  firstIndent = "  " 
) const
private

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

Definition at line 168 of file DumpRawDigits_module.cc.

171  {
172 
173  //
174  // uncompress the digits
175  //
176  raw::RawDigit::ADCvector_t ADCs(digits.Samples());
177  raw::Uncompress(digits.ADCs(), ADCs, digits.Compression());
178 
179  //
180  // print a header for the raw digits
181  //
182  out << firstIndent
183  << " #" << digits.Channel() << ": " << ADCs.size() << " time ticks";
184  if (digits.Samples() != ADCs.size())
185  out << " [!!! EXPECTED " << digits.Samples() << "] ";
186  out
187  << " (" << digits.NADC() << " after compression); compression type: ";
188  switch (digits.Compression()) {
189  case raw::kNone: out << "no compression"; break;
190  case raw::kHuffman: out << "Huffman encoding" ; break;
191  case raw::kZeroSuppression: out << "zero suppression"; break;
192  case raw::kZeroHuffman: out << "zero suppression + Huffman encoding";
193  break;
194  case raw::kDynamicDec: out << "dynamic decimation"; break;
195  default:
196  out << "unknown (#" << ((int) digits.Compression()) << ")"; break;
197  } // switch
198 
199  // print the content of the channel
200  if (fDigitsPerLine > 0) {
201  std::vector<Digit_t> DigitBuffer(fDigitsPerLine), LastBuffer;
202 
203  unsigned int repeat_count = 0; // additional lines like the last one
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(); // const iterators
209  while (iTick != tend) {
210  // the next line will show at most fDigitsPerLine ticks
211  unsigned int line_size
212  = std::min(fDigitsPerLine, (unsigned int) ADCs.size() - index);
213  if (line_size == 0) break; // no more ticks
214 
215  // fill the new buffer (iTick will move forward)
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));
220  index += line_size;
221 
222  // if the new buffer is the same as the old one, just mark it
223  if (DigitBuffer == LastBuffer) {
224  repeat_count += 1;
225  continue;
226  }
227 
228  // if there are previous repeats, write that on screen
229  // before the new, different line
230  if (repeat_count > 0) {
231  out << "\n" << indent
232  << " [ ... repeated " << repeat_count << " more times, "
233  << (repeat_count * LastBuffer.size()) << " ticks ]";
234  repeat_count = 0;
235  }
236 
237  // dump the new line of ticks
238  out << "\n" << indent << " ";
239  for (auto digit: DigitBuffer)
240  out << " " << std::setw(4) << digit;
241 
242  // quick way to assign DigitBuffer to LastBuffer
243  // (we don't care we lose the former)
244  std::swap(LastBuffer, DigitBuffer);
245 
246  } // while
247  if (repeat_count > 0) {
248  out << "\n" << indent
249  << " [ ... repeated " << repeat_count << " more times to the end ]";
250  }
251  if (Extrema.min() < Extrema.max()) {
252  out << "\n" << indent
253  << " range of " << index
254  << " samples: [" << Extrema.min() << ";" << Extrema.max() << "]";
255  }
256  } // if dumping the ticks
257 
258 } // detsim::DumpRawDigits::analyze()
Data_t max() const
Returns the accumulated maximum, or a very small number if no values.
Huffman Encoding.
Definition: RawTypes.h:10
This_t & add(Data_t value)
Include a single value in the statistics.
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
no compression
Definition: RawTypes.h:9
unsigned int fDigitsPerLine
Ticks/digits per line in the output.
Zero Suppression algorithm.
Definition: RawTypes.h:11
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.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
Dynamic decimation.
Definition: RawTypes.h:13

Member Data Documentation

art::InputTag detsim::DumpRawDigits::fDetSimModuleLabel
private

Tag for digits data product.

Definition at line 108 of file DumpRawDigits_module.cc.

unsigned int detsim::DumpRawDigits::fDigitsPerLine
private

Ticks/digits per line in the output.

Definition at line 110 of file DumpRawDigits_module.cc.

std::string detsim::DumpRawDigits::fOutputCategory
private

Category for LogVerbatim output.

Definition at line 109 of file DumpRawDigits_module.cc.

Pedestal_t detsim::DumpRawDigits::fPedestal
private

ADC pedestal, will be subtracted from digits.

Definition at line 111 of file DumpRawDigits_module.cc.


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