Belle II Software development
RawFTSWFormat Class Referenceabstract

The Raw FTSW class. More...

#include <RawFTSWFormat.h>

Inheritance diagram for RawFTSWFormat:
RawDataBlockFormat RawFTSWFormat_latest RawFTSWFormat_v1 RawFTSWFormat_v2

Public Types

enum  {
  POS_NWORDS = 0 ,
  POS_NODE_ID = 6
}
 
enum  {
  POS_FTSW_ID_OLD = 5 ,
  TEMP_POS_NWORDS_HEADER = 1 ,
  OLD_FTSW_NWORDS_HEADER = 6
}
 

Public Member Functions

 RawFTSWFormat ()
 Default constructor.
 
virtual ~RawFTSWFormat ()
 Constructor using existing pointer to raw data buffer.
 
virtual int GetNwordsHeader (int n)=0
 Get # of words of header.
 
virtual unsigned int GetFTSWNodeID (int n)=0
 Get Node # ( should be "TTD " )
 
virtual unsigned int GetEveNo (int n)=0
 Get event #.
 
virtual unsigned int GetTTCtimeTRGType (int n)=0
 Get a word containing ctime and trigger type info.
 
virtual unsigned int GetTTUtime (int n)=0
 get unixtime of the trigger
 
virtual int GetTTCtime (int n)=0
 Get ctime of the trigger.
 
virtual int GetTRGType (int n)=0
 Get trgtype.
 
virtual void GetTTTimeVal (int n, struct timeval *tv)=0
 Get timeval from ctime and utime.
 
virtual void GetTTTimeSpec (int n, struct timespec *ts)=0
 Get timespec from ctime and utime.
 
virtual unsigned long long int GetTTTimeNs (int n)=0
 Get time in ns since epoch from ctime and utime.
 
virtual unsigned int GetMagicTrailer (int n)=0
 Get magic number for data corruption check.
 
virtual void GetPCTimeVal (int n, struct timeval *tv)
 Get stored information of getimeofday in a PC.
 
virtual void CheckData (int n, unsigned int prev_evenum, unsigned int *cur_evenum, unsigned int prev_exprunsubrun_no, unsigned int *cur_exprunsubrun_no)=0
 check the data contents
 
virtual unsigned int GetExpRunSubrun (int n)=0
 Exp# (10bit) run# (14bit) restart # (8bit)
 
virtual int GetRunNo (int n)=0
 Get run #.
 
virtual int GetSubRunNo (int n)=0
 Get subrun #.
 
virtual int GetRunNoSubRunNo (int n)=0
 get a word cotaining run # and subrun #
 
virtual int GetExpNo (int n)=0
 Get Exp #.
 
virtual int Get15bitTLUTag (int n)
 DESY test only (ver.1)
 
virtual int GetIsHER (int n)
 HER injection = 1 or LER injection = 0.
 
virtual unsigned int GetTimeSinceLastInjection (int n)
 Get time since the last injection.
 
virtual unsigned int GetTimeSincePrevTrigger (int n)
 Get time since the previous trigger.
 
virtual unsigned int GetBunchNumber (int n)
 Get a bunch number.
 
virtual unsigned int GetFrameCount (int n)
 Get a frame count.
 
virtual void SetBuffer (int *bufin, int nwords, int delete_flag, int num_events, int num_nodes)
 set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
 
virtual int TotalBufNwords ()
 Get total length of m_buffer.
 
virtual int GetBufferPos (int n)
 get position of data block in word
 
virtual int * GetBuffer (int n)
 get nth buffer pointer
 
virtual int * GetWholeBuffer ()
 get pointer to buffer(m_buffer)
 
virtual int GetNumEntries ()
 get # of data blocks = (# of nodes)*(# of events)
 
virtual int GetNumNodes ()
 get # of data sources(e.g. # of COPPER boards) in m_buffer
 
virtual int GetNumEvents ()
 get # of events in m_buffer
 
virtual int GetPreAllocFlag ()
 get malloc_flag
 
virtual int GetBlockNwords (int n)
 get size of a data block
 
virtual int CheckFTSWID (int n)
 get FTSW ID to check whether this data block is FTSW data or not
 
virtual int CheckTLUID (int n)
 get FTSW ID to check whether this data block is FTSW data or not
 
virtual void CopyBlock (int n, int *buf_to)
 Copy one datablock to buffer.
 
virtual void PrintData (int *buf, int nwords)
 print data
 

Protected Attributes

int m_nwords
 number of words of buffer
 
int m_num_nodes
 number of nodes in this object
 
int m_num_events
 number of events in this object
 
int * m_buffer
 Buffer.
 
int m_use_prealloc_buf
 not recorded
 

Detailed Description

The Raw FTSW class.

This class stores the RAW data containing FTSW data(event #, trg time ).

Definition at line 24 of file RawFTSWFormat.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

Definition at line 75 of file RawDataBlockFormat.h.

75 {
76 POS_NWORDS = 0,
77 POS_NODE_ID = 6
78 };

◆ anonymous enum

anonymous enum
inherited

Definition at line 80 of file RawDataBlockFormat.h.

80 {
81 // Tentatively needed to distinguish new and old FTSW format, which will be changed in Nov. 2013
82 POS_FTSW_ID_OLD = 5,
83 TEMP_POS_NWORDS_HEADER = 1,
84 OLD_FTSW_NWORDS_HEADER = 6
85 };

Constructor & Destructor Documentation

◆ RawFTSWFormat()

Default constructor.

Definition at line 15 of file RawFTSWFormat.cc.

16{
17}

◆ ~RawFTSWFormat()

~RawFTSWFormat ( )
virtual

Constructor using existing pointer to raw data buffer.

Destructor

Definition at line 19 of file RawFTSWFormat.cc.

20{
21}

Member Function Documentation

◆ CheckData()

virtual void CheckData ( int  n,
unsigned int  prev_evenum,
unsigned int *  cur_evenum,
unsigned int  prev_exprunsubrun_no,
unsigned int *  cur_exprunsubrun_no 
)
pure virtual

check the data contents

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ CheckFTSWID()

int CheckFTSWID ( int  n)
virtualinherited

get FTSW ID to check whether this data block is FTSW data or not

Definition at line 73 of file RawDataBlockFormat.cc.

74{
75 int pos = POS_NODE_ID;
76 if (m_buffer[ GetBufferPos(n) + TEMP_POS_NWORDS_HEADER ] == OLD_FTSW_NWORDS_HEADER) {
77 pos = POS_FTSW_ID_OLD;
78 }
79
80 if ((m_buffer[ GetBufferPos(n) + pos ] & 0xffffff00) == 0x54544400) { // "TTD" + format version ( 0x20=DESY, 0x31=2018/7/11)
81 return 1;
82 } else {
83 return 0;
84 }
85}
virtual int GetBufferPos(int n)
get position of data block in word

◆ CheckTLUID()

int CheckTLUID ( int  n)
virtualinherited

get FTSW ID to check whether this data block is FTSW data or not

Definition at line 88 of file RawDataBlockFormat.cc.

89{
90 int pos = POS_NODE_ID;
91 if (m_buffer[ GetBufferPos(n) + TEMP_POS_NWORDS_HEADER ] == OLD_FTSW_NWORDS_HEADER) {
92 pos = POS_FTSW_ID_OLD;
93 }
94 if (m_buffer[ GetBufferPos(n) + pos ] == 0x544c5520) { // "TLU "
95 return 1;
96 } else {
97 return 0;
98 }
99}

◆ CopyBlock()

void CopyBlock ( int  n,
int *  buf_to 
)
virtualinherited

Copy one datablock to buffer.

Definition at line 173 of file RawDataBlockFormat.cc.

174{
175 memcpy(buf_to, GetBuffer(n), GetBlockNwords(n) * sizeof(int));
176 return;
177}
virtual int GetBlockNwords(int n)
get size of a data block
virtual int * GetBuffer(int n)
get nth buffer pointer

◆ Get15bitTLUTag()

int Get15bitTLUTag ( int  n)
virtual

DESY test only (ver.1)

Reimplemented in RawFTSWFormat_v1.

Definition at line 24 of file RawFTSWFormat.cc.

25{
26 char err_buf[500];
27 sprintf(err_buf,
28 "[FATAL] This function is not supported in the version of RawFTSW format that you're using. n=%d : %s %s %d: Exiting...\n",
29 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
30 printf("%s\n", err_buf); fflush(stdout);
31 B2FATAL(err_buf);
32 return -1;
33}

◆ GetBlockNwords()

int GetBlockNwords ( int  n)
virtualinherited

get size of a data block

Definition at line 107 of file RawDataBlockFormat.cc.

108{
109 int size;
110 if (n == (m_num_events * m_num_nodes) - 1) {
111 size = m_nwords - GetBufferPos(n);
112 } else {
113 size = GetBufferPos(n + 1) - GetBufferPos(n);
114 }
115 return size;
116}
int m_num_events
number of events in this object
int m_num_nodes
number of nodes in this object
int m_nwords
number of words of buffer

◆ GetBuffer()

int * GetBuffer ( int  n)
virtualinherited

get nth buffer pointer

Definition at line 124 of file RawDataBlockFormat.cc.

125{
126 int pos_nwords = GetBufferPos(n);
127 return &(m_buffer[ pos_nwords ]);
128}

◆ GetBufferPos()

int GetBufferPos ( int  n)
virtualinherited

get position of data block in word

Definition at line 30 of file RawDataBlockFormat.cc.

31{
32 if (m_buffer == NULL || m_nwords <= 0) {
33 char err_buf[500];
34 sprintf(err_buf, "[FATAL] RawPacket buffer(%p) is not available or length(%d) is not set.\n %s %s %d\n",
35 m_buffer, m_nwords, __FILE__, __PRETTY_FUNCTION__, __LINE__);
36 printf("%s", err_buf); fflush(stdout);
37 B2FATAL(err_buf);
38 }
39
40 if (n >= (m_num_events * m_num_nodes)) {
41 char err_buf[500];
42 sprintf(err_buf, "[FATAL] Invalid COPPER block No. (%d : max %d ) is specified. Exiting... \n %s %s %d\n",
43 n, (m_num_events * m_num_nodes), __FILE__, __PRETTY_FUNCTION__, __LINE__);
44 printf("%s", err_buf); fflush(stdout);
45 B2FATAL(err_buf);
46 }
47
48 int pos_nwords = 0;
49 for (int i = 1; i <= n ; i++) {
50 if (m_buffer[ pos_nwords ] <= 0) {
51 char err_buf[500];
52 sprintf(err_buf,
53 "[FATAL] ERROR_EVENT : length of this data block is strange ( %d words ). Maybe data is corrupted or RawHeader info has not been filled yet. Exiting...",
54 m_buffer[ pos_nwords ]);
55 printf("%s", err_buf);
56 B2FATAL(err_buf);
57 } else {
58 pos_nwords += m_buffer[ pos_nwords ];
59 }
60 if (pos_nwords >= m_nwords) {
61 char err_buf[500];
62 sprintf(err_buf, "[FATAL] ERROR_EVENT : value of pos_nwords(%d) is larger than m_nwords(%d). Exiting...\n %s %s %d\n",
63 pos_nwords, m_nwords, __FILE__, __PRETTY_FUNCTION__, __LINE__);
64 printf("%s", err_buf); fflush(stdout);
65 B2FATAL(err_buf); // to reduce multiple error messages
66 }
67 }
68 return pos_nwords;
69
70}

◆ GetBunchNumber()

unsigned int GetBunchNumber ( int  n)
virtual

Get a bunch number.

Reimplemented in RawFTSWFormat_latest, and RawFTSWFormat_v2.

Definition at line 72 of file RawFTSWFormat.cc.

73{
74 char err_buf[500];
75 sprintf(err_buf,
76 "[FATAL] This function is not supported in the version of RawFTSW format that you're using. n=%d : %s %s %d: Exiting...\n",
77 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
78 printf("%s\n", err_buf); fflush(stdout);
79 B2FATAL(err_buf);
80 return -1;
81}

◆ GetEveNo()

virtual unsigned int GetEveNo ( int  n)
pure virtual

Get event #.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetExpNo()

virtual int GetExpNo ( int  n)
pure virtual

Get Exp #.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetExpRunSubrun()

virtual unsigned int GetExpRunSubrun ( int  n)
pure virtual

Exp# (10bit) run# (14bit) restart # (8bit)

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetFrameCount()

unsigned int GetFrameCount ( int  n)
virtual

Get a frame count.

Reimplemented in RawFTSWFormat_latest, and RawFTSWFormat_v2.

Definition at line 83 of file RawFTSWFormat.cc.

84{
85 char err_buf[500];
86 sprintf(err_buf,
87 "[FATAL] This function is not supported in the version of RawFTSW format that you're using. n=%d : %s %s %d: Exiting...\n",
88 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
89 printf("%s\n", err_buf); fflush(stdout);
90 B2FATAL(err_buf);
91 return -1;
92}

◆ GetFTSWNodeID()

virtual unsigned int GetFTSWNodeID ( int  n)
pure virtual

Get Node # ( should be "TTD " )

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetIsHER()

int GetIsHER ( int  n)
virtual

HER injection = 1 or LER injection = 0.

Reimplemented in RawFTSWFormat_latest, and RawFTSWFormat_v2.

Definition at line 36 of file RawFTSWFormat.cc.

37{
38 char err_buf[500];
39 sprintf(err_buf,
40 "[FATAL] This function is not supported in the version of RawFTSW format that you're using. n=%d : %s %s %d: Exiting...\n",
41 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
42 printf("%s\n", err_buf); fflush(stdout);
43 B2FATAL(err_buf);
44 return -1;
45}

◆ GetMagicTrailer()

virtual unsigned int GetMagicTrailer ( int  n)
pure virtual

Get magic number for data corruption check.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetNumEntries()

virtual int GetNumEntries ( )
inlinevirtualinherited

get # of data blocks = (# of nodes)*(# of events)

Definition at line 49 of file RawDataBlockFormat.h.

49{ return m_num_events * m_num_nodes; }

◆ GetNumEvents()

virtual int GetNumEvents ( )
inlinevirtualinherited

get # of events in m_buffer

Definition at line 55 of file RawDataBlockFormat.h.

55{ return m_num_events; }

◆ GetNumNodes()

virtual int GetNumNodes ( )
inlinevirtualinherited

get # of data sources(e.g. # of COPPER boards) in m_buffer

Definition at line 52 of file RawDataBlockFormat.h.

52{ return m_num_nodes; }

◆ GetNwordsHeader()

virtual int GetNwordsHeader ( int  n)
pure virtual

Get # of words of header.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetPCTimeVal()

void GetPCTimeVal ( int  n,
struct timeval *  tv 
)
virtual

Get stored information of getimeofday in a PC.

Reimplemented in RawFTSWFormat_latest.

Definition at line 98 of file RawFTSWFormat.cc.

99{
100 // According to Nakao-san's comment at DAQ meeting on Feb.28, 2020. If one calls this function for older data, just returning 0 values is fine.
101 // No need to either end up with FATAL message or issue any WARNING messages (Actually, WARNING messages would be issued in every event when implemented.)
102 tv->tv_sec = 0;
103 tv->tv_usec = 0;
104
105 return;
106}

◆ GetPreAllocFlag()

virtual int GetPreAllocFlag ( )
inlinevirtualinherited

get malloc_flag

Definition at line 58 of file RawDataBlockFormat.h.

58{ return m_use_prealloc_buf; }

◆ GetRunNo()

virtual int GetRunNo ( int  n)
pure virtual

Get run #.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetRunNoSubRunNo()

virtual int GetRunNoSubRunNo ( int  n)
pure virtual

get a word cotaining run # and subrun #

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetSubRunNo()

virtual int GetSubRunNo ( int  n)
pure virtual

Get subrun #.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetTimeSinceLastInjection()

unsigned int GetTimeSinceLastInjection ( int  n)
virtual

Get time since the last injection.

Reimplemented in RawFTSWFormat_latest, and RawFTSWFormat_v2.

Definition at line 49 of file RawFTSWFormat.cc.

50{
51 char err_buf[500];
52 sprintf(err_buf,
53 "[FATAL] This function is not supported in the version of RawFTSW format that you're using. n=%d : %s %s %d: Exiting...\n",
54 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
55 printf("%s\n", err_buf); fflush(stdout);
56 B2FATAL(err_buf);
57 return -1;
58
59}

◆ GetTimeSincePrevTrigger()

unsigned int GetTimeSincePrevTrigger ( int  n)
virtual

Get time since the previous trigger.

Reimplemented in RawFTSWFormat_latest, and RawFTSWFormat_v2.

Definition at line 61 of file RawFTSWFormat.cc.

62{
63 char err_buf[500];
64 sprintf(err_buf,
65 "[FATAL] This function is not supported in the version of RawFTSW format that you're using. n=%d : %s %s %d: Exiting...\n",
66 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
67 printf("%s\n", err_buf); fflush(stdout);
68 B2FATAL(err_buf);
69 return -1;
70}

◆ GetTRGType()

virtual int GetTRGType ( int  n)
pure virtual

Get trgtype.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetTTCtime()

virtual int GetTTCtime ( int  n)
pure virtual

Get ctime of the trigger.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetTTCtimeTRGType()

virtual unsigned int GetTTCtimeTRGType ( int  n)
pure virtual

Get a word containing ctime and trigger type info.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetTTTimeNs()

virtual unsigned long long int GetTTTimeNs ( int  n)
pure virtual

Get time in ns since epoch from ctime and utime.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetTTTimeSpec()

virtual void GetTTTimeSpec ( int  n,
struct timespec *  ts 
)
pure virtual

Get timespec from ctime and utime.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetTTTimeVal()

virtual void GetTTTimeVal ( int  n,
struct timeval *  tv 
)
pure virtual

Get timeval from ctime and utime.

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetTTUtime()

virtual unsigned int GetTTUtime ( int  n)
pure virtual

get unixtime of the trigger

Implemented in RawFTSWFormat_latest, RawFTSWFormat_v1, and RawFTSWFormat_v2.

◆ GetWholeBuffer()

int * GetWholeBuffer ( )
virtualinherited

get pointer to buffer(m_buffer)

Definition at line 119 of file RawDataBlockFormat.cc.

120{
121 return m_buffer;
122}

◆ PrintData()

void PrintData ( int *  buf,
int  nwords 
)
virtualinherited

print data

Definition at line 161 of file RawDataBlockFormat.cc.

162{
163 printf("[DEBUG] ");
164 for (int i = 0; i < nwords; i++) {
165 printf("%.8x ", buf[ i ]);
166 if (i % 10 == 9) printf("\n[DEBUG] ");
167 }
168 printf("\n[DEBUG] ");
169 printf("\n");
170 return;
171}

◆ SetBuffer()

void SetBuffer ( int *  bufin,
int  nwords,
int  delete_flag,
int  num_events,
int  num_nodes 
)
virtualinherited

set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )

Definition at line 131 of file RawDataBlockFormat.cc.

132{
133
134 if (bufin == NULL) {
135 char err_buf[500];
136 sprintf(err_buf, "[DEBUG] bufin is NULL. Exting...\n");
137 printf("%s", err_buf); fflush(stdout);
138 B2FATAL(err_buf);
139 }
140
141 if (!m_use_prealloc_buf && m_buffer != NULL) delete[] m_buffer;
142
143 if (delete_flag == 0) {
144 m_use_prealloc_buf = true;
145 } else {
146 m_use_prealloc_buf = false;
147 }
148
149 m_nwords = nwords;
150 m_buffer = bufin;
151
152 m_num_nodes = num_nodes;
153 m_num_events = num_events;
154
155 return;
156
157}

◆ TotalBufNwords()

int TotalBufNwords ( )
virtualinherited

Get total length of m_buffer.

Definition at line 101 of file RawDataBlockFormat.cc.

102{
103 return m_nwords;
104}

Member Data Documentation

◆ m_buffer

int* m_buffer
protectedinherited

Buffer.

Definition at line 98 of file RawDataBlockFormat.h.

◆ m_num_events

int m_num_events
protectedinherited

number of events in this object

Definition at line 95 of file RawDataBlockFormat.h.

◆ m_num_nodes

int m_num_nodes
protectedinherited

number of nodes in this object

Definition at line 92 of file RawDataBlockFormat.h.

◆ m_nwords

int m_nwords
protectedinherited

number of words of buffer

Definition at line 89 of file RawDataBlockFormat.h.

◆ m_use_prealloc_buf

int m_use_prealloc_buf
protectedinherited

not recorded

flag for deleting m_buffer in destructer( 0:delete, 1: not delete) When using pre-allocated buffer, the buffer should be reused and not deleted in the destructer

Definition at line 102 of file RawDataBlockFormat.h.


The documentation for this class was generated from the following files: