Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
dune::ToyFragmentWriter Class Reference

#include <ToyFragmentWriter.hh>

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

Public Member Functions

 ToyFragmentWriter (artdaq::Fragment &f)
 
adc_tdataBegin ()
 
adc_tdataEnd ()
 
Headerheader_ ()
 
void set_hdr_run_number (Header::run_number_t run_number)
 
void resize (size_t nAdcs)
 
- Public Member Functions inherited from dune::ToyFragment
 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)
 

Private Member Functions

size_t calc_event_size_words_ (size_t nAdcs)
 

Static Private Member Functions

static size_t adcs_to_words_ (size_t nAdcs)
 

Private Attributes

artdaq::Fragment & artdaq_Fragment_
 

Additional Inherited Members

- Public Types inherited from dune::ToyFragment
typedef uint16_t adc_t
 
- Static Public Member Functions inherited from dune::ToyFragment
static constexpr size_t hdr_size_words ()
 
- Protected Member Functions inherited from dune::ToyFragment
Header const * header_ () const
 
- Static Protected Member Functions inherited from dune::ToyFragment
static constexpr size_t adcs_per_word_ ()
 

Detailed Description

Definition at line 27 of file ToyFragmentWriter.hh.

Constructor & Destructor Documentation

dune::ToyFragmentWriter::ToyFragmentWriter ( artdaq::Fragment &  f)

Definition at line 66 of file ToyFragmentWriter.hh.

66  :
68 
69  // If this assert doesn't hold, then can't call
70  // "words_to_frag_words_" below, translating between the
71  // ToyFragment's standard data type size and the
72  // artdaq::Fragment's data type size, on the Metadata object
73 
74  assert( sizeof(Metadata::data_t) == sizeof(Header::data_t) );
75 
76 
77  if (! artdaq_Fragment_.hasMetadata() ) {
78  throw cet::exception("Error in ToyFragmentWriter: passed artdaq::Fragment object doesn't contain metadata");
79  }
80 
81  if (artdaq_Fragment_.dataSizeBytes() > 0) {
82  throw cet::exception("Error in ToyFragmentWriter: passed artdaq::Fragment object already contains payload");
83  }
84 
85  // Allocate space for the header
86  artdaq_Fragment_.resizeBytes( sizeof(Header) );
87 }
ToyFragment(artdaq::Fragment const &f)
Definition: ToyFragment.hh:88
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
artdaq::Fragment & artdaq_Fragment_

Member Function Documentation

size_t dune::ToyFragmentWriter::adcs_to_words_ ( size_t  nAdcs)
inlinestaticprivate

Definition at line 110 of file ToyFragmentWriter.hh.

110  {
111  auto mod(nAdcs % adcs_per_word_());
112  return (mod == 0) ?
113  nAdcs / adcs_per_word_() :
114  nAdcs / adcs_per_word_() + 1;
115 }
static constexpr size_t adcs_per_word_()
Definition: ToyFragment.hh:144
size_t dune::ToyFragmentWriter::calc_event_size_words_ ( size_t  nAdcs)
inlineprivate

Definition at line 106 of file ToyFragmentWriter.hh.

106  {
107  return adcs_to_words_(nAdcs) + hdr_size_words();
108 }
static constexpr size_t hdr_size_words()
Definition: ToyFragment.hh:94
static size_t adcs_to_words_(size_t nAdcs)
dune::ToyFragment::adc_t * dune::ToyFragmentWriter::dataBegin ( )
inline

Definition at line 90 of file ToyFragmentWriter.hh.

90  {
91  assert(artdaq_Fragment_.dataSizeBytes() > sizeof(Header) );
92  return reinterpret_cast<adc_t *>(header_() + 1);
93 }
artdaq::Fragment & artdaq_Fragment_
dune::ToyFragment::adc_t * dune::ToyFragmentWriter::dataEnd ( )
inline

Definition at line 95 of file ToyFragmentWriter.hh.

95  {
96  return dataBegin() + total_adc_values();
97 }
size_t total_adc_values() const
Definition: ToyFragment.hh:97
Header* dune::ToyFragmentWriter::header_ ( )
inline

Definition at line 42 of file ToyFragmentWriter.hh.

42  {
43  assert(artdaq_Fragment_.dataSizeBytes() >= sizeof(Header) );
44  return reinterpret_cast<Header *>( artdaq_Fragment_.dataBeginBytes());
45  }
artdaq::Fragment & artdaq_Fragment_
void dune::ToyFragmentWriter::resize ( size_t  nAdcs)
inline

Definition at line 100 of file ToyFragmentWriter.hh.

100  {
101  auto es(calc_event_size_words_(nAdcs));
102  artdaq_Fragment_.resizeBytes( sizeof(Header::data_t) * es );
103  header_()->event_size = es;
104 }
size_t calc_event_size_words_(size_t nAdcs)
artdaq::Fragment & artdaq_Fragment_
void dune::ToyFragmentWriter::set_hdr_run_number ( Header::run_number_t  run_number)
inline

Definition at line 47 of file ToyFragmentWriter.hh.

47  {
48  header_()->run_number = run_number;
49  }

Member Data Documentation

artdaq::Fragment& dune::ToyFragmentWriter::artdaq_Fragment_
private

Definition at line 59 of file ToyFragmentWriter.hh.


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