9#ifndef RAWHEADER_LATEST_H
10#define RAWHEADER_LATEST_H
14#include <rawdata/switch_basf2_standalone.h>
166 MAGIC_WORD = 0x7F7F0000,
167 MAGIC_MASK = 0xFFFF0000,
169 FORMAT_VERSION__MASK = 0x0000FF00,
170 FORMAT_VERSION_SHIFT = 8
174 EXP_MASK = 0xFFC00000,
176 RUNNO_MASK = 0x003FFF00,
178 SUBRUNNO_MASK = 0x000000FF
182 RAWHEADER_NWORDS = 56
186 HDR_NWORDS_MASK = 0x000000FF
192 POS_VERSION_HDRNWORDS = 1,
195 POS_TTCTIME_TRGTYPE = 4,
198 POS_TRUNC_MASK_DATATYPE = 7,
219 TTCTIME_MASK = 0x7FFFFFF0,
227 B2LINK_PACKET_CRC_ERROR = 0x1,
228 B2LINK_EVENT_CRC_ERROR = 0x2
244 B2FATAL(
"m_buffer is NULL. Exiting...");
251 B2FATAL(
"m_buffer is NULL. Data is corrupted or header info has not yet filled. Exiting...");
274 m_buffer[ POS_NODE_ID ] = (int)node_id;
280 m_buffer[ POS_TRUNC_MASK_DATATYPE ] =
281 (data_type & 0x7FFFFFFF) | (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x80000000);
288 m_buffer[ POS_TRUNC_MASK_DATATYPE ] = (trunc_mask << 31) | (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x7FFFFFFF);
295 m_buffer[ POS_TTCTIME_TRGTYPE ] = word1;
304 memcpy(&(
m_buffer[ POS_EXP_RUN_NO ]), (
char*)exprun_buf,
sizeof(
int) * 1);
324 return RAWHEADER_NWORDS;
330 return (((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]) & EXP_MASK)
338 return (((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]) & RUNNO_MASK)
345 return (
m_buffer[ POS_EXP_RUN_NO ] & SUBRUNNO_MASK);
351 return ((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]));
364 return (
unsigned int)
m_buffer[ POS_NODE_ID ];
370 return (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x7FFFFFFF);
376 return (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] >> 23) & 0x1;
382 return (
unsigned int)(
m_buffer[ POS_TRUNC_MASK_DATATYPE ]);
388 m_buffer[ POS_TRUNC_MASK_DATATYPE ] |= (int)error_bit_flag;
396 if ((temp_err_flag & B2LINK_PACKET_CRC_ERROR) == 0) {
406 if ((temp_err_flag & B2LINK_EVENT_CRC_ERROR) == 0) {
422 return (
unsigned int)(
m_buffer[ POS_TTCTIME_TRGTYPE ]);
440 return (
unsigned int)(
m_buffer[ POS_TTUTIME ]);
446 tv->tv_usec = (int)(((
double)
GetTTCtime()) / 127.216);
int GetNwords()
set contents of header
void SetTruncMask(int trunc_mask)
set contents of header
unsigned int GetEveNo()
get restart #(8bit)
int GetPacketCRCError()
Get Packet CRC error flag.
void AddErrorBitFlag(unsigned int error_bit_flag)
Add Detected Error bitflag.
int GetTTCtime()
get contents of header
void GetTTTimeVal(struct timeval *tv)
get contents of header
void SetFTSW2Words(unsigned int word1, unsigned int word2)
Set values of FTSW info( trigger timing)
int GetSubRunNo()
get run # (14bit)
int GetHdrNwords()
get contents of header
int GetDataType()
get contents of header
void CheckSetBuffer()
initialize header
unsigned int GetTTUtime()
get contents of header
void CheckGetBuffer()
check if m_buffer exists
int GetTRGType()
get TRGType
void SetEveNo(unsigned int eve_no)
set contents of header
unsigned int GetNodeID()
get contents of header
void SetDataType(int data_type)
set contents of header
void SetNodeID(unsigned int node_id)
set contents of header
int GetRunNo()
get contents of header
void SetNwords(int nwords)
set contents of header
int GetTruncMask()
get contents of header
unsigned int GetErrorBitFlag()
get contents of header
int GetEventCRCError()
Get Detected Error bitflag.
unsigned int GetTTCtimeTRGType()
get contents of header
unsigned int GetExpRunSubrun()
get contents of header
void SetExpRunNumber(int *exprun_buf)
Set a word consists of exp #, run # and subrun #.
int GetExpNo()
get a run/exp number combined word
Abstract base class for different kinds of events.