Belle II Software development
RawHeader_v1 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_v1.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
}
 

Public Member Functions

 RawHeader_v1 ()
 Default constructor.
 
 RawHeader_v1 (int *)
 Constructor using existing pointer to raw data buffer.
 
 ~RawHeader_v1 ()
 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 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_v1 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 31 of file RawHeader_v1.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 159 of file RawHeader_v1.h.

159 {
160 MAGIC_WORD = 0x7F7F0000,
161 MAGIC_MASK = 0xFFFF0000,
162 MAGIC_SHIFT = 16,
163 FORMAT_VERSION__MASK = 0x0000FF00,
164 FORMAT_VERSION_SHIFT = 8
165 };

◆ anonymous enum

anonymous enum

Definition at line 167 of file RawHeader_v1.h.

167 {
168 EXP_MASK = 0xFFC00000,
169 EXP_SHIFT = 22,
170 RUNNO_MASK = 0x003FFF00,
171 RUNNO_SHIFT = 8,
172 SUBRUNNO_MASK = 0x000000FF
173 };

◆ anonymous enum

anonymous enum

Definition at line 175 of file RawHeader_v1.h.

175 {
176 RAWHEADER_NWORDS = 12
177 };

◆ anonymous enum

anonymous enum

Definition at line 179 of file RawHeader_v1.h.

179 {
180 HDR_NWORDS_MASK = 0x000000FF
181 };

◆ anonymous enum

anonymous enum

Definition at line 184 of file RawHeader_v1.h.

184 {
185 POS_NWORDS = 0,
186 POS_VERSION_HDRNWORDS = 1,
187 POS_EXP_RUN_NO = 2,
188 POS_EVE_NO = 3,
189 POS_TTCTIME_TRGTYPE = 4,
190 POS_TTUTIME = 5,
191 POS_NODE_ID = 6,
192 POS_TRUNC_MASK_DATATYPE = 7,
193 POS_OFFSET_1ST_FINESSE = 8,
194 POS_OFFSET_2ND_FINESSE = 9,
195 POS_OFFSET_3RD_FINESSE = 10,
196 POS_OFFSET_4TH_FINESSE = 11,
197 };

◆ anonymous enum

anonymous enum

Definition at line 211 of file RawHeader_v1.h.

211 {
212 TTCTIME_MASK = 0x7FFFFFF0,
213 TTCTIME_SHIFT = 4,
214 TRGTYPE_MASK = 0xF
215 };

Constructor & Destructor Documentation

◆ RawHeader_v1() [1/2]

Default constructor.

Definition at line 17 of file RawHeader_v1.cc.

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

◆ RawHeader_v1() [2/2]

RawHeader_v1 ( int *  buffer)
explicit

Constructor using existing pointer to raw data buffer.

Definition at line 24 of file RawHeader_v1.cc.

25{
26 m_buffer = buffer;
27}

◆ ~RawHeader_v1()

Destructor.

Definition at line 29 of file RawHeader_v1.cc.

30{
31}

Member Function Documentation

◆ CheckHeader()

void CheckHeader ( int *  buf)

Get magic word to check the data corruption.

check the contents of header

Definition at line 62 of file RawHeader_v1.cc.

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}

◆ GetBuffer()

int * GetBuffer ( )
inline

Get header contents.

Definition at line 44 of file RawHeader_v1.h.

44{ return m_buffer; }

◆ SetBuffer()

void SetBuffer ( int *  bufin)
inline

set buffer

Definition at line 47 of file RawHeader_v1.h.

47{ m_buffer = bufin; }

Member Data Documentation

◆ m_buffer

int* m_buffer
private

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

Definition at line 219 of file RawHeader_v1.h.


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