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 = 12
186 HDR_NWORDS_MASK = 0x000000FF
192 POS_VERSION_HDRNWORDS = 1,
195 POS_TTCTIME_TRGTYPE = 4,
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,
222 TTCTIME_MASK = 0x7FFFFFF0,
230 B2LINK_PACKET_CRC_ERROR = 0x1,
231 B2LINK_EVENT_CRC_ERROR = 0x2
247 B2FATAL(
"m_buffer is NULL. Exiting...");
254 B2FATAL(
"m_buffer is NULL. Data is corrupted or header info has not yet filled. Exiting...");
277 m_buffer[ POS_NODE_ID ] = (int)node_id;
283 m_buffer[ POS_TRUNC_MASK_DATATYPE ] =
284 (data_type & 0x7FFFFFFF) | (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x80000000);
291 m_buffer[ POS_TRUNC_MASK_DATATYPE ] = (trunc_mask << 31) | (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x7FFFFFFF);
304 m_buffer[ POS_OFFSET_1ST_FINESSE ] = offset_1st_FINESSE;
310 m_buffer[ POS_OFFSET_2ND_FINESSE ] = offset_2nd_FINESSE;
316 m_buffer[ POS_OFFSET_3RD_FINESSE ] = offset_3rd_FINESSE;
322 m_buffer[ POS_OFFSET_4TH_FINESSE ] = offset_4th_FINESSE;
336 m_buffer[ POS_TTCTIME_TRGTYPE ] = word1;
345 memcpy(&(
m_buffer[ POS_EXP_RUN_NO ]), (
char*)exprun_buf,
sizeof(
int) * 1);
365 return RAWHEADER_NWORDS;
371 return (((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]) & EXP_MASK)
379 return (((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]) & RUNNO_MASK)
386 return (
m_buffer[ POS_EXP_RUN_NO ] & SUBRUNNO_MASK);
392 return ((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]));
405 return (
unsigned int)
m_buffer[ POS_NODE_ID ];
411 return (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x7FFFFFFF);
417 return (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] >> 23) & 0x1;
423 return (
unsigned int)(
m_buffer[ POS_TRUNC_MASK_DATATYPE ]);
429 m_buffer[ POS_TRUNC_MASK_DATATYPE ] |= (int)error_bit_flag;
437 if ((temp_err_flag & B2LINK_PACKET_CRC_ERROR) == 0) {
447 if ((temp_err_flag & B2LINK_EVENT_CRC_ERROR) == 0) {
456 return m_buffer[ POS_OFFSET_1ST_FINESSE ];
462 return m_buffer[ POS_OFFSET_2ND_FINESSE ];
468 return m_buffer[ POS_OFFSET_3RD_FINESSE ];
474 return m_buffer[ POS_OFFSET_4TH_FINESSE ];
486 return (
unsigned int)(
m_buffer[ POS_TTCTIME_TRGTYPE ]);
504 return (
unsigned int)(
m_buffer[ POS_TTUTIME ]);
510 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 GetOffset1stFINESSE()
get contents of header
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 SetOffset4thFINESSE(int offset_4th_FINESSE)
set 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
void SetOffset2ndFINESSE(int offset_2nd_FINESSE)
set 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 SetOffset1stFINESSE(int offset_1st_FINESSE)
set contents of header
void SetNwords(int nwords)
set contents of header
int GetTruncMask()
get contents of header
int GetOffset4thFINESSE()
get contents of header
unsigned int GetErrorBitFlag()
get contents of header
int GetEventCRCError()
Get Detected Error bitflag.
void SetOffset3rdFINESSE(int offset_3rd_FINESSE)
set contents of header
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
int GetOffset2ndFINESSE()
get contents of header
int GetOffset3rdFINESSE()
get contents of header
Abstract base class for different kinds of events.