Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | List of all members
dune::ToyFragment Class Reference

#include <ToyFragment.hh>

Inheritance diagram for dune::ToyFragment:
dune::ToyFragmentWriter

Classes

struct  Header
 
struct  Metadata
 

Public Types

typedef uint16_t adc_t
 

Public Member Functions

 ToyFragment (artdaq::Fragment const &f)
 
Header::event_size_t hdr_event_size () const
 
Header::run_number_t hdr_run_number () const
 
size_t total_adc_values () const
 
adc_t const * dataBegin () const
 
adc_t const * dataEnd () const
 
adc_t const * findBadADC (int daq_adc_bits) const
 
bool fastVerify (int daq_adc_bits) const
 
void checkADCData (int daq_adc_bits) const
 
size_t adc_range (int daq_adc_bits)
 

Static Public Member Functions

static constexpr size_t hdr_size_words ()
 

Protected Member Functions

Header const * header_ () const
 

Static Protected Member Functions

static constexpr size_t adcs_per_word_ ()
 

Private Attributes

artdaq::Fragment const & artdaq_Fragment_
 

Detailed Description

Definition at line 21 of file ToyFragment.hh.

Member Typedef Documentation

typedef uint16_t dune::ToyFragment::adc_t

Definition at line 30 of file ToyFragment.hh.

Constructor & Destructor Documentation

dune::ToyFragment::ToyFragment ( artdaq::Fragment const &  f)
inline

Definition at line 88 of file ToyFragment.hh.

88 : artdaq_Fragment_(f) {}
artdaq::Fragment const & artdaq_Fragment_
Definition: ToyFragment.hh:158

Member Function Documentation

size_t dune::ToyFragment::adc_range ( int  daq_adc_bits)
inline

Definition at line 133 of file ToyFragment.hh.

133  {
134  return (1ul << daq_adc_bits );
135  }
static constexpr size_t dune::ToyFragment::adcs_per_word_ ( )
inlinestaticprotected

Definition at line 144 of file ToyFragment.hh.

144  {
145  return sizeof(Header::data_t) / sizeof(adc_t);
146  }
void dune::ToyFragment::checkADCData ( int  daq_adc_bits) const

Definition at line 17 of file ToyFragment.cc.

17  {
18  dune::ToyFragment::adc_t const * adcPtr(findBadADC(daq_adc_bits));
19  if (adcPtr != dataEnd()) {
20  throw cet::exception("IllegalADCVal")
21  << "Illegal value of ADC word #"
22  << (adcPtr - dataBegin())
23  << ": 0x"
24  << std::hex
25  << *adcPtr
26  << ".";
27  }
28 }
adc_t const * findBadADC(int daq_adc_bits) const
Definition: ToyFragment.hh:118
QTextStream & hex(QTextStream &s)
adc_t const * dataEnd() const
Definition: ToyFragment.hh:107
adc_t const * dataBegin() const
Definition: ToyFragment.hh:102
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
adc_t const* dune::ToyFragment::dataBegin ( ) const
inline

Definition at line 102 of file ToyFragment.hh.

102  {
103  return reinterpret_cast<adc_t const *>(header_() + 1);
104  }
Header const * header_() const
Definition: ToyFragment.hh:152
adc_t const* dune::ToyFragment::dataEnd ( ) const
inline

Definition at line 107 of file ToyFragment.hh.

107  {
108  return dataBegin() + total_adc_values();
109  }
size_t total_adc_values() const
Definition: ToyFragment.hh:97
adc_t const * dataBegin() const
Definition: ToyFragment.hh:102
bool dune::ToyFragment::fastVerify ( int  daq_adc_bits) const
inline

Definition at line 124 of file ToyFragment.hh.

124  {
125  return (findBadADC(daq_adc_bits) == dataEnd());
126  };
adc_t const * findBadADC(int daq_adc_bits) const
Definition: ToyFragment.hh:118
adc_t const * dataEnd() const
Definition: ToyFragment.hh:107
adc_t const* dune::ToyFragment::findBadADC ( int  daq_adc_bits) const
inline

Definition at line 118 of file ToyFragment.hh.

118  {
119  return std::find_if(dataBegin(), dataEnd(),
120  [&](adc_t const adc) -> bool {
121  return (adc >> daq_adc_bits); });
122  }
int16_t adc
Definition: CRTFragment.hh:202
adc_t const * dataEnd() const
Definition: ToyFragment.hh:107
adc_t const * dataBegin() const
Definition: ToyFragment.hh:102
Header::event_size_t dune::ToyFragment::hdr_event_size ( ) const
inline

Definition at line 92 of file ToyFragment.hh.

92 { return header_()->event_size; }
Header const * header_() const
Definition: ToyFragment.hh:152
Header::run_number_t dune::ToyFragment::hdr_run_number ( ) const
inline

Definition at line 93 of file ToyFragment.hh.

93 { return header_()->run_number; }
Header const * header_() const
Definition: ToyFragment.hh:152
static constexpr size_t dune::ToyFragment::hdr_size_words ( )
inlinestatic

Definition at line 94 of file ToyFragment.hh.

94 { return Header::size_words; }
static size_t const size_words
Definition: ToyFragment.hh:80
Header const* dune::ToyFragment::header_ ( ) const
inlineprotected

Definition at line 152 of file ToyFragment.hh.

152  {
153  return reinterpret_cast<ToyFragment::Header const *>( artdaq_Fragment_.dataBeginBytes());
154  }
artdaq::Fragment const & artdaq_Fragment_
Definition: ToyFragment.hh:158
size_t dune::ToyFragment::total_adc_values ( ) const
inline

Definition at line 97 of file ToyFragment.hh.

97  {
98  return (hdr_event_size() - hdr_size_words()) * adcs_per_word_();
99  }
static constexpr size_t hdr_size_words()
Definition: ToyFragment.hh:94
static constexpr size_t adcs_per_word_()
Definition: ToyFragment.hh:144
Header::event_size_t hdr_event_size() const
Definition: ToyFragment.hh:92

Member Data Documentation

artdaq::Fragment const& dune::ToyFragment::artdaq_Fragment_
private

Definition at line 158 of file ToyFragment.hh.


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