Belle II Software development
PostRawCOPPERFormat_v1.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 POSTRAWCOPPERFORMAT_V1_H
10#define POSTRAWCOPPERFORMAT_V1_H
11
12// Includes
13#include <stdio.h>
14#include <string>
15
16#include <rawdata/dataobjects/RawCOPPERFormat_v1.h>
17#include <rawdata/CRCCalculator.h>
18
19//#define USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
20
21namespace Belle2 {
33 public:
36
38 //PostRawCOPPERFormat_v1(int* bufin, int nwords);
41
42 //
43 // Get position of or pointer to data
44 //
46 // POINTER TO "DETECTOR BUFFER"
47 //( after removing "B2link headers" from "FINESSE buffer". THIS IS THE RAW DATA FROM A DETECTOR
49
51 /* cppcheck-suppress missingOverride */
52 int GetDetectorNwords(int n, int finesse_num) OVERRIDE_CPP17;
53
55 /* cppcheck-suppress missingOverride */
56 int* Get1stDetectorBuffer(int n) OVERRIDE_CPP17;
57
59 /* cppcheck-suppress missingOverride */
60 int* Get2ndDetectorBuffer(int n) OVERRIDE_CPP17;
61
63 /* cppcheck-suppress missingOverride */
64 int* Get3rdDetectorBuffer(int n) OVERRIDE_CPP17;
65
67 /* cppcheck-suppress missingOverride */
68 int* Get4thDetectorBuffer(int n) OVERRIDE_CPP17;
70
72 // virtual int GetBufferPos(int n);
73
74 //
75 // Get information from 13words "COPPER header" attached by COPPER board
76 //
78 /* cppcheck-suppress missingOverride */
79 unsigned int GetCOPPERCounter(int n) OVERRIDE_CPP17;
80
82 /* cppcheck-suppress missingOverride */
83 int GetOffset1stFINESSE(int n) OVERRIDE_CPP17;
84
86 /* cppcheck-suppress missingOverride */
87 int GetFINESSENwords(int n, int finesse) OVERRIDE_CPP17;
88
89 //
90 // Get information from "B2link(attached by FEE and HLSB) header"
91 //
93 // virtual int* GetFTSW2Words(int n);
94
96 /* cppcheck-suppress missingOverride */
97 virtual int* GetExpRunSubrunBuf(int n) OVERRIDE_CPP17;
98
100 /* cppcheck-suppress missingOverride */
101 virtual unsigned int GetB2LFEE32bitEventNumber(int n) OVERRIDE_CPP17;
102
103 //
104 // read magic word to check data
105 //
107 /* cppcheck-suppress missingOverride */
108 unsigned int GetMagicDriverHeader(int n) OVERRIDE_CPP17;
109
111 /* cppcheck-suppress missingOverride */
112 unsigned int GetMagicFPGAHeader(int n) OVERRIDE_CPP17;
113
115 /* cppcheck-suppress missingOverride */
116 unsigned int GetMagicFPGATrailer(int n) OVERRIDE_CPP17;
117
119 /* cppcheck-suppress missingOverride */
120 unsigned int GetMagicDriverTrailer(int n) OVERRIDE_CPP17;
121
123 /* cppcheck-suppress missingOverride */
124 unsigned int GetTrailerChksum(int n) OVERRIDE_CPP17;
125
127 /* cppcheck-suppress missingOverride */
128 bool CheckCOPPERMagic(int n) OVERRIDE_CPP17;
129
131 /* cppcheck-suppress missingOverride */
132 unsigned int FillTopBlockRawHeader(unsigned int m_node_id, unsigned int prev_eve32,
133 unsigned int prev_exprunsubrun_no, unsigned int* cur_exprunsubrun_no) OVERRIDE_CPP17;
134
136 /* cppcheck-suppress missingOverride */
137 unsigned int GetDriverChkSum(int n) OVERRIDE_CPP17;
138
140 /* cppcheck-suppress missingOverride */
141 unsigned int CalcDriverChkSum(int n) OVERRIDE_CPP17;
142
144 /* cppcheck-suppress missingOverride */
145 void CheckData(int n,
146 unsigned int prev_evenum, unsigned int* cur_evenum,
147 unsigned int prev_copper_ctr, unsigned int* cur_copper_ctr,
148 unsigned int prev_exprunsubrun_no, unsigned int* cur_exprunsubrun_no) OVERRIDE_CPP17;
149
151 /* cppcheck-suppress missingOverride */
152 void CheckUtimeCtimeTRGType(int n) OVERRIDE_CPP17;
153
155 int CheckB2LHSLBMagicWords(int* finesse_buf, int finesse_nwords);
156
158 int CheckCRC16(int n, int finesse_num);
159
161 /* cppcheck-suppress missingOverride */
162 int* PackDetectorBuf(int* packed_buf_nwords,
163 int* detector_buf_1st, int nwords_1st,
164 int* detector_buf_2nd, int nwords_2nd,
165 int* detector_buf_3rd, int nwords_3rd,
166 int* detector_buf_4th, int nwords_4th,
167 RawCOPPERPackerInfo rawcprpacker_info) OVERRIDE_CPP17;
168
169 //
170 // size of "COPPER front header" and "COPPER trailer"
171 //
173
174 enum {
175 SIZE_COPPER_DRIVER_HEADER = 0,
176 SIZE_COPPER_DRIVER_TRAILER = 0
177 };
178
179 // Data Format : "COPPER header"
180 enum {
181 SIZE_COPPER_HEADER = 0
182 };
183
184 // Data Format : "COPPER Trailer"
185 enum {
186 SIZE_COPPER_TRAILER = 0
187 };
188
189 // Data Format : "B2Link HSLB Header"
190 enum {
191 POS_B2LHSLB_MAGIC = 0,
192 SIZE_B2LHSLB_HEADER = 1
193 };
194
195
196 // Data Format : "B2Link FEE Header"
197 enum {
198 POS_B2L_CTIME = 0,
199 SIZE_B2LFEE_HEADER = 1
200 };
201
202 // Data Format : B2Link FEE Trailer
203 enum {
204 POS_B2LFEE_CRC16 = 0,
205 SIZE_B2LFEE_TRAILER = 1
206 };
207
208 //
209 // Data Format : "B2Link HSLB Trailer"
210 //
211 enum {
212 SIZE_B2LHSLB_TRAILER = 0
213 };
214
215
216
217 protected :
219 // ClassDefOverride(PostRawCOPPERFormat_v1, 2);
220
221 };
222
224 {
225 int pos_nwords = GetBufferPos(n) + tmp_header.RAWHEADER_NWORDS + SIZE_COPPER_HEADER;
226 return pos_nwords;
227 }
228
230 {
231#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
232 CheckB2LFEEHeaderVersion(n);
233#endif
234 if (Get1stFINESSENwords(n) > 0) {
235 int pos_nwords = GetOffset1stFINESSE(n) + SIZE_B2LHSLB_HEADER + SIZE_B2LFEE_HEADER;
236 return &(m_buffer[ pos_nwords ]);
237 }
238 return NULL;
239 }
240
242 {
243#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
244 CheckB2LFEEHeaderVersion(n);
245#endif
246 if (Get2ndFINESSENwords(n) > 0) {
247 int pos_nwords = GetOffset2ndFINESSE(n) + SIZE_B2LHSLB_HEADER + SIZE_B2LFEE_HEADER;
248 return &(m_buffer[ pos_nwords ]);
249 }
250 return NULL;
251 }
252
254 {
255#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
256 CheckB2LFEEHeaderVersion(n);
257#endif
258 if (Get3rdFINESSENwords(n) > 0) {
259 int pos_nwords = GetOffset3rdFINESSE(n) + SIZE_B2LHSLB_HEADER + SIZE_B2LFEE_HEADER;
260 return &(m_buffer[ pos_nwords ]);
261 }
262 return NULL;
263 }
264
266 {
267#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
268 CheckB2LFEEHeaderVersion(n);
269#endif
270 if (Get4thFINESSENwords(n) > 0) {
271 int pos_nwords = GetOffset4thFINESSE(n) + SIZE_B2LHSLB_HEADER + SIZE_B2LFEE_HEADER;
272 return &(m_buffer[ pos_nwords ]);
273 }
274 return NULL;
275 }
276
278 {
279 int pos_nwords = GetBufferPos(n) + tmp_header.POS_EXP_RUN_NO;
280 return &(m_buffer[ pos_nwords ]);
281 /* #ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2 */
282 /* CheckB2LFEEHeaderVersion(n); */
283 /* #endif */
284 /* int pos_nwords = GetOffset1stFINESSE(n) + SIZE_B2LHSLB_HEADER + POS_EXP_RUN; */
285 /* return &(m_buffer[ pos_nwords ]); */
286 }
287
289 {
290 int pos_nwords = GetBufferPos(n) + GetBlockNwords(n)
291 - tmp_trailer.RAWTRAILER_NWORDS - SIZE_COPPER_DRIVER_TRAILER;
292 return m_buffer[ pos_nwords ];
293 }
294
295
297 {
298 char err_buf[500];
299 sprintf(err_buf, "This data format does not have COPPER counter.(block %d) Exiting...\n %s %s %d\n",
300 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
301 std::string err_str = err_buf; throw (err_str);
302 return 0;
303 }
304
306 {
307 char err_buf[500];
308 sprintf(err_buf, "This function is not supported. (block %d) Exiting...\n %s %s %d\n",
309 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
310 std::string err_str = err_buf; throw (err_str);
311 return 0;
312 }
313
315 {
316 char err_buf[500];
317 sprintf(err_buf, "This function is not supported. (block %d) Exiting...\n %s %s %d\n",
318 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
319 std::string err_str = err_buf; throw (err_str);
320 return 0;
321 }
322
323
325 {
326 int pos_nwords = GetBufferPos(n) + GetBlockNwords(n) - tmp_trailer.GetTrlNwords() - 3;
327
328 // printf( "[DEBUG] 1 %d 2 %d 3 %d\n", GetBufferPos(n), GetBlockNwords(n), tmp_trailer.GetTrlNwords());
329
330 return (unsigned int)(m_buffer[ pos_nwords ]);
331 }
332
334 {
335 int pos_nwords = GetBufferPos(n) + GetBlockNwords(n) - tmp_trailer.GetTrlNwords() - 1;
336 return (unsigned int)(m_buffer[ pos_nwords ]);
337 }
338
339
341 {
342 int pos_nwords = GetBufferPos(n) + GetBlockNwords(n) - tmp_trailer.GetTrlNwords() + tmp_trailer.POS_CHKSUM;
343 return (unsigned int)(m_buffer[ pos_nwords ]);
344 }
345
346
347
348
350}
351
352#endif
The Raw COPPER class ver.1 ( the latest version since May, 2014 ) This class stores data received by ...
int CheckB2LHSLBMagicWords(int *finesse_buf, int finesse_nwords)
check magic words
int CheckCRC16(int n, int finesse_num)
check magic words
int * PackDetectorBuf(int *packed_buf_nwords, int *detector_buf_1st, int nwords_1st, int *detector_buf_2nd, int nwords_2nd, int *detector_buf_3rd, int nwords_3rd, int *detector_buf_4th, int nwords_4th, RawCOPPERPackerInfo rawcprpacker_info) OVERRIDE_CPP17
Pack data (format ver. = -1 -> Select the latest format version)
void CheckUtimeCtimeTRGType(int n) OVERRIDE_CPP17
check data contents
unsigned int FillTopBlockRawHeader(unsigned int m_node_id, unsigned int prev_eve32, unsigned int prev_exprunsubrun_no, unsigned int *cur_exprunsubrun_no) OVERRIDE_CPP17
should be called by DeSerializerCOPPER.cc and fill contents in RawHeader
virtual unsigned int GetB2LFEE32bitEventNumber(int n) OVERRIDE_CPP17
get b2l block from "FEE b2link header"
virtual ~PostRawCOPPERFormat_v1()
Constructor using existing pointer to raw data buffer.
int GetDetectorNwords(int n, int finesse_num) OVERRIDE_CPP17
get Detector buffer length
bool CheckCOPPERMagic(int n) OVERRIDE_CPP17
Check if COPPER Magic words are correct.
unsigned int CalcDriverChkSum(int n) OVERRIDE_CPP17
calc COPPER driver's checksum value
PostRawCOPPERFormat_v1()
Default constructor.
int GetFINESSENwords(int n, int finesse) OVERRIDE_CPP17
get data size of FINESSE buffer
void CheckData(int n, unsigned int prev_evenum, unsigned int *cur_evenum, unsigned int prev_copper_ctr, unsigned int *cur_copper_ctr, unsigned int prev_exprunsubrun_no, unsigned int *cur_exprunsubrun_no) OVERRIDE_CPP17
check data contents
The Raw COPPER class ver.1 ( the latest version since May, 2014 ) This class stores data received by ...
RawTrailer_v1 tmp_trailer
trailer ( not recorded )
RawHeader_v1 tmp_header
header ( not recorded )
struct to contain header information used by RawCOPPERFormat::Packer()
virtual int GetBlockNwords(int n)
get size of a data block
virtual int GetBufferPos(int n)
get position of data block in word
int Get3rdFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot C buffer
unsigned int GetDriverChkSum(int n) OVERRIDE_CPP17
read COPPER driver's checksum value
int GetOffset1stFINESSE(int n) OVERRIDE_CPP17
get # of offset words for FINESSE slot A buffer position
unsigned int GetCOPPERCounter(int n) OVERRIDE_CPP17
get posistion of COPPER block in unit of word
unsigned int GetMagicFPGATrailer(int n) OVERRIDE_CPP17
get magic word of COPPER FPGA trailer
int Get1stFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot A buffer
unsigned int GetMagicDriverTrailer(int n) OVERRIDE_CPP17
get magic word of COPPER driver trailer
int * Get2ndDetectorBuffer(int n) OVERRIDE_CPP17
get Detector Buffer of slot B
virtual int GetOffset2ndFINESSE(int n)
get # of offset words for FINESSE slot B buffer position
int GetTrlNwords()
Set magic word.
unsigned int GetMagicFPGAHeader(int n) OVERRIDE_CPP17
get magic word of COPPER FPGA header
unsigned int GetTrailerChksum(int n) OVERRIDE_CPP17
Get checksum in RawTrailer.
int * Get4thDetectorBuffer(int n) OVERRIDE_CPP17
get Detector Buffer of slot D
int Get4thFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot D buffer
virtual int GetOffset4thFINESSE(int n)
get # of offset words for FINESSE slot D buffer position
virtual int GetOffset3rdFINESSE(int n)
get # of offset words for FINESSE slot C buffer position
virtual int * GetExpRunSubrunBuf(int n) OVERRIDE_CPP17
get b2l block from "FEE b2link header"
int * Get3rdDetectorBuffer(int n) OVERRIDE_CPP17
get Detector Buffer of slot C
unsigned int GetMagicDriverHeader(int n) OVERRIDE_CPP17
get magic word of COPPER driver header
int * Get1stDetectorBuffer(int n) OVERRIDE_CPP17
get Detector buffer of slot A
int Get2ndFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot B buffer
Abstract base class for different kinds of events.