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:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

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...
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

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...
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

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.

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.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
unsigned int fDigitsPerLine
Ticks/digits per line in the output.
Pedestal_t fPedestal
ADC pedestal, will be subtracted from digits.
static Config * config
Definition: config.cpp:1054

Member Function Documentation

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

Does the printing.

Implements art::EDAnalyzer.

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 
160 
161  } // for digits
162 
163 } // caldata::DumpWires::analyze()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::vector< raw::RawDigit > RawDigits
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.
std::string encode() const
Definition: InputTag.cc:97
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:7
void detsim::DumpRawDigits::beginJob ( )
overridevirtual

Prints an introduction.

Reimplemented from art::EDAnalyzer.

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()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
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 swap(Handle< T > &a, Handle< T > &b)
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
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: