Belle II Software development
RawHeader_v2 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_v2.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 = 12 }
 
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_OFFSET_1ST_FINESSE = 8 ,
  POS_OFFSET_2ND_FINESSE = 9 ,
  POS_OFFSET_3RD_FINESSE = 10 ,
  POS_OFFSET_4TH_FINESSE = 11
}
 
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_v2 ()
 Default constructor.
 
 RawHeader_v2 (int *)
 Constructor using existing pointer to raw data buffer.
 
 ~RawHeader_v2 ()
 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_v2 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_v2.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 165 of file RawHeader_v2.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_v2.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_v2.h.

181 {
182 RAWHEADER_NWORDS = 12
183 };

◆ anonymous enum

anonymous enum

Definition at line 185 of file RawHeader_v2.h.

185 {
186 HDR_NWORDS_MASK = 0x000000FF
187 };

◆ anonymous enum

anonymous enum

Definition at line 190 of file RawHeader_v2.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_OFFSET_1ST_FINESSE = 8,
200 POS_OFFSET_2ND_FINESSE = 9,
201 POS_OFFSET_3RD_FINESSE = 10,
202 POS_OFFSET_4TH_FINESSE = 11,
203 };

◆ anonymous enum

anonymous enum

Definition at line 221 of file RawHeader_v2.h.

221 {
222 TTCTIME_MASK = 0x7FFFFFF0,
223 TTCTIME_SHIFT = 4,
224 TRGTYPE_MASK = 0xF
225 };

◆ anonymous enum

anonymous enum

Definition at line 229 of file RawHeader_v2.h.

229 {
230 B2LINK_PACKET_CRC_ERROR = 0x1,
231 B2LINK_EVENT_CRC_ERROR = 0x2
232 };

Constructor & Destructor Documentation

◆ RawHeader_v2() [1/2]

Default constructor.

Definition at line 16 of file RawHeader_v2.cc.

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

◆ RawHeader_v2() [2/2]

RawHeader_v2 ( int *  buffer)
explicit

Constructor using existing pointer to raw data buffer.

Definition at line 23 of file RawHeader_v2.cc.

24{
25 m_buffer = buffer;
26}

◆ ~RawHeader_v2()

Destructor.

Definition at line 28 of file RawHeader_v2.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 61 of file RawHeader_v2.cc.

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}

◆ GetBuffer()

int * GetBuffer ( )
inline

Get header contents.

Definition at line 44 of file RawHeader_v2.h.

44{ return m_buffer; }

◆ SetBuffer()

void SetBuffer ( int *  bufin)
inline

set buffer

Definition at line 47 of file RawHeader_v2.h.

47{ m_buffer = bufin; }

Member Data Documentation

◆ m_buffer

int* m_buffer
private

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

Definition at line 236 of file RawHeader_v2.h.


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