Belle II Software development
RawHeader_latest Class Reference

The Raw Header class ver.1 ( the latest version since May, 2014 ) This class defines the format of the header of RawCOPPER class data and used for extracting header info from RawCOPPER object. More...

#include <RawHeader_latest.h>

Public Types

enum  {
  MAGIC_WORD = 0x7F7F0000 ,
  MAGIC_MASK = 0xFFFF0000 ,
  MAGIC_SHIFT = 16 ,
  FORMAT_VERSION__MASK = 0x0000FF00 ,
  FORMAT_VERSION_SHIFT = 8
}
 
enum  {
  EXP_MASK = 0xFFC00000 ,
  EXP_SHIFT = 22 ,
  RUNNO_MASK = 0x003FFF00 ,
  RUNNO_SHIFT = 8 ,
  SUBRUNNO_MASK = 0x000000FF
}
 
enum  { RAWHEADER_NWORDS = 56 }
 
enum  { HDR_NWORDS_MASK = 0x000000FF }
 
enum  {
  POS_NWORDS = 0 ,
  POS_VERSION_HDRNWORDS = 1 ,
  POS_EXP_RUN_NO = 2 ,
  POS_EVE_NO = 3 ,
  POS_TTCTIME_TRGTYPE = 4 ,
  POS_TTUTIME = 5 ,
  POS_NODE_ID = 6 ,
  POS_TRUNC_MASK_DATATYPE = 7 ,
  POS_CH_POS_TABLE = 8
}
 
enum  {
  TTCTIME_MASK = 0x7FFFFFF0 ,
  TTCTIME_SHIFT = 4 ,
  TRGTYPE_MASK = 0xF
}
 
enum  {
  B2LINK_PACKET_CRC_ERROR = 0x1 ,
  B2LINK_EVENT_CRC_ERROR = 0x2
}
 

Public Member Functions

 RawHeader_latest ()
 Default constructor.
 
 RawHeader_latest (int *)
 Constructor using existing pointer to raw data buffer.
 
 ~RawHeader_latest ()
 Destructor.
 
int * GetBuffer ()
 Get header contents.
 
void SetBuffer (int *bufin)
 set buffer
 
void CheckSetBuffer ()
 initialize header
 
void CheckGetBuffer ()
 check if m_buffer exists
 
void SetNwords (int nwords)
 set contents of header
 
void SetEveNo (unsigned int eve_no)
 set contents of header
 
void SetNodeID (unsigned int node_id)
 set contents of header
 
void SetDataType (int data_type)
 set contents of header
 
void SetTruncMask (int trunc_mask)
 set contents of header
 
void SetFTSW2Words (unsigned int word1, unsigned int word2)
 Set values of FTSW info( trigger timing)
 
void SetExpRunNumber (int *exprun_buf)
 Set a word consists of exp #, run # and subrun #.
 
void SetOffset1stFINESSE (int offset_1st_FINESSE)
 set contents of header
 
void SetOffset2ndFINESSE (int offset_2nd_FINESSE)
 set contents of header
 
void SetOffset3rdFINESSE (int offset_3rd_FINESSE)
 set contents of header
 
void SetOffset4thFINESSE (int offset_4th_FINESSE)
 set contents of header
 
int GetNwords ()
 set contents of header
 
int GetHdrNwords ()
 get contents of header
 
unsigned int GetExpRunSubrun ()
 get contents of header
 
int GetExpNo ()
 get a run/exp number combined word
 
int GetRunNo ()
 get contents of header
 
int GetSubRunNo ()
 get run # (14bit)
 
unsigned int GetEveNo ()
 get restart #(8bit)
 
unsigned int GetNodeID ()
 get contents of header
 
int GetDataType ()
 get contents of header
 
int GetTruncMask ()
 get contents of header
 
unsigned int GetErrorBitFlag ()
 get contents of header
 
void AddErrorBitFlag (unsigned int error_bit_flag)
 Add Detected Error bitflag.
 
int GetPacketCRCError ()
 Get Packet CRC error flag.
 
int GetEventCRCError ()
 Get Detected Error bitflag.
 
int GetOffset1stFINESSE ()
 get contents of header
 
int GetOffset2ndFINESSE ()
 get contents of header
 
int GetOffset3rdFINESSE ()
 get contents of header
 
int GetOffset4thFINESSE ()
 get contents of header
 
unsigned int GetTTCtimeTRGType ()
 get contents of header
 
int GetTTCtime ()
 get contents of header
 
int GetTRGType ()
 get TRGType
 
unsigned int GetTTUtime ()
 get contents of header
 
void GetTTTimeVal (struct timeval *tv)
 get contents of header
 
void CheckHeader (int *buf)
 Get magic word to check the data corruption.
 

Private Attributes

int * m_buffer
 do not record buffer ( RawCOPPER includes buffer of RawHeader_latest and RawTrailer )
 

Detailed Description

The Raw Header class ver.1 ( the latest version since May, 2014 ) This class defines the format of the header of RawCOPPER class data and used for extracting header info from RawCOPPER object.

Definition at line 32 of file RawHeader_latest.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 165 of file RawHeader_latest.h.

165 {
166 MAGIC_WORD = 0x7F7F0000,
167 MAGIC_MASK = 0xFFFF0000,
168 MAGIC_SHIFT = 16,
169 FORMAT_VERSION__MASK = 0x0000FF00,
170 FORMAT_VERSION_SHIFT = 8
171 };

◆ anonymous enum

anonymous enum

Definition at line 173 of file RawHeader_latest.h.

173 {
174 EXP_MASK = 0xFFC00000,
175 EXP_SHIFT = 22,
176 RUNNO_MASK = 0x003FFF00,
177 RUNNO_SHIFT = 8,
178 SUBRUNNO_MASK = 0x000000FF
179 };

◆ anonymous enum

anonymous enum

Definition at line 181 of file RawHeader_latest.h.

181 {
182 RAWHEADER_NWORDS = 56
183 };

◆ anonymous enum

anonymous enum

Definition at line 185 of file RawHeader_latest.h.

185 {
186 HDR_NWORDS_MASK = 0x000000FF
187 };

◆ anonymous enum

anonymous enum

Definition at line 190 of file RawHeader_latest.h.

190 {
191 POS_NWORDS = 0,
192 POS_VERSION_HDRNWORDS = 1,
193 POS_EXP_RUN_NO = 2,
194 POS_EVE_NO = 3,
195 POS_TTCTIME_TRGTYPE = 4,
196 POS_TTUTIME = 5,
197 POS_NODE_ID = 6,
198 POS_TRUNC_MASK_DATATYPE = 7,
199 POS_CH_POS_TABLE = 8
200 };

◆ anonymous enum

anonymous enum

Definition at line 218 of file RawHeader_latest.h.

218 {
219 TTCTIME_MASK = 0x7FFFFFF0,
220 TTCTIME_SHIFT = 4,
221 TRGTYPE_MASK = 0xF
222 };

◆ anonymous enum

anonymous enum

Definition at line 226 of file RawHeader_latest.h.

226 {
227 B2LINK_PACKET_CRC_ERROR = 0x1,
228 B2LINK_EVENT_CRC_ERROR = 0x2
229 };

Constructor & Destructor Documentation

◆ RawHeader_latest() [1/2]

Default constructor.

Definition at line 16 of file RawHeader_latest.cc.

17{
18 m_buffer = NULL;
19 // initialize();
20 // cout << "RawHeader_latest NULL constructor" << endl;
21}
int * m_buffer
do not record buffer ( RawCOPPER includes buffer of RawHeader_latest and RawTrailer )

◆ RawHeader_latest() [2/2]

RawHeader_latest ( int *  buffer)
explicit

Constructor using existing pointer to raw data buffer.

Definition at line 23 of file RawHeader_latest.cc.

24{
25 m_buffer = buffer;
26}

◆ ~RawHeader_latest()

Destructor.

Definition at line 28 of file RawHeader_latest.cc.

29{
30}

Member Function Documentation

◆ CheckHeader()

void CheckHeader ( int *  buf)

Get magic word to check the data corruption.

check the contents of header

Definition at line 58 of file RawHeader_latest.cc.

59{
60
61 // # of words
62 if (buf[ POS_NWORDS ] > 2.5e7 || buf[ POS_NWORDS ] < RAWHEADER_NWORDS) {
63 char err_buf[500];
64 sprintf(err_buf, "data size error %d words. Exiting... : %s %s %d\n",
65 buf[ POS_NWORDS ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
66 printf("%s", err_buf); fflush(stdout);
67 B2FATAL(err_buf);
68 }
69
70 // # of words in this block
71 if ((buf[ POS_VERSION_HDRNWORDS ] & HDR_NWORDS_MASK) != RAWHEADER_NWORDS) {
72 char err_buf[500];
73 sprintf(err_buf, "Invalid header size %d words should be %d. Exiting... : %s %s %d\n",
74 buf[ buf[ POS_VERSION_HDRNWORDS ] & HDR_NWORDS_MASK ],
75 RAWHEADER_NWORDS, __FILE__, __PRETTY_FUNCTION__, __LINE__);
76 printf("%s", err_buf); fflush(stdout);
77 B2FATAL(err_buf);
78 }
79
80 // exp. run #
81
82 // utime( 2010 1/1 - 2050 1/1 )
83 if ((unsigned int)(buf[ POS_TTUTIME ]) < (unsigned int)0x4b3cbc70 ||
84 (unsigned int)0x9679f770 < (unsigned int)(buf[ POS_TTUTIME ])) {
85 char err_buf[500];
86 sprintf(err_buf, "Invalid utime %d . Exiting...: %s %s %d\n",
87 buf[ POS_TTUTIME ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
88 printf("%s", err_buf); fflush(stdout);
89 B2FATAL(err_buf);
90 }
91
92 // truncation mask
93
94 int ch = 0;
95 // offset
96 if (buf[ POS_CH_POS_TABLE + ch ] < RAWHEADER_NWORDS) {
97 char err_buf[500];
98 sprintf(err_buf, "Invalid data offset for ch(=%d) finesse buffer(%d). Exiting...: %s %s %d\n",
99 ch, buf[ POS_CH_POS_TABLE + ch ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
100 printf("%s", err_buf); fflush(stdout);
101 B2FATAL(err_buf);
102 }
103
104 for (int i = 1; i < (MAX_PCIE40_CH - 1); i++) {
105 ch = i;
106 if (buf[ POS_CH_POS_TABLE + ch ] < buf[ POS_CH_POS_TABLE + (ch - 1) ]) {
107 char err_buf[500];
108 sprintf(err_buf, "Invalid data offset for ch(=%d) finesse buffer(%d). Exiting...: %s %s %d\n",
109 ch, buf[ POS_CH_POS_TABLE + ch ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
110 printf("%s", err_buf); fflush(stdout);
111 B2FATAL(err_buf);
112 }
113 }
114 ch = MAX_PCIE40_CH - 1;
115
116 if (buf[ POS_CH_POS_TABLE + ch ] < buf[ POS_CH_POS_TABLE + (ch - 1) ] ||
117 buf[ POS_CH_POS_TABLE + ch ] > buf[ POS_NWORDS ]) {
118 char err_buf[500];
119 sprintf(err_buf, "Invalid data offset for ch(=%d) finesse buffer(%d). Exiting...: %s %s %d\n",
120 ch, buf[ POS_CH_POS_TABLE + ch ], __FILE__, __PRETTY_FUNCTION__, __LINE__);
121 printf("%s", err_buf); fflush(stdout);
122 B2FATAL(err_buf);
123 }
124 return;
125}

◆ GetBuffer()

int * GetBuffer ( )
inline

Get header contents.

Definition at line 44 of file RawHeader_latest.h.

44{ return m_buffer; }

◆ GetOffset1stFINESSE()

int GetOffset1stFINESSE ( )

get contents of header

Definition at line 163 of file RawHeader_latest.cc.

164{
165 char err_buf[500];
166 sprintf(err_buf, "[FATAL] This function is not supported. Exiting...: \n%s %s %d\n",
167 __FILE__, __PRETTY_FUNCTION__, __LINE__);
168 printf("[DEBUG] %s\n", err_buf);
169 B2FATAL(err_buf);
170 return 0;
171}

◆ GetOffset2ndFINESSE()

int GetOffset2ndFINESSE ( )

get contents of header

Definition at line 173 of file RawHeader_latest.cc.

174{
175 char err_buf[500];
176 sprintf(err_buf, "[FATAL] This function is not supported. Exiting...: \n%s %s %d\n",
177 __FILE__, __PRETTY_FUNCTION__, __LINE__);
178 printf("[DEBUG] %s\n", err_buf);
179 B2FATAL(err_buf);
180 return 0;
181}

◆ GetOffset3rdFINESSE()

int GetOffset3rdFINESSE ( )

get contents of header

Definition at line 183 of file RawHeader_latest.cc.

184{
185 char err_buf[500];
186 sprintf(err_buf, "[FATAL] This function is not supported. Exiting...: \n%s %s %d\n",
187 __FILE__, __PRETTY_FUNCTION__, __LINE__);
188 printf("[DEBUG] %s\n", err_buf);
189 B2FATAL(err_buf);
190 return 0;
191}

◆ GetOffset4thFINESSE()

int GetOffset4thFINESSE ( )

get contents of header

Definition at line 193 of file RawHeader_latest.cc.

194{
195 char err_buf[500];
196 sprintf(err_buf, "[FATAL] This function is not supported. Exiting...: \n%s %s %d\n",
197 __FILE__, __PRETTY_FUNCTION__, __LINE__);
198 printf("[DEBUG] %s\n", err_buf);
199 B2FATAL(err_buf);
200 return 0;
201}

◆ SetBuffer()

void SetBuffer ( int *  bufin)
inline

set buffer

Definition at line 47 of file RawHeader_latest.h.

47{ m_buffer = bufin; }

◆ SetOffset1stFINESSE()

void SetOffset1stFINESSE ( int  offset_1st_FINESSE)

set contents of header

Definition at line 127 of file RawHeader_latest.cc.

128{
129 char err_buf[500];
130 sprintf(err_buf, "[FATAL] This function is not supported. Exiting...: \n%s %s %d\n",
131 __FILE__, __PRETTY_FUNCTION__, __LINE__);
132 printf("[DEBUG] %s\n", err_buf);
133 B2FATAL(err_buf);
134}

◆ SetOffset2ndFINESSE()

void SetOffset2ndFINESSE ( int  offset_2nd_FINESSE)

set contents of header

Definition at line 136 of file RawHeader_latest.cc.

137{
138 char err_buf[500];
139 sprintf(err_buf, "[FATAL] This function is not supported. Exiting...: \n%s %s %d\n",
140 __FILE__, __PRETTY_FUNCTION__, __LINE__);
141 printf("[DEBUG] %s\n", err_buf);
142 B2FATAL(err_buf);
143}

◆ SetOffset3rdFINESSE()

void SetOffset3rdFINESSE ( int  offset_3rd_FINESSE)

set contents of header

Definition at line 145 of file RawHeader_latest.cc.

146{
147 char err_buf[500];
148 sprintf(err_buf, "[FATAL] This function is not supported. Exiting...: \n%s %s %d\n",
149 __FILE__, __PRETTY_FUNCTION__, __LINE__);
150 printf("[DEBUG] %s\n", err_buf);
151 B2FATAL(err_buf);
152}

◆ SetOffset4thFINESSE()

void SetOffset4thFINESSE ( int  offset_4th_FINESSE)

set contents of header

Definition at line 154 of file RawHeader_latest.cc.

155{
156 char err_buf[500];
157 sprintf(err_buf, "[FATAL] This function is not supported. Exiting...: \n%s %s %d\n",
158 __FILE__, __PRETTY_FUNCTION__, __LINE__);
159 printf("[DEBUG] %s\n", err_buf);
160 B2FATAL(err_buf);
161}

Member Data Documentation

◆ m_buffer

int* m_buffer
private

do not record buffer ( RawCOPPER includes buffer of RawHeader_latest and RawTrailer )

Definition at line 233 of file RawHeader_latest.h.


The documentation for this class was generated from the following files: