Belle II Software development
RawCOPPERFormat_v2.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#ifndef RAWCOPPERFORMAT_V2_H
10#define RAWCOPPERFORMAT_V2_H
11
12// Includes
13#include <rawdata/dataobjects/RawCOPPERFormat.h>
14#include <rawdata/dataobjects/RawHeader_v2.h>
15#include <rawdata/dataobjects/RawTrailer_v2.h>
16#include <rawdata/CRCCalculator.h>
17
18/* #include <framework/datastore/DataStore.h> */
19/* #include <TObject.h> */
20
21//#define USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
22
23
24namespace Belle2 {
29
35
36 class RawCOPPERFormat_v2 : public RawCOPPERFormat {
37 public:
40
42 //RawCOPPERFormat_v2(int* bufin, int nwords);
44 virtual ~RawCOPPERFormat_v2();
45
46 //
47 // Get position of or pointer to data
48 //
50 // POINTER TO "DETECTOR BUFFER"
51 //( after removing "B2link headers" from "FINESSE buffer". THIS IS THE RAW DATA FROM A DETECTOR
53
54
56 /* cppcheck-suppress missingOverride */
57 int Get1stDetectorNwords(int n) OVERRIDE_CPP17;
58
60 /* cppcheck-suppress missingOverride */
61 int Get2ndDetectorNwords(int n) OVERRIDE_CPP17;
62
64 /* cppcheck-suppress missingOverride */
65 int Get3rdDetectorNwords(int n) OVERRIDE_CPP17;
66
68 /* cppcheck-suppress missingOverride */
69 int Get4thDetectorNwords(int n) OVERRIDE_CPP17;
70
72
74 /* cppcheck-suppress missingOverride */
75 int* GetRawTrlBufPtr(int n) OVERRIDE_CPP17;
76
77 //
78 // Get information from "RawCOPPERFormat_v2 header" attached by DAQ software
79 //
80
81 /* cppcheck-suppress missingOverride */
82 int GetExpNo(int n) OVERRIDE_CPP17;
83
84 /* cppcheck-suppress missingOverride */
85 unsigned int GetExpRunSubrun(int n) OVERRIDE_CPP17;
86
87 /* cppcheck-suppress missingOverride */
88 int GetRunNo(int n) OVERRIDE_CPP17;
89
90 /* cppcheck-suppress missingOverride */
91 int GetSubRunNo(int n) OVERRIDE_CPP17;
92
93 /* cppcheck-suppress missingOverride */
94 unsigned int GetEveNo(int n) OVERRIDE_CPP17;
95
96 /* cppcheck-suppress missingOverride */
97 int GetDataType(int n) OVERRIDE_CPP17;
98
99 /* cppcheck-suppress missingOverride */
100 int GetTruncMask(int n) OVERRIDE_CPP17;
101
103 /* cppcheck-suppress missingOverride */
104 unsigned int GetErrorBitFlag(int n) OVERRIDE_CPP17;
105
107 /* cppcheck-suppress missingOverride */
108 void AddErrorBitFlag(int n, unsigned int error_bit_flag) OVERRIDE_CPP17;
109
111 /* cppcheck-suppress missingOverride */
112 int GetPacketCRCError(int n) OVERRIDE_CPP17;
113
115 /* cppcheck-suppress missingOverride */
116 int GetEventCRCError(int n) OVERRIDE_CPP17;
117
119 /* cppcheck-suppress missingOverride */
120 unsigned int GetNodeID(int n) OVERRIDE_CPP17;
121
122 //
123 // Get information from 13words "COPPER header" attached by COPPER board
124 //
125
127 /* cppcheck-suppress missingOverride */
128 virtual int GetNumFINESSEBlock(int n) OVERRIDE_CPP17;
129
131 /* cppcheck-suppress missingOverride */
132 int Get1stFINESSENwords(int n) OVERRIDE_CPP17;
133
135 /* cppcheck-suppress missingOverride */
136 int Get2ndFINESSENwords(int n) OVERRIDE_CPP17;
137
139 /* cppcheck-suppress missingOverride */
140 int Get3rdFINESSENwords(int n) OVERRIDE_CPP17;
141
143 /* cppcheck-suppress missingOverride */
144 int Get4thFINESSENwords(int n) OVERRIDE_CPP17;
145
146 //
147 // Get information from "B2link(attached by FEE and HLSB) header"
148 //
150 // virtual int* GetFTSW2Words(int n);
151
152#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
154 /* cppcheck-suppress missingOverride */
155 void CheckB2LFEEHeaderVersion(int n) OVERRIDE_CPP17;
156#endif
157
159 /* cppcheck-suppress missingOverride */
160 unsigned int GetTTCtimeTRGType(int n) OVERRIDE_CPP17;
161
163 /* cppcheck-suppress missingOverride */
164 unsigned int GetTTUtime(int n) OVERRIDE_CPP17;
165
166 /* //! calc COPPER driver's checksum value */
167 /* virtual unsigned int CalcDriverChkSum(int n) = 0; */
168
169
171 /* cppcheck-suppress missingOverride */
172 int GetTTCtime(int n) OVERRIDE_CPP17;
173
175 /* cppcheck-suppress missingOverride */
176 int GetTRGType(int n) OVERRIDE_CPP17;
177
179 /* cppcheck-suppress missingOverride */
180 void GetTTTimeVal(int n, struct timeval* tv) OVERRIDE_CPP17;
181
183 /* cppcheck-suppress missingOverride */
184 int GetMaxNumOfCh(int n) OVERRIDE_CPP17;
185
187 enum {
188 DATA_FORMAT_VERSION = 2
189 };
190
193
196
197
198 protected :
200 // ClassDefOverride(RawCOPPERFormat_v2, 2);
201 };
202
203
204
205
207 {
208 int pos_nwords;
209 if (n == (m_num_events * m_num_nodes) - 1) {
210 pos_nwords = m_nwords - tmp_trailer.GetTrlNwords();
211 } else {
212 pos_nwords = GetBufferPos(n + 1) - tmp_trailer.GetTrlNwords();
213 }
214 return &(m_buffer[ pos_nwords ]);
215 }
216
218 {
219 tmp_header.SetBuffer(GetBuffer(n));
220 return tmp_header.GetExpNo();
221 }
222
223
224 inline unsigned int RawCOPPERFormat_v2::GetExpRunSubrun(int n)
225 {
226 tmp_header.SetBuffer(GetBuffer(n));
227 return tmp_header.GetExpRunSubrun();
228 }
229
230
232 {
233 tmp_header.SetBuffer(GetBuffer(n));
234 return tmp_header.GetRunNo();
235 }
236
237
239 {
240 tmp_header.SetBuffer(GetBuffer(n));
241 return tmp_header.GetSubRunNo();
242 }
243
244 inline unsigned int RawCOPPERFormat_v2::GetEveNo(int n)
245 {
246 tmp_header.SetBuffer(GetBuffer(n));
247 return tmp_header.GetEveNo();
248 }
249
250
251 inline unsigned int RawCOPPERFormat_v2::GetNodeID(int n)
252 {
253 tmp_header.SetBuffer(GetBuffer(n));
254 return tmp_header.GetNodeID();
255 }
256
257
259 {
260 tmp_header.SetBuffer(GetBuffer(n));
261 return tmp_header.GetDataType();
262 }
263
265 {
266 tmp_header.SetBuffer(GetBuffer(n));
267 return tmp_header.GetTruncMask();
268 }
269
270 inline unsigned int RawCOPPERFormat_v2::GetErrorBitFlag(int n)
271 {
272 tmp_header.SetBuffer(GetBuffer(n));
273 return tmp_header.GetErrorBitFlag();
274 }
275
276 inline void RawCOPPERFormat_v2::AddErrorBitFlag(int n, unsigned int error_bit_flag)
277 {
278 tmp_header.SetBuffer(GetBuffer(n));
279 tmp_header.AddErrorBitFlag(error_bit_flag);
280 return;
281 }
282
284 {
285 tmp_header.SetBuffer(GetBuffer(n));
286 return tmp_header.GetPacketCRCError();
287 }
288
290 {
291 tmp_header.SetBuffer(GetBuffer(n));
292 return tmp_header.GetEventCRCError();
293 }
294
295
297 {
298 return GetDetectorNwords(n, 0);
299 }
300
302 {
303 return GetDetectorNwords(n, 1);
304 }
305
307 {
308 return GetDetectorNwords(n, 2);
309 }
310
312 {
313 return GetDetectorNwords(n, 3);
314 }
315
316
317
319 {
320 return GetFINESSENwords(n, 0);
321 }
322
324 {
325 return GetFINESSENwords(n, 1);
326 }
327
329 {
330 return GetFINESSENwords(n, 2);
331 }
332
334 {
335 return GetFINESSENwords(n, 3);
336 }
337
338
339
340 inline unsigned int RawCOPPERFormat_v2::GetTTCtimeTRGType(int n)
341 {
342 tmp_header.SetBuffer(GetBuffer(n));
343 return tmp_header.GetTTCtimeTRGType();
344 }
345
346 inline unsigned int RawCOPPERFormat_v2::GetTTUtime(int n)
347 {
348 tmp_header.SetBuffer(GetBuffer(n));
349 return tmp_header.GetTTUtime();
350 }
351
353 {
354 tmp_header.SetBuffer(GetBuffer(n));
355 return tmp_header.GetTTCtime();
356 }
357
359 {
360 tmp_header.SetBuffer(GetBuffer(n));
361 return tmp_header.GetTRGType();
362 }
363
364 inline void RawCOPPERFormat_v2::GetTTTimeVal(int n, struct timeval* tv)
365 {
366 tmp_header.SetBuffer(GetBuffer(n));
367 tmp_header.GetTTTimeVal(tv);
368 return ;
369 }
370
372 {
373 return MAX_COPPER_CH;
374 }
375
377}
378#endif
RawTrailer_v2 tmp_trailer
trailer ( not recorded )
RawHeader_v2 tmp_header
header ( not recorded )
virtual int GetNumFINESSEBlock(int n) OVERRIDE_CPP17
get # of FINNESEs which contains data
virtual ~RawCOPPERFormat_v2()
Constructor using existing pointer to raw data buffer.
RawCOPPERFormat_v2()
Default constructor.
virtual int GetFINESSENwords(int n, int finesse)=0
get data size of FINESSE buffer
virtual int GetDetectorNwords(int n, int finesse_num)=0
set buffer ( delete_flag : m_buffer is freed( = 0 )/ not freed( = 1 ) in Destructor )
int m_num_events
number of events in this object
int m_num_nodes
number of nodes in this object
virtual int GetBufferPos(int n)
get position of data block in word
virtual int * GetBuffer(int n)
get nth buffer pointer
int m_nwords
number of words of buffer
The Raw Header class ver.1 ( the latest version since May, 2014 ) This class defines the format of th...
The Raw Trailer class ver.1 ( the latest version since May, 2014 ) This class defines the format of t...
int GetMaxNumOfCh(int n) OVERRIDE_CPP17
Get the max number of channels in a readout board.
int GetTTCtime(int n) OVERRIDE_CPP17
Get ctime.
int GetEventCRCError(int n) OVERRIDE_CPP17
check CRC event Error
int Get3rdFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot C buffer
unsigned int GetEveNo(int n) OVERRIDE_CPP17
get subrun #(8bit)
int Get1stFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot A buffer
int GetTruncMask(int n) OVERRIDE_CPP17
get contents of header
int Get3rdDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot C
unsigned int GetErrorBitFlag(int n) OVERRIDE_CPP17
get contents of header
int GetTRGType(int n) OVERRIDE_CPP17
Get trgtype.
void GetTTTimeVal(int n, struct timeval *tv) OVERRIDE_CPP17
Get timeval.
void AddErrorBitFlag(int n, unsigned int error_bit_flag) OVERRIDE_CPP17
Add Detected Error bitflag.
unsigned int GetExpRunSubrun(int n) OVERRIDE_CPP17
get Experimental # from header
int GetExpNo(int n) OVERRIDE_CPP17
get Experimental # from header
int Get4thFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot D buffer
int GetRunNo(int n) OVERRIDE_CPP17
Exp# (10bit) run# (14bit) restart # (8bit)
int GetPacketCRCError(int n) OVERRIDE_CPP17
check CRC packet Error
int Get4thDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot D
int Get2ndDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot B
unsigned int GetTTUtime(int n) OVERRIDE_CPP17
Check if COPPER Magic words are correct.
unsigned int GetNodeID(int n) OVERRIDE_CPP17
get node-ID from data
int GetDataType(int n) OVERRIDE_CPP17
get contents of header
int * GetRawTrlBufPtr(int n) OVERRIDE_CPP17
get buffer pointer of rawcopper trailer
unsigned int GetTTCtimeTRGType(int n) OVERRIDE_CPP17
get b2l block from "FEE b2link header"
int Get1stDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot A
int Get2ndFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot B buffer
int GetSubRunNo(int n) OVERRIDE_CPP17
get run # (14bit)
Abstract base class for different kinds of events.