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