CTBFragment.hh
Go to the documentation of this file.
1 #ifndef dune_artdaq_Overlays_CTBFragment_hh
2 #define dune_artdaq_Overlays_CTBFragment_hh
3 
4 #include "artdaq-core/Data/Fragment.hh"
5 
7 
8 #include <ostream>
9 #include <vector>
10 
11 
12 
13 
14 /*
15 -------------------------------------
16 Brief guide to CTB fragments
17 -------------------------------------
18 
19  The CTB keeps sending information to the DAQ at all times.
20  Its fragments are just random collections of words
21  from the trigger board.
22  In this context "random" means that the wrapping is not particularly significant
23  and it is determined by pure convenience during runtime.
24 
25  Hence the structure of fragments is quite simple.
26  It is just an array of trigger words.
27  The trigger words are defined in the content.h file, see include.
28 
29  This overlay classes is just providing the proper readouts and
30  casts to the proper word type.
31 
32 */
33 
34 namespace dune {
35 
36 
37 class CTBFragment {
38  public:
39 
40  // The constructor simply sets its const private member "artdaq_Fragment_"
41  // to refer to the artdaq::Fragment object
42 
43  CTBFragment( artdaq::Fragment const & f ) ;
44 
45 
46  // const getter functions for the data in the header
47  unsigned int NWords() const noexcept { return _n_words ; }
48 
49  // array-like access to the words, index from 0 to NWords()-1
50  // this pointer should always be valid, if not there is a problem
51  // tipically i is too big
52  const ptb::content::word::word_t * operator [] ( unsigned int i ) const { return Word(i) ; }
53 
54  // casted words depending on their type for easy deconding
55  // An null pointer as a return means the requested cast is not correct
56 
57  // access to the generic word structure.
58  // This simply allows access to word type, TS
59  // and the payload is not formatted
60  // this pointer should always be valid, if not there is a problem
61  const ptb::content::word::word_t* Word( unsigned int i ) const ;
62 
63  // These are words that report errors from the board
64  const ptb::content::word::feedback_t* Feedback( unsigned int i ) const ;
65 
66  // Channel status reports
67  const ptb::content::word::ch_status_t* ChStatus( unsigned int i ) const ;
68 
69  // simple mask to make explicit that this was a TS word
70  const ptb::content::word::timestamp_t* Timestamp( unsigned int i ) const ;
71 
72  // Trigger words
73  // There are a number of trigger words, the complete list being
74  // - High level trigger (HLT)
75  // - Low level trigger (LLT)
76  // yet the payload is organized in the same way and so the casting
77  // function is the same
78  const ptb::content::word::trigger_t * Trigger( unsigned int i ) const ;
79 
80  //static methods for casting
85 
86  static constexpr unsigned int WordSize() { return sizeof( ptb::content::word::word_t ) ; }
87 
88  friend std::ostream & operator << (std::ostream &, CTBFragment const & ) ;
89 
90 protected:
91 
92  //maybe let's put some utilities here
93 
94 private:
95 
96  const unsigned int _n_words ;
97 
98  artdaq::Fragment const & artdaq_Fragment_;
99 
100 };
101 
102 
103 } // dune namespace
104 
105 #endif /* dune_artdaq_Overlays_CTBFragment_hh */
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
const ptb::content::word::word_t * Word(unsigned int i) const
Definition: CTBFragment.cc:59
friend std::ostream & operator<<(std::ostream &, CTBFragment const &)
Definition: CTBFragment.cc:6
const unsigned int _n_words
Definition: CTBFragment.hh:96
const ptb::content::word::trigger_t * Trigger(unsigned int i) const
Definition: CTBFragment.cc:101
CTBFragment(artdaq::Fragment const &f)
Definition: CTBFragment.cc:48
const ptb::content::word::word_t * operator[](unsigned int i) const
Definition: CTBFragment.hh:52
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
struct ptb::content::word::word_t word_t
static constexpr unsigned int WordSize()
Definition: CTBFragment.hh:86