9 #include <rawdata/dataobjects/RawFTSWFormat_latest.h>
15 RawFTSWFormat_latest::RawFTSWFormat_latest()
19 RawFTSWFormat_latest::~RawFTSWFormat_latest()
24 unsigned int RawFTSWFormat_latest::GetTTCtimeTRGType(
int n)
26 return (
unsigned int)(m_buffer[ GetBufferPos(n) + POS_TT_CTIME_TRGTYPE ]);
31 int RawFTSWFormat_latest::GetTTCtime(
int n)
33 return (
int)((GetTTCtimeTRGType(n) & TTCTIME_MASK) >> TTCTIME_SHIFT);
36 int RawFTSWFormat_latest::GetTRGType(
int n)
38 return (
int)(GetTTCtimeTRGType(n) & TRGTYPE_MASK);
41 unsigned int RawFTSWFormat_latest::GetTTUtime(
int n)
43 return (
unsigned int)(m_buffer[ GetBufferPos(n) + POS_TT_UTIME ]);
46 void RawFTSWFormat_latest::GetTTTimeVal(
int n,
struct timeval* tv)
48 tv->tv_sec = GetTTUtime(n);
49 tv->tv_usec = (int)(((
double)GetTTCtime(n)) / 127.216);
54 void RawFTSWFormat_latest::GetTTTimeSpec(
int n,
struct timespec* ts)
56 ts->tv_sec = GetTTUtime(n);
57 ts->tv_nsec = (long)(((
double)GetTTCtime(n)) / 0.127216);
62 void RawFTSWFormat_latest::GetPCTimeVal(
int n,
struct timeval* tv)
64 tv->tv_sec = (
unsigned int)(m_buffer[ GetBufferPos(n) + POS_TVSEC_FROM_PC ]);
65 tv->tv_usec = (
unsigned int)(m_buffer[ GetBufferPos(n) + POS_TVUSEC_FROM_PC ]);
70 unsigned long long int RawFTSWFormat_latest::GetTTTimeNs(
int n)
72 return (
unsigned long long int)GetTTUtime(n) * 1e9 + (long)((
double)GetTTCtime(n) / 0.127216);
75 int RawFTSWFormat_latest::GetNwordsHeader(
int n)
77 return m_buffer[ GetBufferPos(n) + POS_HDR_NWORDS ];
81 unsigned int RawFTSWFormat_latest::GetFTSWNodeID(
int n)
83 return (
unsigned int)(m_buffer[ GetBufferPos(n) + POS_NODE_ID ]);
86 unsigned int RawFTSWFormat_latest::GetEveNo(
int n)
88 return m_buffer[ GetBufferPos(n) + POS_EVE_NO_1 ];
91 unsigned int RawFTSWFormat_latest::GetMagicTrailer(
int n)
93 return m_buffer[ GetBufferPos(n) + POS_MAGIC_1 ];
96 int RawFTSWFormat_latest::GetIsHER(
int n)
98 int* buffer = GetBuffer(n);
99 int ret = (buffer[ POS_INJECTION_INFO ] & INJ_HER_LER_MASK) >> INJ_HER_LER_SHIFT;
104 unsigned int RawFTSWFormat_latest::GetTimeSinceLastInjection(
int n)
106 unsigned int* buffer = (
unsigned int*) GetBuffer(n);
107 unsigned int ret = (buffer[ POS_INJECTION_INFO ] & INJ_TIME_MASK) >> INJ_TIME_SHIFT;
111 unsigned int RawFTSWFormat_latest::GetTimeSincePrevTrigger(
int n)
113 unsigned int* buffer = (
unsigned int*) GetBuffer(n);
114 unsigned int ret = buffer[ POS_TIME_SINCE_PREV_TRG ];
118 unsigned int RawFTSWFormat_latest::GetBunchNumber(
int n)
120 unsigned int* buffer = (
unsigned int*) GetBuffer(n);
121 unsigned int ret = (buffer[ POS_BUNCH_NUM ] & INJ_BUNCH_MASK) >> INJ_BUNCH_SHIFT;
125 unsigned int RawFTSWFormat_latest::GetFrameCount(
int n)
127 unsigned int* buffer = (
unsigned int*) GetBuffer(n);
128 unsigned int ret = buffer[ POS_FRAME_COUNT ];
133 void RawFTSWFormat_latest::CheckData(
int n,
134 unsigned int prev_evenum,
unsigned int* cur_evenum,
135 unsigned int prev_exprunsubrun_no,
unsigned int* cur_exprunsubrun_no)
139 *cur_evenum = GetEveNo(n);
140 *cur_exprunsubrun_no = GetExpRunSubrun(n);
143 #ifndef NO_DATA_CHECK
144 if (prev_exprunsubrun_no == *cur_exprunsubrun_no) {
145 if ((
unsigned int)(prev_evenum + 1) != *cur_evenum) {
146 sprintf(err_buf,
"[FATAL] ERROR_EVENT : Event # jump : i %d prev 0x%x cur 0x%x : Exiting...\n %s %s %d\n",
147 n, prev_evenum, *cur_evenum, __FILE__, __PRETTY_FUNCTION__, __LINE__);
148 printf(
"%s", err_buf);
154 if (GetBlockNwords(n) != SIZE_FTSW_PACKET) {
155 sprintf(err_buf,
"[FATAL] ERROR_EVENT : invalid FTSW packet length : block %d nwords %d must be %d : Exiting...\n %s %s %d\n",
156 n, GetBlockNwords(n), SIZE_FTSW_PACKET, __FILE__, __PRETTY_FUNCTION__, __LINE__);
157 printf(
"%s", err_buf);
161 if (GetMagicTrailer(n) != FTSW_MAGIC_TRAILER) {
162 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",
163 n, GetMagicTrailer(n), FTSW_MAGIC_TRAILER, __FILE__, __PRETTY_FUNCTION__, __LINE__);
164 printf(
"%s", err_buf); fflush(stdout);
169 printf(
"[DEBUG] ========== dump a data block : block # %d==========\n", n);
171 for (
int k = 0 ; k < GetBlockNwords(n); k++) {
172 printf(
"0x%.8x ", (GetBuffer(n))[k]);
173 if (k % 10 == 9) printf(
"\n[DEBUG] ");
Abstract base class for different kinds of events.