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

#include <SSPFragmentWriter.hh>

Inheritance diagram for dune::SSPFragmentWriter:
dune::SSPFragment

Public Member Functions

 SSPFragmentWriter (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::SSPFragment
 SSPFragment (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
 

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::SSPFragment
typedef unsigned int adc_t
 
- Static Public Member Functions inherited from dune::SSPFragment
static constexpr size_t hdr_size_words ()
 
- Protected Member Functions inherited from dune::SSPFragment
Header const * header_ () const
 
- Static Protected Member Functions inherited from dune::SSPFragment
static constexpr size_t adcs_per_word_ ()
 

Detailed Description

Definition at line 27 of file SSPFragmentWriter.hh.

Constructor & Destructor Documentation

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

Definition at line 66 of file SSPFragmentWriter.hh.

66  :
68 
69  if ( ! f.hasMetadata() || f.dataSizeBytes() > 0 ) {
70  throw cet::exception("Error in SSPFragmentWriter: Raw artdaq::Fragment object does not appear to consist of (and only of) its own header + the SSPFragment::Metadata object");
71  }
72 
73  // Allocate space for the header
74  artdaq_Fragment_.resizeBytes( sizeof(Header) );
75 }
artdaq::Fragment & artdaq_Fragment_
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
SSPFragment(artdaq::Fragment const &f)
Definition: SSPFragment.hh:83

Member Function Documentation

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

Definition at line 99 of file SSPFragmentWriter.hh.

99  {
100  auto mod(nAdcs % adcs_per_word_());
101  return (mod == 0) ?
102  nAdcs / adcs_per_word_() :
103  nAdcs / adcs_per_word_() + 1;
104 }
static constexpr size_t adcs_per_word_()
Definition: SSPFragment.hh:113
size_t dune::SSPFragmentWriter::calc_event_size_words_ ( size_t  nAdcs)
inlineprivate

Definition at line 95 of file SSPFragmentWriter.hh.

95  {
96  return adcs_to_words_(nAdcs) + hdr_size_words();
97 }
static constexpr size_t hdr_size_words()
Definition: SSPFragment.hh:89
static size_t adcs_to_words_(size_t nAdcs)
dune::SSPFragment::adc_t * dune::SSPFragmentWriter::dataBegin ( )
inline

Definition at line 78 of file SSPFragmentWriter.hh.

78  {
79  // Make sure there's data past the SSPFragment header
80  assert(artdaq_Fragment_.dataSizeBytes() >= sizeof(Header) + sizeof(artdaq::Fragment::value_type) );
81  return reinterpret_cast<adc_t *>(header_() + 1);
82 }
artdaq::Fragment & artdaq_Fragment_
unsigned int adc_t
Definition: SSPFragment.hh:28
dune::SSPFragment::adc_t * dune::SSPFragmentWriter::dataEnd ( )
inline

Definition at line 84 of file SSPFragmentWriter.hh.

84  {
85  return dataBegin() + total_adc_values();
86 }
size_t total_adc_values() const
Definition: SSPFragment.hh:92
Header* dune::SSPFragmentWriter::header_ ( )
inline

Definition at line 42 of file SSPFragmentWriter.hh.

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

Definition at line 89 of file SSPFragmentWriter.hh.

89  {
90 
91  artdaq_Fragment_.resizeBytes(sizeof(Header::data_t) * calc_event_size_words_(nAdcs) );
93 }
size_t calc_event_size_words_(size_t nAdcs)
artdaq::Fragment & artdaq_Fragment_
void dune::SSPFragmentWriter::set_hdr_run_number ( Header::run_number_t  run_number)
inline

Definition at line 47 of file SSPFragmentWriter.hh.

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

Member Data Documentation

artdaq::Fragment& dune::SSPFragmentWriter::artdaq_Fragment_
private

Definition at line 59 of file SSPFragmentWriter.hh.


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