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

#include <RceFragment.hh>

Public Member Functions

 RceFragment (artdaq::Fragment const &fragment)
 
 RceFragment (const uint64_t *data_ptr)
 
int size () const
 
TpcStreamUnpack const * get_stream (int i) const
 
void hexdump (std::ostream &out, int n_words=10) const
 
void save (const std::string &filepath) const
 

Static Public Member Functions

static RceFragments from_container_frags (const artdaq::Fragments &frags)
 

Private Member Functions

void _init ()
 

Private Attributes

std::unique_ptr< DataFragmentUnpack > _data_fragment
 
std::unique_ptr< TpcFragmentUnpack > _tpc_fragment
 
int _n_streams = 0
 
const uint64_t * _data_ptr
 

Detailed Description

Definition at line 19 of file RceFragment.hh.

Constructor & Destructor Documentation

dune::RceFragment::RceFragment ( artdaq::Fragment const &  fragment)

Definition at line 17 of file RceFragment.cc.

17  :
18  _data_ptr((uint64_t const*)(afrag.dataBeginBytes() + 12))
19 {
20  _init();
21 }
const uint64_t * _data_ptr
Definition: RceFragment.hh:38
dune::RceFragment::RceFragment ( const uint64_t *  data_ptr)

Definition at line 11 of file RceFragment.cc.

11  :
12  _data_ptr(data_ptr)
13 {
14  _init();
15 }
const uint64_t * _data_ptr
Definition: RceFragment.hh:38

Member Function Documentation

void dune::RceFragment::_init ( )
private

Definition at line 23 of file RceFragment.cc.

24 {
25  HeaderFragmentUnpack const header (_data_ptr);
26  if ( header.isData() )
27  {
28  _data_fragment = std::make_unique<DataFragmentUnpack>(_data_ptr);
29  // if (_data_fragment->isTpcNormal())
30  // {
31 
32  _tpc_fragment = std::make_unique<TpcFragmentUnpack>(*_data_fragment);
33  _n_streams = _tpc_fragment->getNStreams();
34 
35  // }
36  //else
37  // {
38  //std::cout << "Fragment skipped in RceFragment::_init() because not TpcNormal." << std::endl;
39  //}
40  }
41  else
42  {
43  //std::cout << "Fragment skipped in RceFragment::_init() because header says is not data." << std::endl;
44  }
45 }
std::unique_ptr< DataFragmentUnpack > _data_fragment
Definition: RceFragment.hh:35
const uint64_t * _data_ptr
Definition: RceFragment.hh:38
std::unique_ptr< TpcFragmentUnpack > _tpc_fragment
Definition: RceFragment.hh:36
dune::RceFragments dune::RceFragment::from_container_frags ( const artdaq::Fragments &  frags)
static

Definition at line 79 of file RceFragment.cc.

80 {
81  RceFragments rces;
82 
83  for (auto const& frag: frags)
84  {
85  artdaq::ContainerFragment cfrag(frag);
86  for (size_t ii = 0 ; ii < cfrag.block_count(); ++ii)
87  {
88  auto* data_ptr = (uint8_t*) (cfrag.dataBegin());
89  data_ptr += cfrag.fragmentIndex(ii);
90 
91  size_t afrag_size = 16;
92  artdaq::Fragment afrag;
93  afrag.resizeBytes(afrag_size);
94  memcpy(afrag.headerAddress(), data_ptr, afrag_size);
95 
96  int afrag_header_bytes = afrag.dataBeginBytes()
97  - afrag.headerBeginBytes();
98 
99  data_ptr += afrag_header_bytes;
100  data_ptr += 12;
101 
102  dune::RceFragment rce((uint64_t*) data_ptr);
103  rces.push_back(std::move(rce));
104  }
105  }
106  //return std::move(rces);
107  return rces;
108 }
std::vector< dune::RceFragment > RceFragments
Definition: RceFragment.hh:13
def move(depos, offset)
Definition: depos.py:107
TpcStreamUnpack const * dune::RceFragment::get_stream ( int  i) const

Definition at line 48 of file RceFragment.cc.

49 {
50  if (_n_streams <= 0)
51  return nullptr;
52  return _tpc_fragment->getStream(i);
53 }
std::unique_ptr< TpcFragmentUnpack > _tpc_fragment
Definition: RceFragment.hh:36
void dune::RceFragment::hexdump ( std::ostream &  out,
int  n_words = 10 
) const

Definition at line 55 of file RceFragment.cc.

56 {
57  out << std::hex;
58  for (int i = 0; i < n_words; ++i)
59  out << *(_data_ptr + i) << " ";
60  out << std::dec << std::endl;
61 }
QTextStream & hex(QTextStream &s)
const uint64_t * _data_ptr
Definition: RceFragment.hh:38
QTextStream & dec(QTextStream &s)
QTextStream & endl(QTextStream &s)
void dune::RceFragment::save ( const std::string filepath) const

Definition at line 63 of file RceFragment.cc.

64 {
65  // TODO check header
66  uint64_t header = *_data_ptr;
67  size_t bytes = (header >> 8) & 0xffffff;
68  bytes *= sizeof(uint64_t);
69 
70  std::ofstream b_stream(filepath.c_str(),
71  std::fstream::out | std::fstream::binary);
72 
73  char const* data = reinterpret_cast<decltype(data)>(_data_ptr);
74  b_stream.write(data, bytes);
75  b_stream.close();
76 }
const uint64_t * _data_ptr
Definition: RceFragment.hh:38
string filepath
Definition: train.py:371
byte bytes
Alias for common language habits.
Definition: datasize.h:101
int dune::RceFragment::size ( ) const
inline

Definition at line 25 of file RceFragment.hh.

25 { return _n_streams; }

Member Data Documentation

std::unique_ptr<DataFragmentUnpack> dune::RceFragment::_data_fragment
private

Definition at line 35 of file RceFragment.hh.

const uint64_t* dune::RceFragment::_data_ptr
private

Definition at line 38 of file RceFragment.hh.

int dune::RceFragment::_n_streams = 0
private

Definition at line 37 of file RceFragment.hh.

std::unique_ptr<TpcFragmentUnpack> dune::RceFragment::_tpc_fragment
private

Definition at line 36 of file RceFragment.hh.


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