Belle II Software development
RawCOPPERFormat_latest Class Referenceabstract

The Raw COPPER class ver.1 ( the latest version since May, 2014 ) This class stores data received by COPPER via belle2linkt Data from all detectors except PXD are stored in this class. More...

#include <RawCOPPERFormat_latest.h>

Inheritance diagram for RawCOPPERFormat_latest:
RawCOPPERFormat RawDataBlockFormat PostRawCOPPERFormat_latest PreRawCOPPERFormat_latest

Public Types

enum  { DATA_FORMAT_VERSION = 4 }
 Format version number. More...
 
enum  {
  SIZE_COPPER_DRIVER_HEADER = 0 ,
  SIZE_COPPER_DRIVER_TRAILER = 0
}
 
enum  { SIZE_COPPER_HEADER = 0 }
 
enum  { SIZE_COPPER_TRAILER = 0 }
 
enum  { ONLINE_REMOVED_DATA = 15 }
 
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

 RawCOPPERFormat_latest ()
 Default constructor.
 
virtual ~RawCOPPERFormat_latest ()
 Constructor using existing pointer to raw data buffer.
 
int Get1stDetectorNwords (int n) OVERRIDE_CPP17 FINAL_CPP17
 get Detector buffer length of slot A
 
int Get2ndDetectorNwords (int n) OVERRIDE_CPP17 FINAL_CPP17
 get Detector buffer length of slot B
 
int Get3rdDetectorNwords (int n) OVERRIDE_CPP17 FINAL_CPP17
 get Detector buffer length of slot C
 
int Get4thDetectorNwords (int n) OVERRIDE_CPP17 FINAL_CPP17
 get Detector buffer length of slot D
 
int * Get1stDetectorBuffer (int n) OVERRIDE_CPP17 FINAL_CPP17
 get Detector buffer of slot A
 
int * Get2ndDetectorBuffer (int n) OVERRIDE_CPP17 FINAL_CPP17
 get Detector Buffer of slot B
 
int * Get3rdDetectorBuffer (int n) OVERRIDE_CPP17 FINAL_CPP17
 get Detector Buffer of slot C
 
int * Get4thDetectorBuffer (int n) OVERRIDE_CPP17 FINAL_CPP17
 get Detector Buffer of slot D
 
int * GetRawTrlBufPtr (int n) OVERRIDE_CPP17
 get buffer pointer of rawcopper trailer
 
int GetExpNo (int n) OVERRIDE_CPP17
 get Experimental # from header
 
unsigned int GetExpRunSubrun (int n) OVERRIDE_CPP17
 get Experimental # from header
 
int GetRunNo (int n) OVERRIDE_CPP17
 Exp# (10bit) run# (14bit) restart # (8bit)
 
int GetSubRunNo (int n) OVERRIDE_CPP17
 get run # (14bit)
 
unsigned int GetEveNo (int n) OVERRIDE_CPP17
 get subrun #(8bit)
 
int GetDataType (int n) OVERRIDE_CPP17
 get contents of header
 
int GetTruncMask (int n) OVERRIDE_CPP17
 get contents of header
 
unsigned int GetErrorBitFlag (int n) OVERRIDE_CPP17
 get contents of header
 
void AddErrorBitFlag (int n, unsigned int error_bit_flag) OVERRIDE_CPP17
 Add Detected Error bitflag.
 
int GetPacketCRCError (int n) OVERRIDE_CPP17
 check CRC packet Error
 
int GetEventCRCError (int n) OVERRIDE_CPP17
 check CRC event Error
 
unsigned int GetNodeID (int n) OVERRIDE_CPP17
 get node-ID from data
 
virtual int GetNumFINESSEBlock (int n) OVERRIDE_CPP17
 get # of FINNESEs which contains data
 
int Get1stFINESSENwords (int n) OVERRIDE_CPP17 FINAL_CPP17
 get data size of FINESSE slot A buffer
 
int Get2ndFINESSENwords (int n) OVERRIDE_CPP17 FINAL_CPP17
 get data size of FINESSE slot B buffer
 
int Get3rdFINESSENwords (int n) OVERRIDE_CPP17 FINAL_CPP17
 get data size of FINESSE slot C buffer
 
int Get4thFINESSENwords (int n) OVERRIDE_CPP17 FINAL_CPP17
 get data size of FINESSE slot D buffer
 
int GetOffset1stFINESSE (int n) OVERRIDE_CPP17 FINAL_CPP17
 get # of offset words for FINESSE slot A buffer position
 
int GetOffset2ndFINESSE (int n) OVERRIDE_CPP17 FINAL_CPP17
 get # of offset words for FINESSE slot B buffer position
 
int GetOffset3rdFINESSE (int n) OVERRIDE_CPP17 FINAL_CPP17
 get # of offset words for FINESSE slot C buffer position
 
int GetOffset4thFINESSE (int n) OVERRIDE_CPP17 FINAL_CPP17
 get # of offset words for FINESSE slot D buffer position
 
unsigned int GetTTCtimeTRGType (int n) OVERRIDE_CPP17
 get b2l block from "FEE b2link header"
 
unsigned int GetTTUtime (int n) OVERRIDE_CPP17
 Check if COPPER Magic words are correct.
 
int GetTTCtime (int n) OVERRIDE_CPP17
 Get ctime.
 
int GetTRGType (int n) OVERRIDE_CPP17
 Get trgtype.
 
void GetTTTimeVal (int n, struct timeval *tv) OVERRIDE_CPP17
 Get timeval.
 
int GetMaxNumOfCh (int n) OVERRIDE_CPP17
 Get the max number of channels in a readout board.
 
int * GetFINESSEBuffer (int n, int finesse_num) OVERRIDE_CPP17
 Get a pointer to a FINESSE buffer.
 
int GetFINESSENwords (int n, int finesse_num) OVERRIDE_CPP17
 Get the size of a finesse buffer.
 
void CompareHeaderValue (int n, const unsigned int(&input_val)[MAX_PCIE40_CH], std::vector< std::vector< unsigned int > > &summary_table) OVERRIDE_CPP17
 Check header value of all channels.
 
virtual int GetDetectorNwords (int n, int finesse_num)=0
 set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
 
virtual int * GetDetectorBuffer (int n, int finesse_num)
 get Detector buffer
 
virtual int * GetRawHdrBufPtr (int n)
 get buffer pointer of rawcopper header(Currently same as GetBufferPos)
 
virtual int * Get1stFINESSEBuffer (int n)
 get FINESSE buffer pointer for slot A
 
virtual int * Get2ndFINESSEBuffer (int n)
 get FINESSE buffer pointer for slot B
 
virtual int * Get3rdFINESSEBuffer (int n)
 get FINESSE buffer pointer for slot C
 
virtual int * Get4thFINESSEBuffer (int n)
 get FINESSE buffer pointer for slot D
 
virtual int GetEventCRC16Value (int n, int finesse_num)
 Get Event CRC16 value.
 
virtual unsigned int GetCOPPERCounter (int n)=0
 get COPPER counter(not event number)
 
virtual int GetOffsetFINESSE (int n, int finesse)
 get # of offset words
 
virtual int * GetExpRunSubrunBuf (int n)=0
 get b2l block from "FEE b2link header"
 
virtual unsigned int GetB2LFEE32bitEventNumber (int n)=0
 get b2l block from "FEE b2link header"
 
virtual unsigned int GetMagicDriverHeader (int n)=0
 get magic word of COPPER driver header
 
virtual unsigned int GetMagicFPGAHeader (int n)=0
 get magic word of COPPER FPGA header
 
virtual unsigned int GetMagicFPGATrailer (int n)=0
 get magic word of COPPER FPGA trailer
 
virtual unsigned int GetMagicDriverTrailer (int n)=0
 get magic word of COPPER driver trailer
 
virtual unsigned int GetTrailerChksum (int n)=0
 Get checksum in RawTrailer.
 
virtual bool CheckCOPPERMagic (int n)=0
 Check if COPPER Magic words are correct.
 
virtual unsigned int FillTopBlockRawHeader (unsigned int m_node_id, unsigned int prev_eve32, unsigned int prev_exprunsubrun_no, unsigned int *cur_exprunsubrun_no)=0
 should be called by DeSerializerCOPPER.cc and fill contents in RawHeader
 
virtual unsigned int GetDriverChkSum (int n)=0
 read COPPER driver's checksum value
 
virtual unsigned int CalcDriverChkSum (int n)=0
 calc COPPER driver's checksum value
 
virtual void CheckData (int n, unsigned int prev_evenum, unsigned int *cur_evenum, unsigned int prev_copper_ctr, unsigned int *cur_copper_ctr, unsigned int prev_exprunsubrun_no, unsigned int *cur_exprunsubrun_no)=0
 check data contents
 
virtual void CheckUtimeCtimeTRGType (int n)=0
 check data contents
 
virtual unsigned int CalcXORChecksum (int *buf, int nwords)
 calc XOR checksum
 
virtual int * PackDetectorBuf (int *packed_buf_nwords, int *detector_buf_1st, int nwords_1st, int *detector_buf_2nd, int nwords_2nd, int *detector_buf_3rd, int nwords_3rd, int *detector_buf_4th, int nwords_4th, RawCOPPERPackerInfo rawcprpacker_info)=0
 Pack data (format ver. = -1 -> Select the latest format version)
 
virtual int * PackDetectorBuf (int *packed_buf_nwords, int *const(&detector_buf_ch)[MAX_PCIE40_CH], int const(&nwords_ch)[MAX_PCIE40_CH], RawCOPPERPackerInfo rawcpr_info)
 Pack data for PCIe40 data-format.
 
virtual void GetNodeName (int n, char *node_name, int bufsize)
 Get hostname of a node from the RawCOPPER header.
 
virtual void GetNodeName (char *node_name, unsigned int node_id, int bufsize)
 Get hostname of a node from an argument.
 
virtual bool CheckOnlineRemovedDataBit (int n, int finesse_num)
 Check if COPPER Magic words are correct.
 
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
 

Public Attributes

RawHeader_latest tmp_header
 header ( not recorded )
 
RawTrailer_latest tmp_trailer
 trailer ( not recorded )
 

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 COPPER class ver.1 ( the latest version since May, 2014 ) This class stores data received by COPPER via belle2linkt Data from all detectors except PXD are stored in this class.

Definition at line 34 of file RawCOPPERFormat_latest.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Format version number.

Definition at line 230 of file RawCOPPERFormat_latest.h.

230 {
231 DATA_FORMAT_VERSION = 4
232 };

◆ anonymous enum

anonymous enum

Definition at line 237 of file RawCOPPERFormat_latest.h.

237 {
238 SIZE_COPPER_DRIVER_HEADER = 0,
239 SIZE_COPPER_DRIVER_TRAILER = 0
240 };

◆ anonymous enum

anonymous enum

Definition at line 243 of file RawCOPPERFormat_latest.h.

243 {
244 SIZE_COPPER_HEADER = 0
245 };

◆ anonymous enum

anonymous enum

Definition at line 248 of file RawCOPPERFormat_latest.h.

248 {
249 SIZE_COPPER_TRAILER = 0
250 };

◆ anonymous enum

anonymous enum

Definition at line 255 of file RawCOPPERFormat_latest.h.

255 {
256 ONLINE_REMOVED_DATA = 15
257 };

◆ 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

◆ RawCOPPERFormat_latest()

Default constructor.

Definition at line 22 of file RawCOPPERFormat_latest.cc.

23{
24}

◆ ~RawCOPPERFormat_latest()

~RawCOPPERFormat_latest ( )
virtual

Constructor using existing pointer to raw data buffer.

Destructor

Definition at line 26 of file RawCOPPERFormat_latest.cc.

27{
28}

Member Function Documentation

◆ CalcDriverChkSum()

virtual unsigned int CalcDriverChkSum ( int  n)
pure virtualinherited

◆ CalcXORChecksum()

unsigned int CalcXORChecksum ( int *  buf,
int  nwords 
)
virtualinherited

calc XOR checksum

Definition at line 24 of file RawCOPPERFormat.cc.

25{
26 unsigned int checksum = 0;
27 for (int i = 0; i < nwords; i++) {
28 checksum = checksum ^ buf[ i ];
29 }
30 return checksum;
31}

◆ CheckCOPPERMagic()

virtual bool CheckCOPPERMagic ( int  n)
pure virtualinherited

◆ CheckData()

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

◆ 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

◆ CheckOnlineRemovedDataBit()

bool CheckOnlineRemovedDataBit ( int  n,
int  finesse_num 
)
virtualinherited

Check if COPPER Magic words are correct.

Reimplemented in PostRawCOPPERFormat_latest, and PreRawCOPPERFormat_latest.

Definition at line 217 of file RawCOPPERFormat.cc.

218{
219 char err_buf[500];
220 sprintf(err_buf,
221 "[FATAL] This function is not supported in the version of RawCOPPER format that you're using. n=%d fin=%d : %s %s %d: Exiting...\n",
222 n, finesse_num, __FILE__, __PRETTY_FUNCTION__, __LINE__);
223 printf("%s\n", err_buf); fflush(stdout);
224 B2FATAL(err_buf);
225 return -1;
226}

◆ 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}

◆ CheckUtimeCtimeTRGType()

virtual void CheckUtimeCtimeTRGType ( int  n)
pure virtualinherited

◆ CompareHeaderValue()

void CompareHeaderValue ( int  n,
const unsigned int(&)  input_val[MAX_PCIE40_CH],
std::vector< std::vector< unsigned int > > &  summary_table 
)
virtual

Check header value of all channels.

Reimplemented from RawCOPPERFormat.

Definition at line 256 of file RawCOPPERFormat_latest.cc.

258{
259
260 //
261 // Format of summary_table
262 // <The 1st channel of a value> <# of channels of the value> <the value>
263 //
264 std::vector<std::vector<unsigned int>> temp;
265 for (int i = 0; i < MAX_PCIE40_CH; i++) {
266 if (GetFINESSENwords(n, i) > 0) {
267
268 int same_flag = 0;
269 for (unsigned j = 0; j < summary_table.size(); ++j) {
270 if (input_val[i] == summary_table.at(j).at(2)) {
271 summary_table.at(j).at(1)++;
272 same_flag = 1;
273 break;
274 }
275 }
276 if (same_flag == 0) {
277 summary_table.push_back({ static_cast<unsigned int>(i), 1, input_val[i] });
278 }
279 }
280 }
281 sort(summary_table.begin(), summary_table.end(), [](const std::vector<unsigned int>& alpha,
282 const std::vector<unsigned int>& beta) {return alpha.at(1) < beta.at(1);});
283 return;
284}
int GetFINESSENwords(int n, int finesse_num) OVERRIDE_CPP17
Get the size of a finesse buffer.

◆ 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

◆ FillTopBlockRawHeader()

virtual unsigned int FillTopBlockRawHeader ( unsigned int  m_node_id,
unsigned int  prev_eve32,
unsigned int  prev_exprunsubrun_no,
unsigned int *  cur_exprunsubrun_no 
)
pure virtualinherited

◆ Get1stDetectorBuffer()

int * Get1stDetectorBuffer ( int  n)
virtual

get Detector buffer of slot A

Implements RawCOPPERFormat.

Definition at line 174 of file RawCOPPERFormat_latest.cc.

175{
176 char err_buf[500];
177 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
178 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
179 printf("[DEBUG] %s\n", err_buf);
180 B2FATAL(err_buf);
181 return NULL;
182}

◆ Get1stDetectorNwords()

int Get1stDetectorNwords ( int  n)
virtual

get Detector buffer length of slot A

Implements RawCOPPERFormat.

Definition at line 92 of file RawCOPPERFormat_latest.cc.

93{
94 char err_buf[500];
95 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
96 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
97 printf("[DEBUG] %s\n", err_buf);
98 B2FATAL(err_buf);
99 return 0;
100}

◆ Get1stFINESSENwords()

int Get1stFINESSENwords ( int  n)
virtual

get data size of FINESSE slot A buffer

Implements RawCOPPERFormat.

Definition at line 133 of file RawCOPPERFormat_latest.cc.

134{
135 char err_buf[500];
136 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
137 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
138 printf("[DEBUG] %s\n", err_buf);
139 B2FATAL(err_buf);
140 return 0;
141}

◆ Get2ndDetectorBuffer()

int * Get2ndDetectorBuffer ( int  n)
virtual

get Detector Buffer of slot B

Implements RawCOPPERFormat.

Definition at line 184 of file RawCOPPERFormat_latest.cc.

185{
186 char err_buf[500];
187 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
188 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
189 printf("[DEBUG] %s\n", err_buf);
190 B2FATAL(err_buf);
191 return NULL;
192}

◆ Get2ndDetectorNwords()

int Get2ndDetectorNwords ( int  n)
virtual

get Detector buffer length of slot B

Implements RawCOPPERFormat.

Definition at line 102 of file RawCOPPERFormat_latest.cc.

103{
104 char err_buf[500];
105 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
106 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
107 printf("[DEBUG] %s\n", err_buf);
108 B2FATAL(err_buf);
109 return 0;
110}

◆ Get2ndFINESSENwords()

int Get2ndFINESSENwords ( int  n)
virtual

get data size of FINESSE slot B buffer

Implements RawCOPPERFormat.

Definition at line 143 of file RawCOPPERFormat_latest.cc.

144{
145 char err_buf[500];
146 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
147 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
148 printf("[DEBUG] %s\n", err_buf);
149 B2FATAL(err_buf);
150 return 0;
151}

◆ Get3rdDetectorBuffer()

int * Get3rdDetectorBuffer ( int  n)
virtual

get Detector Buffer of slot C

Implements RawCOPPERFormat.

Definition at line 194 of file RawCOPPERFormat_latest.cc.

195{
196 char err_buf[500];
197 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
198 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
199 printf("[DEBUG] %s\n", err_buf);
200 B2FATAL(err_buf);
201 return NULL;
202}

◆ Get3rdDetectorNwords()

int Get3rdDetectorNwords ( int  n)
virtual

get Detector buffer length of slot C

Implements RawCOPPERFormat.

Definition at line 112 of file RawCOPPERFormat_latest.cc.

113{
114 char err_buf[500];
115 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
116 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
117 printf("[DEBUG] %s\n", err_buf);
118 B2FATAL(err_buf);
119 return 0;
120}

◆ Get3rdFINESSENwords()

int Get3rdFINESSENwords ( int  n)
virtual

get data size of FINESSE slot C buffer

Implements RawCOPPERFormat.

Definition at line 153 of file RawCOPPERFormat_latest.cc.

154{
155 char err_buf[500];
156 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
157 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
158 printf("[DEBUG] %s\n", err_buf);
159 B2FATAL(err_buf);
160 return 0;
161}

◆ Get4thDetectorBuffer()

int * Get4thDetectorBuffer ( int  n)
virtual

get Detector Buffer of slot D

Implements RawCOPPERFormat.

Definition at line 204 of file RawCOPPERFormat_latest.cc.

205{
206 char err_buf[500];
207 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
208 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
209 printf("[DEBUG] %s\n", err_buf);
210 B2FATAL(err_buf);
211 return NULL;
212}

◆ Get4thDetectorNwords()

int Get4thDetectorNwords ( int  n)
virtual

get Detector buffer length of slot D

Implements RawCOPPERFormat.

Definition at line 122 of file RawCOPPERFormat_latest.cc.

123{
124 char err_buf[500];
125 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
126 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
127 printf("[DEBUG] %s\n", err_buf);
128 B2FATAL(err_buf);
129 return 0;
130}

◆ Get4thFINESSENwords()

int Get4thFINESSENwords ( int  n)
virtual

get data size of FINESSE slot D buffer

Implements RawCOPPERFormat.

Definition at line 163 of file RawCOPPERFormat_latest.cc.

164{
165 char err_buf[500];
166 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
167 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
168 printf("[DEBUG] %s\n", err_buf);
169 B2FATAL(err_buf);
170 return 0;
171}

◆ GetB2LFEE32bitEventNumber()

virtual unsigned int GetB2LFEE32bitEventNumber ( int  n)
pure virtualinherited

◆ 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}

◆ GetCOPPERCounter()

virtual unsigned int GetCOPPERCounter ( int  n)
pure virtualinherited

◆ GetDetectorBuffer()

int * GetDetectorBuffer ( int  n,
int  finesse_num 
)
virtualinherited

get Detector buffer

Reimplemented in PostRawCOPPERFormat_latest, and PreRawCOPPERFormat_latest.

Definition at line 94 of file RawCOPPERFormat.cc.

95{
96 switch (finesse_num) {
97 case 0 :
98 return Get1stDetectorBuffer(n);
99 break;
100 case 1 :
101 return Get2ndDetectorBuffer(n);
102 break;
103 case 2 :
104 return Get3rdDetectorBuffer(n);
105 break;
106 case 3 :
107 return Get4thDetectorBuffer(n);
108 break;
109 default :
110 break;
111 }
112
113 char err_buf[500];
114 sprintf(err_buf, "[FATAL] Specifined FINESSE number( = %d ) is invalid. Exiting...\n%s %s %d\n", finesse_num,
115 __FILE__, __PRETTY_FUNCTION__, __LINE__);
116 printf("%s", err_buf); fflush(stdout);
117 B2FATAL(err_buf);
118}
virtual int * Get4thDetectorBuffer(int n)=0
get Detector Buffer of slot D
virtual int * Get2ndDetectorBuffer(int n)=0
get Detector Buffer of slot B
virtual int * Get3rdDetectorBuffer(int n)=0
get Detector Buffer of slot C
virtual int * Get1stDetectorBuffer(int n)=0
get Detector buffer of slot A

◆ GetDetectorNwords()

virtual int GetDetectorNwords ( int  n,
int  finesse_num 
)
pure virtualinherited

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

get Detector buffer length

Implemented in PostRawCOPPERFormat_latest, PostRawCOPPERFormat_v1, PostRawCOPPERFormat_v2, PreRawCOPPERFormat_latest, PreRawCOPPERFormat_v1, PreRawCOPPERFormat_v2, and RawCOPPERFormat_v0.

◆ GetDriverChkSum()

virtual unsigned int GetDriverChkSum ( int  n)
pure virtualinherited

◆ GetEventCRC16Value()

int GetEventCRC16Value ( int  n,
int  finesse_num 
)
virtualinherited

Get Event CRC16 value.

Reimplemented in PostRawCOPPERFormat_latest, and PostRawCOPPERFormat_v2.

Definition at line 145 of file RawCOPPERFormat.cc.

146{
147 char err_buf[500];
148 sprintf(err_buf,
149 "[FATAL] This function is not supported in the version of RawCOPPER format that you're using. n=%d fin=%d : %s %s %d: Exiting...\n",
150 n, finesse_num, __FILE__, __PRETTY_FUNCTION__, __LINE__);
151 printf("%s\n", err_buf); fflush(stdout);
152 B2FATAL(err_buf);
153 return -1;
154}

◆ GetExpRunSubrunBuf()

virtual int * GetExpRunSubrunBuf ( int  n)
pure virtualinherited

get b2l block from "FEE b2link header"

get b2l block from "FEE b2link header"

Implemented in PostRawCOPPERFormat_latest, PostRawCOPPERFormat_v1, PostRawCOPPERFormat_v2, PreRawCOPPERFormat_latest, PreRawCOPPERFormat_v1, PreRawCOPPERFormat_v2, and RawCOPPERFormat_v0.

◆ GetMagicDriverHeader()

virtual unsigned int GetMagicDriverHeader ( int  n)
pure virtualinherited

◆ GetMagicDriverTrailer()

virtual unsigned int GetMagicDriverTrailer ( int  n)
pure virtualinherited

◆ GetMagicFPGAHeader()

virtual unsigned int GetMagicFPGAHeader ( int  n)
pure virtualinherited

◆ GetMagicFPGATrailer()

virtual unsigned int GetMagicFPGATrailer ( int  n)
pure virtualinherited

◆ GetNodeName() [1/2]

void GetNodeName ( char *  node_name,
unsigned int  node_id,
int  bufsize 
)
virtualinherited

Get hostname of a node from an argument.

Definition at line 200 of file RawCOPPERFormat.cc.

201{
202 if (node_name == NULL || node_id == 0 || bufsize < 20) {
203 char err_buf[500];
204 sprintf(err_buf,
205 "[FATAL] Null pointer or strange node_id(%.8x)in an argument of this function. Exiting... : \n%s %s %d\n",
206 node_id,
207 __FILE__, __PRETTY_FUNCTION__, __LINE__);
208 printf("%s", err_buf); fflush(stdout);
209 B2FATAL(err_buf); // to reduce multiple error messages
210 } else {
211 sprintf(node_name, "cpr%u",
212 (10 * (node_id >> 28) + (node_id >> 24)) * 1000 +
213 (node_id & COPPERID_MASK));
214 }
215}

◆ GetNodeName() [2/2]

void GetNodeName ( int  n,
char *  node_name,
int  bufsize 
)
virtualinherited

Get hostname of a node from the RawCOPPER header.

Definition at line 182 of file RawCOPPERFormat.cc.

183{
184 unsigned int node_id = GetNodeID(n);
185 if (node_name == NULL || node_id == 0 || bufsize < 20) {
186 char err_buf[500];
187 sprintf(err_buf,
188 "[FATAL] Null pointer or strange node_id(%.8x)in an argument of this function. Exiting... : \n%s %s %d\n",
189 node_id,
190 __FILE__, __PRETTY_FUNCTION__, __LINE__);
191 printf("%s", err_buf); fflush(stdout);
192 B2FATAL(err_buf); // to reduce multiple error messages
193 } else {
194 sprintf(node_name, "cpr%u",
195 (10 * (node_id >> 28) + (node_id >> 24)) * 1000 +
196 (node_id & COPPERID_MASK));
197 }
198}
virtual unsigned int GetNodeID(int n)=0
get node-ID from data

◆ 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; }

◆ GetNumFINESSEBlock()

int GetNumFINESSEBlock ( int  n)
virtual

get # of FINNESEs which contains data

Implements RawCOPPERFormat.

Definition at line 30 of file RawCOPPERFormat_latest.cc.

31{
32 int cnt = 0;
33 for (int i = 0; i < 4; i++) {
34 if (GetFINESSENwords(n, i) > 0) {
35 cnt++;
36 }
37 }
38 return cnt;
39}

◆ 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; }

◆ GetOffset1stFINESSE()

int GetOffset1stFINESSE ( int  n)
virtual

get # of offset words for FINESSE slot A buffer position

Implements RawCOPPERFormat.

Definition at line 214 of file RawCOPPERFormat_latest.cc.

215{
216 char err_buf[500];
217 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
218 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
219 printf("[DEBUG] %s\n", err_buf);
220 B2FATAL(err_buf);
221 return 0;
222}

◆ GetOffset2ndFINESSE()

int GetOffset2ndFINESSE ( int  n)
virtual

get # of offset words for FINESSE slot B buffer position

Reimplemented from RawCOPPERFormat.

Definition at line 225 of file RawCOPPERFormat_latest.cc.

226{
227 char err_buf[500];
228 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
229 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
230 printf("[DEBUG] %s\n", err_buf);
231 B2FATAL(err_buf);
232 return 0;
233}

◆ GetOffset3rdFINESSE()

int GetOffset3rdFINESSE ( int  n)
virtual

get # of offset words for FINESSE slot C buffer position

Reimplemented from RawCOPPERFormat.

Definition at line 236 of file RawCOPPERFormat_latest.cc.

237{
238 char err_buf[500];
239 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
240 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
241 printf("[DEBUG] %s\n", err_buf);
242 B2FATAL(err_buf);
243 return 0;
244}

◆ GetOffset4thFINESSE()

int GetOffset4thFINESSE ( int  n)
virtual

get # of offset words for FINESSE slot D buffer position

Reimplemented from RawCOPPERFormat.

Definition at line 246 of file RawCOPPERFormat_latest.cc.

247{
248 char err_buf[500];
249 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
250 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
251 printf("[DEBUG] %s\n", err_buf);
252 B2FATAL(err_buf);
253 return 0;
254}

◆ GetOffsetFINESSE()

int GetOffsetFINESSE ( int  n,
int  finesse 
)
virtualinherited

get # of offset words

Definition at line 36 of file RawCOPPERFormat.cc.

37{
38 switch (finesse_num) {
39 case 0 :
40 return GetOffset1stFINESSE(n);
41 break;
42 case 1 :
43 return GetOffset2ndFINESSE(n);
44 break;
45 case 2 :
46 return GetOffset3rdFINESSE(n);
47 break;
48 case 3 :
49 return GetOffset4thFINESSE(n);
50 break;
51 default :
52 break;
53 }
54
55 char err_buf[500];
56 sprintf(err_buf, "[FATAL] Specifined FINESSE number( = %d ) is invalid. Exiting...\n%s %s %d\n", finesse_num,
57 __FILE__, __PRETTY_FUNCTION__, __LINE__);
58 printf("%s", err_buf); fflush(stdout);
59 B2FATAL(err_buf);
60}
virtual int GetOffset1stFINESSE(int n)=0
get # of offset words for FINESSE slot A buffer position
virtual int GetOffset2ndFINESSE(int n)
get # of offset words for FINESSE slot B buffer position
virtual int GetOffset4thFINESSE(int n)
get # of offset words for FINESSE slot D buffer position
virtual int GetOffset3rdFINESSE(int n)
get # of offset words for FINESSE slot C buffer position

◆ GetPreAllocFlag()

virtual int GetPreAllocFlag ( )
inlinevirtualinherited

get malloc_flag

Definition at line 58 of file RawDataBlockFormat.h.

58{ return m_use_prealloc_buf; }

◆ GetTrailerChksum()

virtual unsigned int GetTrailerChksum ( int  n)
pure virtualinherited

◆ GetWholeBuffer()

int * GetWholeBuffer ( )
virtualinherited

get pointer to buffer(m_buffer)

Definition at line 119 of file RawDataBlockFormat.cc.

120{
121 return m_buffer;
122}

◆ PackDetectorBuf() [1/2]

int * PackDetectorBuf ( int *  packed_buf_nwords,
int *const(&)  detector_buf_ch[MAX_PCIE40_CH],
int const(&)  nwords_ch[MAX_PCIE40_CH],
RawCOPPERPackerInfo  rawcpr_info 
)
virtualinherited

Pack data for PCIe40 data-format.

Reimplemented in PostRawCOPPERFormat_latest, and PreRawCOPPERFormat_latest.

Definition at line 156 of file RawCOPPERFormat.cc.

160{
161 char err_buf[500];
162 sprintf(err_buf,
163 "[FATAL] This function is not supported in the version of RawCOPPER format that you're using. : %s %s %d: Exiting...\n", __FILE__,
164 __PRETTY_FUNCTION__, __LINE__);
165 printf("%s\n", err_buf); fflush(stdout);
166 B2FATAL(err_buf);
167 return NULL;
168}

◆ PackDetectorBuf() [2/2]

virtual int * PackDetectorBuf ( int *  packed_buf_nwords,
int *  detector_buf_1st,
int  nwords_1st,
int *  detector_buf_2nd,
int  nwords_2nd,
int *  detector_buf_3rd,
int  nwords_3rd,
int *  detector_buf_4th,
int  nwords_4th,
RawCOPPERPackerInfo  rawcprpacker_info 
)
pure virtualinherited

◆ 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.

◆ tmp_header

RawHeader_latest tmp_header

header ( not recorded )

Definition at line 260 of file RawCOPPERFormat_latest.h.

◆ tmp_trailer

RawTrailer_latest tmp_trailer

trailer ( not recorded )

Definition at line 263 of file RawCOPPERFormat_latest.h.


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