CTBFragment.cc
Go to the documentation of this file.
2 
3 namespace dune {
4 
5 
6  std::ostream & operator << (std::ostream & out, CTBFragment const & f ) {
7 
8  out << "Fragment size: " << f.artdaq_Fragment_.dataSizeBytes() << " -> " << f._n_words << " words" << std::endl ;
9 
10  for ( unsigned int i = 0; i < f.NWords() ; ++i ) {
11 
12  if ( f.Trigger(i) ) {
13  out << "Trigger word " << std::hex << f.Trigger(i) -> word_type
14  << ", payload: " << f.Trigger(i) -> trigger_word
15  << ", TS: " << f.Trigger(i) -> timestamp << std::dec << std::endl ;
16  }
17  else if ( f.ChStatus(i) ) {
18  out << "Check Status word " << std::hex
19  << " PDS " << f.ChStatus(i) -> get_pds()
20  << ", CRT: " << f.ChStatus(i) -> get_crt()
21  << ", Beam: " << f.ChStatus(i) -> get_beam()
22  << ", TS: " << f.ChStatus(i) -> timestamp
23  << std::dec << std::endl ;
24 
25  }
26  else if ( f.Feedback(i) ) {
27  out << "Feedback word " << std::hex
28  << ", Padding: " << f.Feedback(i) -> padding
29  << ", Source: " << f.Feedback(i) -> source
30  << ", Code: " << f.Feedback(i) -> code
31  << ", TS: " << f.Feedback(i) -> timestamp << std::dec << std::endl ;
32 
33  }
34  else {
35  out << "type: " << std::hex << f.Word(i) -> word_type
36  << ", payload: " << f.Word(i) -> payload
37  << ", TS: " << f.Word(i) -> timestamp << std::dec << std::endl ;
38  }
39 
40  }
41 
42 
43  return out ;
44  }
45 
46 
47 
48  CTBFragment::CTBFragment( artdaq::Fragment const & f ) :
49 
50  _n_words( f.dataSizeBytes()/CTBFragment::WordSize() ),
51  artdaq_Fragment_( f )
52  { ; }
53 
54 
55  //--------------------------------
56  // word getters
57  //--------------------------------
58 
59  const ptb::content::word::word_t* CTBFragment::Word( unsigned int i ) const {
60 
61  if ( i >= NWords() ) return nullptr ;
62 
63  return reinterpret_cast<const ptb::content::word::word_t*>( artdaq_Fragment_.dataBeginBytes() + i * CTBFragment::WordSize() ) ;
64 
65  }
66 
67 
68  const ptb::content::word::feedback_t* CTBFragment::Feedback( unsigned int i ) const {
69 
70  const ptb::content::word::word_t* w = Word( i ) ;
71 
72  if ( ! w ) return nullptr ;
73 
74  return CTBFragment::Feedback( *w ) ;
75 
76  }
77 
78 
79  const ptb::content::word::ch_status_t* CTBFragment::ChStatus( unsigned int i ) const {
80 
81  const ptb::content::word::word_t* w = Word( i ) ;
82 
83  if ( ! w ) return nullptr ;
84 
85  return CTBFragment::ChStatus( *w ) ;
86 
87  }
88 
89 
91 
92  const ptb::content::word::word_t* w = Word( i ) ;
93 
94  if ( ! w ) return nullptr ;
95 
96  return CTBFragment::Timestamp( *w ) ;
97 
98  }
99 
100 
101  const ptb::content::word::trigger_t * CTBFragment::Trigger( unsigned int i ) const {
102 
103  const ptb::content::word::word_t* w = Word( i ) ;
104 
105  if ( ! w ) return nullptr ;
106 
107  return CTBFragment::Trigger( *w ) ;
108 
109  }
110 
111 
112 
113  // casting methods
114 
116 
117  if ( w.word_type != ptb::content::word::t_fback ) return nullptr ;
118 
119  return reinterpret_cast<const ptb::content::word::feedback_t*>( & w ) ;
120 
121  }
122 
124 
125  if ( w.word_type != ptb::content::word::t_ch ) return nullptr ;
126 
127  return reinterpret_cast<const ptb::content::word::ch_status_t*>( & w ) ;
128 
129  }
130 
132 
133  if ( w.word_type != ptb::content::word::t_ts ) return nullptr ;
134 
135  return reinterpret_cast<const ptb::content::word::timestamp_t*>( & w ) ;
136 
137  }
138 
140 
141  if ( w.word_type != ptb::content::word::t_lt && w.word_type != ptb::content::word::t_gt ) return nullptr ;
142 
143  return reinterpret_cast<const ptb::content::word::trigger_t*>( & w ) ;
144 
145  }
146 
147 } // namespace dune
148 
const ptb::content::word::ch_status_t * ChStatus(unsigned int i) const
Definition: CTBFragment.cc:79
artdaq::Fragment const & artdaq_Fragment_
Definition: CTBFragment.hh:98
std::ostream & operator<<(std::ostream &out, CTBFragment const &f)
Definition: CTBFragment.cc:6
const ptb::content::word::word_t * Word(unsigned int i) const
Definition: CTBFragment.cc:59
const unsigned int _n_words
Definition: CTBFragment.hh:96
QTextStream & hex(QTextStream &s)
CodeOutputInterface * code
const ptb::content::word::trigger_t * Trigger(unsigned int i) const
Definition: CTBFragment.cc:101
CTBFragment(artdaq::Fragment const &f)
Definition: CTBFragment.cc:48
QTextStream & dec(QTextStream &s)
const ptb::content::word::timestamp_t * Timestamp(unsigned int i) const
Definition: CTBFragment.cc:90
const ptb::content::word::feedback_t * Feedback(unsigned int i) const
Definition: CTBFragment.cc:68
unsigned int NWords() const noexcept
Definition: CTBFragment.hh:47
QTextStream & endl(QTextStream &s)
static constexpr unsigned int WordSize()
Definition: CTBFragment.hh:86