Belle II Software  release-08-01-10
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 More...
 
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 More...
 
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. More...
 

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 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 }

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