Belle II Software development
RawTLUFormat.cc
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#include <rawdata/dataobjects/RawTLUFormat.h>
10using namespace std;
11using namespace Belle2;
12
14{
15}
16
18{
19}
20
21// int RawTLUFormat::GetNwords(int n)
22// {
23// return m_buffer[ GetBufferPos(n) + POS_NWORDS ];
24// }
25
27{
28 return m_buffer[ GetBufferPos(n) + POS_HDR_NWORDS ];
29}
30
31
32unsigned int RawTLUFormat::GetNodeID(int n)
33{
34 return (unsigned int)(m_buffer[ GetBufferPos(n) + POS_NODE_ID ]);
35}
36
37unsigned int RawTLUFormat::GetEveNo(int n)
38{
39 return m_buffer[ GetBufferPos(n) + POS_EVE_NO ];
40}
41
42
44{
45 return m_buffer[ GetBufferPos(n) + POS_RUN_NO ];
46}
47
48
50{
51 return m_buffer[ GetBufferPos(n) + POS_MAGIC_1 ];
52}
53
55{
56 return m_buffer[ GetBufferPos(n) + POS_TLU_EVENTTAG ];
57}
58
59
61 unsigned int prev_evenum, unsigned int* cur_evenum)
62{
63 int err_flag = 0;
64 char err_buf[500];
65 *cur_evenum = GetEveNo(n);
66
67#ifndef NO_DATA_CHECK
68 if (prev_evenum != 0xFFFFFFFF && *cur_evenum != 0) {
69 if ((unsigned int)(prev_evenum + 1) != *cur_evenum) {
70 sprintf(err_buf, "Event # jump : i %d prev 0x%x cur 0x%x : Exiting...\n %s %s %d\n",
71 n, prev_evenum, *cur_evenum, __FILE__, __PRETTY_FUNCTION__, __LINE__);
72 err_flag = 1;
73 }
74 }
75#endif
76
77 if (GetEveNo(n) != GetTLUEventTag(n)) {
78 sprintf(err_buf, "invalid TLU event tag : blodk %d header eve # %u TLU tag %u. Exiting...\n %s %s %d\n",
79 n, GetEveNo(n), GetTLUEventTag(n), __FILE__, __PRETTY_FUNCTION__, __LINE__);
80 err_flag = 1;
81 }
82
83
84 if (GetBlockNwords(n) != SIZE_TLU_PACKET) {
85 sprintf(err_buf, "invalid TLU packet length : block %d nwords %d must be %d : Exiting...\n %s %s %d\n",
86 n, GetBlockNwords(n), SIZE_TLU_PACKET, __FILE__, __PRETTY_FUNCTION__, __LINE__);
87 err_flag = 1;
88 }
89
90 if (GetMagicTrailer(n) != TLU_MAGIC_TRAILER) {
91 sprintf(err_buf, "invalid magic word : block %d magic word 0x%x must be 0x%x : Exiting...\n %s %s %d\n",
92 n, GetMagicTrailer(n), TLU_MAGIC_TRAILER, __FILE__, __PRETTY_FUNCTION__, __LINE__);
93 err_flag = 1;
94 }
95
96 if (err_flag == 1) {
97 printf("[DEBUG] ========== dump a data block : block # %d==========\n", n);
98 printf("[DEBUG] ");
99 for (int k = 0 ; k < GetBlockNwords(n); k++) {
100 printf("0x%.8x ", (GetBuffer(n))[k]);
101 if (k % 10 == 9) printf("\n[DEBUG] ");
102 }
103 fflush(stderr);
104 B2FATAL(err_buf);
105 }
106
107 return;
108}
virtual int GetBlockNwords(int n)
get size of a data block
virtual int GetBufferPos(int n)
get position of data block in word
virtual int * GetBuffer(int n)
get nth buffer pointer
void CheckData(int n, unsigned int prev_evenum, unsigned int *cur_evenum)
check data contents
Definition: RawTLUFormat.cc:60
unsigned int GetEveNo(int n)
Get Event #.
Definition: RawTLUFormat.cc:37
virtual ~RawTLUFormat()
Destructor.
Definition: RawTLUFormat.cc:17
int GetNwordsHeader(int n)
Get the size of the header.
Definition: RawTLUFormat.cc:26
unsigned int GetMagicTrailer(int n)
Get Magic Trailer #.
Definition: RawTLUFormat.cc:49
RawTLUFormat()
Default constructor.
Definition: RawTLUFormat.cc:13
unsigned int GetNodeID(int n)
Get Node ID.
Definition: RawTLUFormat.cc:32
int GetRunNo(int n)
Get Run #.
Definition: RawTLUFormat.cc:43
unsigned int GetTLUEventTag(int n)
Get TLU event tag.
Definition: RawTLUFormat.cc:54
Abstract base class for different kinds of events.
STL namespace.