14#include <rawdata/switch_basf2_standalone.h>
162 FORMAT_VERSION__MASK = 0x0000FF00,
163 FORMAT_VERSION_SHIFT = 8
167 EXP_MASK = 0xFFC00000,
169 RUNNO_MASK = 0x003FFF00,
171 SUBRUNNO_MASK = 0x000000FF
175 RAWHEADER_NWORDS = 20
184 POS_TTCTIME_TRGTYPE = 4,
187 POS_TRUNC_MASK_DATATYPE = 7,
188 POS_OFFSET_1ST_FINESSE = 8,
189 POS_OFFSET_2ND_FINESSE = 9,
190 POS_OFFSET_3RD_FINESSE = 10,
191 POS_OFFSET_4TH_FINESSE = 11,
210 MAGIC_WORD_TERM_HEADER = 0x7fff0005
215 TTCTIME_MASK = 0x7FFFFFF0,
233 B2FATAL(
"m_buffer is NULL. Exiting...");
240 B2FATAL(
"m_buffer is NULL. Data is corrupted or header info has not yet filled. Exiting...");
241 }
else if (
m_buffer[ POS_TERM_HEADER ] != MAGIC_WORD_TERM_HEADER) {
242 B2FATAL(
"magic word is invalid(0x" << std::hex <<
m_buffer[ POS_TERM_HEADER ] <<
"," <<
m_buffer <<
" pos " << std::dec <<
244 <<
"). Data is corrupted or header info has not yet filled. Exiting...");
256 memset(
m_buffer, 0,
sizeof(
int)*RAWHEADER_NWORDS);
257 m_buffer[ POS_HDR_NWORDS ] = RAWHEADER_NWORDS;
264 m_buffer[ POS_TERM_HEADER ] = MAGIC_WORD_TERM_HEADER;
289 m_buffer[ POS_TRUNC_MASK_DATATYPE ] =
290 (data_type & 0x7FFFFFFF) | (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x80000000);
297 m_buffer[ POS_TRUNC_MASK_DATATYPE ] = (trunc_mask << 31) | (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x7FFFFFFF);
310 m_buffer[ POS_OFFSET_1ST_FINESSE ] = offset_1st_FINESSE;
316 m_buffer[ POS_OFFSET_2ND_FINESSE ] = offset_2nd_FINESSE;
322 m_buffer[ POS_OFFSET_3RD_FINESSE ] = offset_3rd_FINESSE;
328 m_buffer[ POS_OFFSET_4TH_FINESSE ] = offset_4th_FINESSE;
342 m_buffer[ POS_TTCTIME_TRGTYPE ] = word1;
351 memcpy(&(
m_buffer[ POS_EXP_RUN_NO ]), (
char*)exprun_buf,
sizeof(
int) * 1);
377 return (((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]) & EXP_MASK)
385 return (((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]) & RUNNO_MASK)
392 return (
m_buffer[ POS_EXP_RUN_NO ] & SUBRUNNO_MASK);
398 return ((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]));
411 return (
unsigned int)(
m_buffer[ POS_NODE_ID ]);
417 return (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x7FFFFFFF);
423 return (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] >> 23) & 0x1;
429 return (
unsigned int)(
m_buffer[ POS_TRUNC_MASK_DATATYPE ]);
435 m_buffer[ POS_TRUNC_MASK_DATATYPE ] |= (int)error_bit_flag;
442 return m_buffer[ POS_OFFSET_1ST_FINESSE ];
448 return m_buffer[ POS_OFFSET_2ND_FINESSE ];
454 return m_buffer[ POS_OFFSET_3RD_FINESSE ];
460 return m_buffer[ POS_OFFSET_4TH_FINESSE ];
472 return (
unsigned int)(
m_buffer[ POS_TTCTIME_TRGTYPE ]);
491 return (
unsigned int)(
m_buffer[ POS_TTUTIME ]);
497 tv->tv_usec = (int)(((
double)
GetTTCtime()) / 127.216);
int GetNwords()
get contents of header
void SetTruncMask(int trunc_mask)
set contents of header
unsigned int GetEveNo()
get restart #(8bit)
int GetOffset1stFINESSE()
get contents of header
void AddErrorBitFlag(unsigned int error_bit_flag)
Add Detected Error bitflag.
int GetTTCtime()
get contents of header
unsigned int GetMagicWordEntireHeader()
Get magic word to check the data corruption.
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 contents of header
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
int GetNumNodes()
get contents of header
unsigned int GetNodeID()
get contents of header
void SetDataType(int data_type)
set contents of header
void Initialize()
initialize 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
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
void SetMagicWordEntireHeader()
set contents of header
Abstract base class for different kinds of events.