9 #include <rawdata/dataobjects/RawFTSWFormat_v1.h>
15 RawFTSWFormat_v1::RawFTSWFormat_v1()
19 RawFTSWFormat_v1::~RawFTSWFormat_v1()
24 int RawFTSWFormat_v1::Get15bitTLUTag(
int n)
26 return (
int)((
unsigned int)(m_buffer[ GetBufferPos(n) + POS_FTSW_4 ]) & 0x00007FFF);
29 unsigned int RawFTSWFormat_v1::GetTTCtimeTRGType(
int n)
31 return (
unsigned int)(m_buffer[ GetBufferPos(n) + POS_TT_CTIME_TRGTYPE ]);
36 int RawFTSWFormat_v1::GetTTCtime(
int n)
38 return (
int)((GetTTCtimeTRGType(n) & TTCTIME_MASK) >> TTCTIME_SHIFT);
41 int RawFTSWFormat_v1::GetTRGType(
int n)
43 return (
int)(GetTTCtimeTRGType(n) & TRGTYPE_MASK);
46 unsigned int RawFTSWFormat_v1::GetTTUtime(
int n)
48 return (
unsigned int)(m_buffer[ GetBufferPos(n) + POS_TT_UTIME ]);
51 void RawFTSWFormat_v1::GetTTTimeVal(
int n,
struct timeval* tv)
53 tv->tv_sec = GetTTUtime(n);
54 tv->tv_usec = (int)(((
double)GetTTCtime(n)) / 127.216);
59 void RawFTSWFormat_v1::GetTTTimeSpec(
int n,
struct timespec* ts)
61 ts->tv_sec = GetTTUtime(n);
62 ts->tv_nsec = (long)(((
double)GetTTCtime(n)) / 0.127216);
67 unsigned long long int RawFTSWFormat_v1::GetTTTimeNs(
int n)
69 return (
unsigned long long int)GetTTUtime(n) * 1e9 + (long)((
double)GetTTCtime(n) / 0.127216);
72 int RawFTSWFormat_v1::GetNwordsHeader(
int n)
74 return m_buffer[ GetBufferPos(n) + POS_HDR_NWORDS ];
78 unsigned int RawFTSWFormat_v1::GetFTSWNodeID(
int n)
80 return (
unsigned int)(m_buffer[ GetBufferPos(n) + POS_NODE_ID ]);
83 unsigned int RawFTSWFormat_v1::GetEveNo(
int n)
85 return m_buffer[ GetBufferPos(n) + POS_EVE_NO ];
88 unsigned int RawFTSWFormat_v1::GetMagicTrailer(
int n)
90 return m_buffer[ GetBufferPos(n) + POS_MAGIC_1 ];
93 void RawFTSWFormat_v1::CheckData(
int n,
94 unsigned int prev_evenum,
unsigned int* cur_evenum,
95 unsigned int prev_exprunsubrun_no,
unsigned int* cur_exprunsubrun_no)
99 *cur_evenum = GetEveNo(n);
100 *cur_exprunsubrun_no = GetExpRunSubrun(n);
103 #ifndef NO_DATA_CHECK
104 if (prev_exprunsubrun_no == *cur_exprunsubrun_no) {
105 if ((
unsigned int)(prev_evenum + 1) != *cur_evenum) {
106 sprintf(err_buf,
"[FATAL] ERROR_EVENT : Event # jump : i %d prev 0x%x cur 0x%x : Exiting...\n %s %s %d\n",
107 n, prev_evenum, *cur_evenum, __FILE__, __PRETTY_FUNCTION__, __LINE__);
108 printf(
"%s", err_buf);
114 if (GetBlockNwords(n) != SIZE_FTSW_PACKET) {
115 sprintf(err_buf,
"[FATAL] ERROR_EVENT : invalid FTSW packet length : block %d nwords %d must be %d : Exiting...\n %s %s %d\n",
116 n, GetBlockNwords(n), SIZE_FTSW_PACKET, __FILE__, __PRETTY_FUNCTION__, __LINE__);
117 printf(
"%s", err_buf);
121 if (GetMagicTrailer(n) != FTSW_MAGIC_TRAILER) {
122 sprintf(err_buf,
"[FATAL] ERROR_EVENT : invalid magic word : block %d magic word 0x%x must be 0x%x : Exiting...\n %s %s %d\n",
123 n, GetMagicTrailer(n), FTSW_MAGIC_TRAILER, __FILE__, __PRETTY_FUNCTION__, __LINE__);
124 printf(
"%s", err_buf);
129 printf(
"[DEBUG] ========== dump a data block : block # %d==========\n", n);
131 for (
int k = 0 ; k < GetBlockNwords(n); k++) {
132 printf(
"0x%.8x ", (GetBuffer(n))[k]);
133 if (k % 10 == 9) printf(
"\n[DEBUG] ");
Abstract base class for different kinds of events.