Belle II Software  release-08-01-10
RawHeader_v1.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/RawHeader_v1.h>
10 
11 
12 
13 using namespace Belle2;
14 
15 //ClassImp(RawHeader_v1);
16 
18 {
19  m_buffer = NULL;
20  // initialize();
21  // cout << "RawHeader_v1 NULL constructor" << endl;
22 }
23 
25 {
26  m_buffer = buffer;
27 }
28 
30 {
31 }
32 
33 
34 // int RawHeader_v1::AddNodeInfo(int node_id)
35 // {
36 // CheckSetBuffer();
37 // // When the number of total nodes exceeds NUM_MAX_NODES
38 // if (GetNumNodes() >= NUM_MAX_NODES) {
39 // m_buffer[ POS_NUM_NODES ]++;
40 // return -1;
41 // }
42 
43 // m_buffer[ POS_NODES_1 + m_buffer[ POS_NUM_NODES ] ] = node_id;
44 // m_buffer[ POS_NUM_NODES ]++;
45 // return 0;
46 // }
47 
48 // int RawHeader_v1::GetNodeInfo(int node_no, int* node_id)
49 // {
50 // CheckGetBuffer();
51 // if (node_no >= GetNumNodes()) {
52 // return -1;
53 // }
54 // *node_id = m_buffer[ POS_NODES_1 + node_no ];
55 
56 // return 0;
57 // }
58 
59 
60 
61 
63 {
64 
65  // # of words
66  if (buf[ POS_NWORDS ] > 2.5e7 ||
67  buf[ POS_NWORDS ] < RAWHEADER_NWORDS) {
68  char err_buf[500];
69  sprintf(err_buf, "data size error %d words. Exiting... : %s %s %d\n",
70  buf[ POS_NWORDS ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
71  printf("%s", err_buf); fflush(stdout);
72  B2FATAL(err_buf);
73  }
74 
75  // # of words in this block
76  if ((buf[ POS_VERSION_HDRNWORDS ] & HDR_NWORDS_MASK) != RAWHEADER_NWORDS) {
77  char err_buf[500];
78  sprintf(err_buf, "Invalid header size %d words should be %d. Exiting... : %s %s %d\n",
79  buf[ buf[ POS_VERSION_HDRNWORDS ] & HDR_NWORDS_MASK ],
80  RAWHEADER_NWORDS, __FILE__, __PRETTY_FUNCTION__, __LINE__);
81  printf("%s", err_buf); fflush(stdout);
82  B2FATAL(err_buf);
83  }
84 
85  // exp. run #
86 
87  // utime( 2010 1/1 - 2050 1/1 )
88  if ((unsigned int)(buf[ POS_TTUTIME ]) < (unsigned int)0x4b3cbc70 ||
89  (unsigned int)0x9679f770 < (unsigned int)(buf[ POS_TTUTIME ])) {
90  char err_buf[500];
91  sprintf(err_buf, "Invalid utime %d . Exiting...: %s %s %d\n",
92  buf[ POS_TTUTIME ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
93  printf("%s", err_buf); fflush(stdout);
94  B2FATAL(err_buf);
95  }
96 
97  // truncation mask
98 
99  // offset
100  if (buf[ POS_OFFSET_1ST_FINESSE ] < RAWHEADER_NWORDS) {
101  char err_buf[500];
102  sprintf(err_buf, "Invalid data offset for 1st finesse buffer(%d). Exiting...: %s %s %d\n",
103  buf[ POS_OFFSET_1ST_FINESSE ], __FILE__, __PRETTY_FUNCTION__, __LINE__); fflush(stdout);
104  printf("%s", err_buf); fflush(stdout);
105  B2FATAL(err_buf);
106  }
107 
108  if (buf[ POS_OFFSET_2ND_FINESSE ] < buf[ POS_OFFSET_1ST_FINESSE ]) {
109  char err_buf[500];
110  sprintf(err_buf, "Invalid data offset for 2nd finesse buffer(%d). Exiting...: %s %s %d\n",
111  buf[ POS_OFFSET_2ND_FINESSE ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
112  printf("%s", err_buf); fflush(stdout);
113  B2FATAL(err_buf);
114  }
115 
116  if (buf[ POS_OFFSET_3RD_FINESSE ] < buf[ POS_OFFSET_2ND_FINESSE ]) {
117  char err_buf[500];
118  sprintf(err_buf, "Invalid data offset for 3rd finesse buffer(%d). Exiting...: %s %s %d\n",
119  buf[ POS_OFFSET_3RD_FINESSE ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
120  printf("%s", err_buf); fflush(stdout);
121  B2FATAL(err_buf);
122  }
123 
124  if (buf[ POS_OFFSET_4TH_FINESSE ] < buf[ POS_OFFSET_3RD_FINESSE ] ||
125  buf[ POS_OFFSET_4TH_FINESSE ] > buf[ POS_NWORDS ]) {
126  char err_buf[500];
127  sprintf(err_buf, "Invalid data offset for 4th finesse buffer(%d). Exiting...: %s %s %d\n",
128  buf[ POS_OFFSET_4TH_FINESSE ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
129  printf("%s", err_buf); fflush(stdout);
130  B2FATAL(err_buf);
131  }
132 
133  return;
134 
135 
136 }
int * m_buffer
do not record buffer ( RawCOPPER includes buffer of RawHeader_v1 and RawTrailer )
Definition: RawHeader_v1.h:219
void CheckHeader(int *buf)
Get magic word to check the data corruption.
Definition: RawHeader_v1.cc:62
RawHeader_v1()
Default constructor.
Definition: RawHeader_v1.cc:17
~RawHeader_v1()
Destructor.
Definition: RawHeader_v1.cc:29
Abstract base class for different kinds of events.