BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/eformat/include/eformat/ROBFragment.h
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2
3/**
4 * @file eformat/ROBFragment.h
5 * @author <a href="mailto:Andre.dos.Anjos@cern.ch">Andre DOS ANJOS</a>
6 * $Author: maqm $
7 * $Revision: 1.3 $
8 * $Date: 2022/01/06 21:15:37 $
9 *
10 * @brief Defines the ROB fragment entity as described in the Event Format
11 * note.
12 */
13
14#ifndef EFORMAT_ROBFRAGMENT_H
15#define EFORMAT_ROBFRAGMENT_H
16
17#include "eformat/BadVersionIssue.h"
18#include "eformat/Header.h"
19#include "eformat/HeaderMarker.h"
20#include "eformat/SizeCheckIssue.h"
21#include "eformat/WrongMarkerIssue.h"
22
23namespace eformat {
24
25 /**
26 * Describes how to access the contents of a subdetector fragment, as
27 * prescribed by the event format note.
28 */
29 template <class TPointer> class ROBFragment : public eformat::Header<TPointer> {
30
31 public: // interface
32 /**
33 * To build a fragment given the containing buffer. I need to know
34 * where the fragment starts in order to do that.
35 *
36 * @param it The exact position where this fragment should start.
37 */
38 ROBFragment( const TPointer& it );
39
40 /**
41 * Copy constructor
42 *
43 * @param other The fragment to be copied
44 */
45 ROBFragment( const ROBFragment& other )
46 : Header<TPointer>( other ), m_start( other.m_start ) {}
47
48 /**
49 * Builds an empty, otherwise useless ROBFragment
50 */
51 ROBFragment() : Header<TPointer>(), m_start() {}
52
53 /**
54 * Destructor virtualisation
55 */
56 virtual ~ROBFragment() {}
57
58 /**
59 * Assignment
60 *
61 * @param other The fragment to be copied
62 */
65 m_start = other.m_start;
66 return *this;
67 }
68
69 /**
70 * Manual re-assignment
71 *
72 * @param it The position pointing the first word of this fragment
73 */
74 ROBFragment& assign( const TPointer& it );
75
76 /**
77 * Says if the the fragment is valid. This may throw exceptions.
78 */
79 virtual bool check() const;
80
81 /**
82 * Says if the the fragment is valid. This may throw exceptions.
83 */
84 inline bool check_tree() const {
85 check();
86 return true;
87 }
88
89 /**
90 * Returns the fragment type.
91 */
92 inline uint32_t rod_marker() const { return m_start[0]; }
93
94 /**
95 * Returns the total fragment size
96 */
97 inline uint32_t rod_fragment_size_word() const { return this->payload_size_word(); }
98
99 /**
100 * Returns the size, in words, of the current header. That does @b
101 * not include the trailer.
102 */
103 inline uint32_t rod_header_size_word() const { return m_start[1]; }
104
105 /**
106 * Returns the size, in words, of the trailer
107 */
108 inline uint32_t rod_trailer_size_word() const { return 3; }
109
110 /**
111 * Returns the formatting version.
112 */
113 inline uint32_t rod_version() const { return m_start[2]; }
114
115 /**
116 * Returns the full source identifier.
117 */
118 inline uint32_t rod_source_id() const { return m_start[3]; }
119
120 /**
121 * Returns the current run number.
122 */
123 inline uint32_t rod_run_no() const { return m_start[4]; }
124
125 /**
126 * Returns the lvl1 identifier
127 */
128 inline uint32_t rod_lvl1_id() const { return m_start[5]; }
129
130 /**
131 * Returns the bunch crossing identifier
132 */
133 inline uint32_t rod_bc_id() const { return m_start[6]; }
134
135 /**
136 * Returns the lvl1 trigger type
137 */
138 inline uint32_t rod_lvl1_trigger_type() const { return m_start[7]; }
139
140 /**
141 * Returns the detector event type
142 */
143 inline uint32_t rod_detev_type() const { return m_start[8]; }
144
145 /**
146 * Returns the number of status words available
147 */
148 inline uint32_t rod_nstatus() const { return m_start[this->payload_size_word() - 3]; }
149
150 /**
151 * Returns the status words, as an iterator to the status words
152 * available.
153 *
154 * @param it An <em>updateable</em> iterator you should provide.
155 */
156 void rod_status( TPointer& it ) const;
157
158 /**
159 * Returns the number of data words available
160 */
161 inline uint32_t rod_ndata() const { return m_start[this->payload_size_word() - 2]; }
162
163 /**
164 * Returns a pointer to the first data word
165 *
166 * @param it An <em>updateable</em> iterator you should provide.
167 */
168 void rod_data( TPointer& it ) const;
169
170 /**
171 * Returns the status block position. A value of <tt>zero</tt> indicates
172 * that the status block preceeds the data block. A value of <tt>one</tt>
173 * means the contrary.
174 */
175 inline uint32_t rod_status_position() const {
176 return m_start[this->payload_size_word() - 1];
177 }
178
179 private: // static stuff
180 static const uint32_t NSPECIFIC;
181
182 private: // representation
183 TPointer m_start; ///< my last word
184 };
185
186} // namespace eformat
187
188template <class TPointer> const uint32_t eformat::ROBFragment<TPointer>::NSPECIFIC = 0;
189
190template <class TPointer>
192 : eformat::Header<TPointer>( it, eformat::ROB ), m_start() {
193 ERS_DEBUG_3( "Building ROBFragment from pointer" );
195 ERS_DEBUG_1( "Initialized header with source identifier = %s",
196 eformat::helper::SourceIdentifier( source_id() ).human().c_str() );
197 ERS_DEBUG_3( "Building underlying RODFragment" );
199 ERS_DEBUG_1( "Initialized ROD header with source identifier = %s",
201}
202
203template <class TPointer>
205 ERS_DEBUG_3( "Re-building ROBFragment from pointer" );
207 // maqm commentspecific_heademt::Header<TPointer>::(m_start);
208 ERS_DEBUG_1( "Initialized header with source identifier = %s",
209 eformat::helper::SourceIdentifier( source_id() ).human().c_str() );
210 ERS_DEBUG_3( "Re-building underlying RODFragment" );
212 ERS_DEBUG_1( "Reinitialized header with source identifier = %s",
214 return *this;
215}
216
217template <class TPointer> bool eformat::ROBFragment<TPointer>::check() const {
218 // ROB checking
219 ERS_DEBUG_2( "Checking for consistency of ROBFragment [%s]",
220 eformat::helper::SourceIdentifier( source_id() ).human().c_str() );
221 eformat::Header<TPointer>::check(); //< first do a generic check
222 if ( eformat::Header<TPointer>::nspecific() != NSPECIFIC )
223 throw EFORMAT_SIZE_CHECK( NSPECIFIC, this->nspecific() );
224
225 // ROD checking
226 ERS_DEBUG_2( "Checking for consistency of RODFragment [%s]",
231 if ( rod_fragment_size_word() != 12 + rod_nstatus() + rod_ndata() )
233 return true;
234}
235
236template <class TPointer>
238 it = m_start;
239 it += 9;
240 if ( rod_status_position() ) it += rod_ndata();
241}
242
243template <class TPointer> void eformat::ROBFragment<TPointer>::rod_data( TPointer& it ) const {
244 it = m_start;
245 it += 9;
246 if ( !rod_status_position() ) it += rod_nstatus();
247}
248
249#endif /* EFORMAT_ROBFRAGMENT_H */
#define EFORMAT_BAD_VERSION(current, supported)
#define EFORMAT_SIZE_CHECK(actual, informed)
#define EFORMAT_WRONG_MARKER(current, expected)
#define ERS_DEBUG_1(...)
#define ERS_DEBUG_3(...)
#define ERS_DEBUG_2(...)
Header & operator=(const Header &other)
Header(const TPointer &it, uint32_t match)
Header & assign(const TPointer &it, uint32_t match)
void specific_header(TPointer &it) const
ROBFragment & operator=(const ROBFragment &other)
ROBFragment & assign(const TPointer &it)