Belle II Software development
RawCOPPERFormat_v0 Class Reference

The Raw COPPER class ver.0 ( from August, 2013 to April, 2014 ) This class stores data received by COPPER via belle2linkt Data from all detectors except PXD are stored in this class. More...

#include <RawCOPPERFormat_v0.h>

Inheritance diagram for RawCOPPERFormat_v0:
RawCOPPERFormat RawDataBlockFormat

Public Types

enum  { DATA_FORMAT_VERSION = 0 }
 
enum  {
  SIZE_COPPER_DRIVER_HEADER = 7 ,
  SIZE_COPPER_DRIVER_TRAILER = 2
}
 Copper data words = ( total_data_length in COPPER header ) + COPPER_HEADER_TRAILER_NWORDS. More...
 
enum  {
  POS_MAGIC_COPPER_1 = 0 ,
  POS_EVE_NUM_COPPER = 1 ,
  POS_SUBSYSTEM_ID = 2 ,
  POS_CRATE_ID = 3 ,
  POS_SLOT_ID = 4 ,
  POS_MAGIC_COPPER_2 = 7 ,
  POS_DATA_LENGTH = 8 ,
  POS_CH_A_DATA_LENGTH = 9 ,
  POS_CH_B_DATA_LENGTH = 10 ,
  POS_CH_C_DATA_LENGTH = 11 ,
  POS_CH_D_DATA_LENGTH = 12 ,
  SIZE_COPPER_HEADER = 13
}
 
enum  {
  POS_MAGIC_COPPER_3 = 0 ,
  POS_CHKSUM_COPPER = 1 ,
  POS_MAGIC_COPPER_4 = 2 ,
  SIZE_COPPER_TRAILER = 3
}
 
enum  {
  POS_MAGIC_B2LHSLB = 0 ,
  SIZE_B2LHSLB_HEADER = 1
}
 
enum  {
  POS_CHKSUM_B2LHSLB = 0 ,
  SIZE_B2LHSLB_TRAILER = 1
}
 
enum  {
  POS_TT_CTIME_TYPE = 0 ,
  POS_TT_TAG = 1 ,
  POS_TT_UTIME = 2 ,
  POS_EXP_RUN = 3 ,
  POS_B2L_CTIME = 4 ,
  SIZE_B2LFEE_HEADER = 5
}
 
enum  {
  POS_CHKSUM_B2LFEE = 0 ,
  SIZE_B2LFEE_TRAILER = 1
}
 
enum  {
  COPPER_MAGIC_DRIVER_HEADER = 0x7FFF0008 ,
  COPPER_MAGIC_FPGA_HEADER = 0xFFFFFAFA ,
  COPPER_MAGIC_FPGA_TRAILER = 0xFFFFF5F5 ,
  COPPER_MAGIC_DRIVER_TRAILER = 0x7FFF0009
}
 
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_v0 ()
 Default constructor.
 
virtual ~RawCOPPERFormat_v0 ()
 Constructor using existing pointer to raw data buffer.
 
int GetDetectorNwords (int n, int finesse_num) OVERRIDE_CPP17
 get Detector buffer length
 
int Get1stDetectorNwords (int n) OVERRIDE_CPP17
 get Detector buffer length of slot A
 
int Get2ndDetectorNwords (int n) OVERRIDE_CPP17
 get Detector buffer length of slot B
 
int Get3rdDetectorNwords (int n) OVERRIDE_CPP17
 get Detector buffer length of slot C
 
int Get4thDetectorNwords (int n) OVERRIDE_CPP17
 get Detector buffer length of slot D
 
int * Get1stDetectorBuffer (int n) OVERRIDE_CPP17
 get Detector buffer of slot A
 
int * Get2ndDetectorBuffer (int n) OVERRIDE_CPP17
 get Detector Buffer of slot B
 
int * Get3rdDetectorBuffer (int n) OVERRIDE_CPP17
 get Detector Buffer of slot C
 
int * Get4thDetectorBuffer (int n) OVERRIDE_CPP17
 get Detector Buffer of slot D
 
virtual 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.
 
unsigned int GetNodeID (int n) OVERRIDE_CPP17
 get node-ID from data
 
virtual unsigned int GetCOPPERCounter (int n) OVERRIDE_CPP17
 get COPPER counter(not event number)
 
virtual int GetNumFINESSEBlock (int n) OVERRIDE_CPP17
 get # of FINNESEs which contains data
 
int GetOffset1stFINESSE (int n) OVERRIDE_CPP17
 get # of offset words for FINESSE slot A buffer position
 
int GetFINESSENwords (int n, int finesse) OVERRIDE_CPP17
 get data size of FINESSE buffer
 
int Get1stFINESSENwords (int n) OVERRIDE_CPP17
 get data size of FINESSE slot A buffer
 
int Get2ndFINESSENwords (int n) OVERRIDE_CPP17
 get data size of FINESSE slot B buffer
 
int Get3rdFINESSENwords (int n) OVERRIDE_CPP17
 get data size of FINESSE slot C buffer
 
int Get4thFINESSENwords (int n) OVERRIDE_CPP17
 get data size of FINESSE slot D buffer
 
virtual int * GetExpRunSubrunBuf (int n) OVERRIDE_CPP17
 get b2l block from "FEE b2link header"
 
virtual unsigned int GetB2LFEE32bitEventNumber (int n) OVERRIDE_CPP17
 get b2l block from "FEE b2link header"
 
unsigned int GetMagicDriverHeader (int n) OVERRIDE_CPP17
 get magic word of COPPER driver header
 
unsigned int GetMagicFPGAHeader (int n) OVERRIDE_CPP17
 get magic word of COPPER FPGA header
 
unsigned int GetMagicFPGATrailer (int n) OVERRIDE_CPP17
 get magic word of COPPER FPGA trailer
 
unsigned int GetMagicDriverTrailer (int n) OVERRIDE_CPP17
 get magic word of COPPER driver trailer
 
unsigned int GetTrailerChksum (int n) OVERRIDE_CPP17
 Get checksum in RawTrailer.
 
bool CheckCOPPERMagic (int n) OVERRIDE_CPP17
 Check if COPPER Magic words are correct.
 
unsigned int GetTTCtimeTRGType (int n) OVERRIDE_CPP17
 Check if COPPER Magic words are correct.
 
unsigned int GetTTUtime (int n) OVERRIDE_CPP17
 Check if COPPER Magic words are correct.
 
unsigned int FillTopBlockRawHeader (unsigned int m_node_id, unsigned int prev_eve32, unsigned int prev_exprunsubrun_no, unsigned int *cur_exprunsubrun_no) OVERRIDE_CPP17
 should be called by DeSerializerCOPPER.cc and fill contents in RawHeader
 
unsigned int GetDriverChkSum (int n) OVERRIDE_CPP17
 read COPPER driver's checksum value
 
unsigned int CalcDriverChkSum (int n) OVERRIDE_CPP17
 calc COPPER driver's checksum value
 
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) OVERRIDE_CPP17
 check data contents
 
void CheckUtimeCtimeTRGType (int n) OVERRIDE_CPP17
 check data contents
 
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 * 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) OVERRIDE_CPP17
 Pack data (format ver. = -1 -> Select the latest format version)
 
int GetMaxNumOfCh (int n) OVERRIDE_CPP17
 Get the max number of channels in a readout board.
 
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 * GetFINESSEBuffer (int n, int finesse_num)
 get FINESSE buffer pointer
 
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 GetPacketCRCError (int n)
 check CRC packet Error
 
virtual int GetEventCRCError (int n)
 check CRC event Error
 
virtual int GetEventCRC16Value (int n, int finesse_num)
 Get Event CRC16 value.
 
virtual int GetOffsetFINESSE (int n, int finesse)
 get # of offset words
 
virtual int GetOffset2ndFINESSE (int n)
 get # of offset words for FINESSE slot B buffer position
 
virtual int GetOffset3rdFINESSE (int n)
 get # of offset words for FINESSE slot C buffer position
 
virtual int GetOffset4thFINESSE (int n)
 get # of offset words for FINESSE slot D buffer position
 
virtual unsigned int CalcXORChecksum (int *buf, int nwords)
 calc XOR checksum
 
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 CompareHeaderValue (int n, const unsigned int(&input_val)[MAX_PCIE40_CH], std::vector< std::vector< unsigned int > > &result)
 Compare value from different channels and make a statistics table.
 
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_v0 tmp_header
 header ( not recorded )
 
RawTrailer_v0 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.0 ( from August, 2013 to April, 2014 ) This class stores data received by COPPER via belle2linkt Data from all detectors except PXD are stored in this class.

Definition at line 35 of file RawCOPPERFormat_v0.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 274 of file RawCOPPERFormat_v0.h.

274 {
275 DATA_FORMAT_VERSION = 0
276 };

◆ anonymous enum

anonymous enum

Copper data words = ( total_data_length in COPPER header ) + COPPER_HEADER_TRAILER_NWORDS.

Definition at line 282 of file RawCOPPERFormat_v0.h.

282 {
283 SIZE_COPPER_DRIVER_HEADER = 7,
284 SIZE_COPPER_DRIVER_TRAILER = 2
285 };

◆ anonymous enum

anonymous enum

Definition at line 290 of file RawCOPPERFormat_v0.h.

290 {
291 POS_MAGIC_COPPER_1 = 0,
292 POS_EVE_NUM_COPPER = 1,
293 POS_SUBSYSTEM_ID = 2,
294 POS_CRATE_ID = 3,
295 POS_SLOT_ID = 4,
296 POS_MAGIC_COPPER_2 = 7,
297 POS_DATA_LENGTH = 8,
298 POS_CH_A_DATA_LENGTH = 9,
299 POS_CH_B_DATA_LENGTH = 10,
300 POS_CH_C_DATA_LENGTH = 11,
301 POS_CH_D_DATA_LENGTH = 12,
302
303 SIZE_COPPER_HEADER = 13
304 };

◆ anonymous enum

anonymous enum

Definition at line 311 of file RawCOPPERFormat_v0.h.

311 {
312 POS_MAGIC_COPPER_3 = 0,
313 POS_CHKSUM_COPPER = 1,
314 POS_MAGIC_COPPER_4 = 2,
315
316 SIZE_COPPER_TRAILER = 3
317 };

◆ anonymous enum

anonymous enum

Definition at line 322 of file RawCOPPERFormat_v0.h.

322 {
323 POS_MAGIC_B2LHSLB = 0,
324 // POS_EVE_CNT_B2LHSLB = 1,
325 SIZE_B2LHSLB_HEADER = 1
326 };

◆ anonymous enum

anonymous enum

Definition at line 331 of file RawCOPPERFormat_v0.h.

331 {
332 POS_CHKSUM_B2LHSLB = 0,
333 SIZE_B2LHSLB_TRAILER = 1
334 };

◆ anonymous enum

anonymous enum

Definition at line 339 of file RawCOPPERFormat_v0.h.

339 {
340 POS_TT_CTIME_TYPE = 0,
341 POS_TT_TAG = 1,
342 POS_TT_UTIME = 2,
343 POS_EXP_RUN = 3,
344 POS_B2L_CTIME = 4,
345 SIZE_B2LFEE_HEADER = 5
346 };

◆ anonymous enum

anonymous enum

Definition at line 352 of file RawCOPPERFormat_v0.h.

352 {
353 POS_CHKSUM_B2LFEE = 0,
354 SIZE_B2LFEE_TRAILER = 1
355 };

◆ anonymous enum

anonymous enum

Definition at line 360 of file RawCOPPERFormat_v0.h.

360 {
361 COPPER_MAGIC_DRIVER_HEADER = 0x7FFF0008,
362 COPPER_MAGIC_FPGA_HEADER = 0xFFFFFAFA,
363 COPPER_MAGIC_FPGA_TRAILER = 0xFFFFF5F5,
364 COPPER_MAGIC_DRIVER_TRAILER = 0x7FFF0009
365 };

◆ 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_v0()

Default constructor.

Definition at line 21 of file RawCOPPERFormat_v0.cc.

22{
23}

◆ ~RawCOPPERFormat_v0()

~RawCOPPERFormat_v0 ( )
virtual

Constructor using existing pointer to raw data buffer.

Destructor

Definition at line 25 of file RawCOPPERFormat_v0.cc.

26{
27}

Member Function Documentation

◆ CalcDriverChkSum()

unsigned int CalcDriverChkSum ( int  n)
virtual

calc COPPER driver's checksum value

Implements RawCOPPERFormat.

Definition at line 29 of file RawCOPPERFormat_v0.cc.

30{
31 int min = GetBufferPos(n) + tmp_header.RAWHEADER_NWORDS;
32 int max = GetBufferPos(n) + GetBlockNwords(n)
33 - tmp_trailer.RAWTRAILER_NWORDS - SIZE_COPPER_DRIVER_TRAILER;
34 unsigned int chksum = 0;
35 for (int i = min; i < max; i++) {
36 chksum ^= m_buffer[ i ];
37 }
38 return chksum;
39}
RawTrailer_v0 tmp_trailer
trailer ( not recorded )
RawHeader_v0 tmp_header
header ( not recorded )
virtual int GetBlockNwords(int n)
get size of a data block
virtual int GetBufferPos(int n)
get position of data block in word

◆ 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()

bool CheckCOPPERMagic ( int  n)
virtual

Check if COPPER Magic words are correct.

Implements RawCOPPERFormat.

Definition at line 335 of file RawCOPPERFormat_v0.cc.

336{
337 if (GetMagicDriverHeader(n) != COPPER_MAGIC_DRIVER_HEADER) {
338 return false;
339 } else if (GetMagicFPGAHeader(n) != COPPER_MAGIC_FPGA_HEADER) {
340 return false;
341 } else if (GetMagicFPGATrailer(n) != COPPER_MAGIC_FPGA_TRAILER) {
342 return false;
343 } else if (GetMagicDriverTrailer(n) != COPPER_MAGIC_DRIVER_TRAILER) {
344 return false;
345 }
346 return true;
347}
unsigned int GetMagicFPGATrailer(int n) OVERRIDE_CPP17
get magic word of COPPER FPGA trailer
unsigned int GetMagicDriverTrailer(int n) OVERRIDE_CPP17
get magic word of COPPER driver trailer
unsigned int GetMagicFPGAHeader(int n) OVERRIDE_CPP17
get magic word of COPPER FPGA header
unsigned int GetMagicDriverHeader(int n) OVERRIDE_CPP17
get magic word of COPPER driver header

◆ CheckData()

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 
)
virtual

check data contents

Implements RawCOPPERFormat.

Definition at line 172 of file RawCOPPERFormat_v0.cc.

176{
177
178 char err_buf[500];
179 sprintf(err_buf,
180 "This function for format ver.0 is not supported. (n %d preveve %u eve %u prectr %u ctr %u prevrun %u run %u) Exiting...\n %s %s %d\n",
181 n, prev_evenum, *cur_evenum_rawcprhdr, prev_copper_ctr, *cur_copper_ctr,
182 prev_exprunsubrun_no, *cur_exprunsubrun_no,
183 __FILE__, __PRETTY_FUNCTION__, __LINE__);
184 printf("%s", err_buf); fflush(stdout);
185 B2FATAL(err_buf);
186
187// char err_buf[500];
188// int err_flag = 0;
189// //
190// // check Magic words
191// //
192// if (!CheckCOPPERMagic(n)) {
193// sprintf(err_buf, "CORRUPTED DATA: Invalid Magic word 0x7FFFF0008=%u 0xFFFFFAFA=%u 0xFFFFF5F5=%u 0x7FFF0009=%u\n%s %s %d\n",
194// GetMagicDriverHeader(n),
195// GetMagicFPGAHeader(n),
196// GetMagicFPGATrailer(n),
197// GetMagicDriverTrailer(n),
198// __FILE__, __PRETTY_FUNCTION__, __LINE__);
199// err_flag = 1;
200// }
201// //
202// // Event # check
203// //
204// *cur_evenum_rawcprhdr = GetEveNo(n);
205// unsigned int evenum_feehdr = GetB2LFEE32bitEventNumber(n);
206// if (*cur_evenum_rawcprhdr != evenum_feehdr) {
207// sprintf(err_buf,
208// "CORRUPTED DATA: Event # in RawCOPPERFormat_v0 header and FEE header is different : cprhdr 0x%x feehdr 0x%x : Exiting...\n%s %s %d\n",
209// *cur_evenum_rawcprhdr, evenum_feehdr,
210// __FILE__, __PRETTY_FUNCTION__, __LINE__);
211// err_flag = 1;
212// }
213
214// //
215// // Check incrementation of event #
216// //
217// *cur_runsubrun_no = GetRunNoSubRunNo(n);
218// if (
219// #ifdef WO_FIRST_EVENUM_CHECK
220// prev_evenum != 0xFFFFFFFF && *cur_evenum_rawcprhdr != 0
221// #else
222// prev_runsubrun_no == *cur_runsubrun_no && prev_runsubrun_no >= 0
223// #endif
224// ) {
225// if ((unsigned int)(prev_evenum + 1) != *cur_evenum_rawcprhdr) {
226// sprintf(err_buf, "CORRUPTED DATA: Event # jump : i %d prev 0x%x cur 0x%x : Exiting...\n%s %s %d\n",
227// n, prev_evenum, *cur_evenum_rawcprhdr,
228// __FILE__, __PRETTY_FUNCTION__, __LINE__);
229// err_flag = 1;
230// }
231// }
232
233
234// *cur_copper_ctr = GetCOPPERCounter(n);
235// if (
236// #ifdef WO_FIRST_EVENUM_CHECK
237// prev_copper_ctr != 0xFFFFFFFF
238// #else
239// true
240// #endif
241// ) {
242// if ((unsigned int)(prev_copper_ctr + 1) != *cur_copper_ctr) {
243// sprintf(err_buf, "COPPER counter jump : i %d prev 0x%x cur 0x%x :\n%s %s %d\n",
244// n, prev_copper_ctr, *cur_copper_ctr,
245// __FILE__, __PRETTY_FUNCTION__, __LINE__);
246
247// #ifdef DESY
248// //
249// // In DESY test, we ignore this error
250// //
251// printf("[DEBUG] [INFO] %s", err_buf);
252// #else
253// err_flag = 1;
254// #endif
255
256// }
257// }
258
259// //
260// // Check is utime and ctime_trgtype same over different FINESSE data
261// //
262// CheckUtimeCtimeTRGType(n);
263
264
265// //
266// // Check checksum calculated by COPPER driver
267// //
268// if (GetDriverChkSum(n) != CalcDriverChkSum(n)) {
269// sprintf(err_buf,
270// "CORRUPTED DATA: COPPER driver checkSum error : block %d : length %d eve 0x%x : Trailer chksum 0x%.8x : calcd. now 0x%.8x\n%s %s %d\n",
271// n,
272// GetBlockNwords(n),
273// *cur_evenum_rawcprhdr,
274// GetDriverChkSum(n),
275// CalcDriverChkSum(n),
276// __FILE__, __PRETTY_FUNCTION__, __LINE__);
277// err_flag = 1;
278// }
279
280
281// //
282// // Check checksum calculated by DeSerializerCOPPER()
283// //
284
285// tmp_trailer.SetBuffer(GetRawTrlBufPtr(n));
286// unsigned int xor_chksum = CalcXORChecksum(GetBuffer(n), GetBlockNwords(n) - tmp_trailer.GetTrlNwords());
287// if (tmp_trailer.GetChksum() != xor_chksum) {
288// sprintf(err_buf,
289// "CORRUPTED DATA: RawCOPPERFormat_v0 checksum error : block %d : length %d eve 0x%x : Trailer chksum 0x%.8x : calcd. now 0x%.8x\n %s %s %d\n",
290// n, GetBlockNwords(n), *cur_evenum_rawcprhdr, tmp_trailer.GetChksum(), xor_chksum,
291// __FILE__, __PRETTY_FUNCTION__, __LINE__);
292// err_flag = 1;
293// }
294
295
296// #ifdef DEBUG
297// printf("[DEBUG] eve %u %d %d %d %d\n",
298// GetEveNo(n),
299// Get1stDetectorNwords(n),
300// Get2ndDetectorNwords(n),
301// Get3rdDetectorNwords(n),
302// Get4thDetectorNwords(n)
303// );
304// printf("[DEBUG] ===COPPER BLOCK==============\n");
305// printData(GetBuffer(n), GetBlockNwords(n));
306
307// printf("[DEBUG] ===FINNESSE A ==============\n");
308// printData(Get1stDetectorBuffer(n), Get1stDetectorNwords(n));
309
310// printf("[DEBUG] ===FINNESSE B ==============\n");
311// printData(Get2ndDetectorBuffer(n), Get2ndDetectorNwords(n));
312
313// printf("[DEBUG] ===FINNESSE C ==============\n");
314// printData(Get3rdDetectorBuffer(n), Get3rdDetectorNwords(n));
315
316// printf("[DEBUG] ===FINNESSE D ==============\n");
317// printData(Get4thDetectorBuffer(n), Get4thDetectorNwords(n));
318// printf("[DEBUG] === END ==============\n");
319
320// #endif
321
322// if (err_flag == 1) {
323// printf("[DEBUG] ========== dump a data blcok : block # %d==========\n", n);
324// PrintData(GetBuffer(n), GetBlockNwords(n));
325// string err_str = err_buf;
326// throw (err_str);
327// // sleep(1234567);
328// // exit(-1);
329// }
330
331 return;
332
333}

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

◆ 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()

void CheckUtimeCtimeTRGType ( int  n)
virtual

check data contents

Implements RawCOPPERFormat.

Definition at line 349 of file RawCOPPERFormat_v0.cc.

350{
351
352#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
353 CheckB2LFEEHeaderVersion(n);
354#endif
355 int err_flag = 0;
356 int flag = 0;
357 unsigned int temp_utime = 0, temp_ctime_trgtype = 0;
358 unsigned int utime[4], ctime_trgtype[4];
359 memset(utime, 0, sizeof(utime));
360 memset(ctime_trgtype, 0, sizeof(ctime_trgtype));
361
362 for (int i = 0; i < 4; i++) {
363 if (GetFINESSENwords(n, i) > 0) {
364 ctime_trgtype[ i ] = m_buffer[ GetOffsetFINESSE(n, i) +
365 SIZE_B2LHSLB_HEADER + POS_TT_CTIME_TYPE ];
366 utime[ i ] = m_buffer[ GetOffsetFINESSE(n, i) +
367 SIZE_B2LHSLB_HEADER + POS_TT_UTIME ];
368 if (flag == 0) {
369 temp_ctime_trgtype = ctime_trgtype[ i ];
370 temp_utime = utime[ i ];
371 flag = 1;
372 } else {
373 if (temp_ctime_trgtype != ctime_trgtype[ i ]
374 || temp_utime != utime[ i ]) {
375 err_flag = 1;
376 }
377 }
378 }
379 }
380
381 if (err_flag != 0) {
382 for (int i = 0; i < 4; i++) {
383 printf("[DEBUG] FINESSE #=%d buffsize %d ctimeTRGtype 0x%.8x utime 0x%.8x\n",
384 i, GetFINESSENwords(n, i), ctime_trgtype[ i ], utime[ i ]);
385 }
386 char err_buf[500];
387 sprintf(err_buf, "CORRUPTED DATA: mismatch over FINESSEs. Exiting...\n %s %s %d\n",
388 __FILE__, __PRETTY_FUNCTION__, __LINE__);
389 printf("%s", err_buf); fflush(stdout);
390 B2FATAL(err_buf);
391 }
392 return;
393}
int GetFINESSENwords(int n, int finesse) OVERRIDE_CPP17
get data size of FINESSE buffer
virtual int GetOffsetFINESSE(int n, int finesse)
get # of offset words

◆ CompareHeaderValue()

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

Compare value from different channels and make a statistics table.

Reimplemented in RawCOPPERFormat_latest.

Definition at line 170 of file RawCOPPERFormat.cc.

172{
173 char err_buf[500];
174 sprintf(err_buf,
175 "[FATAL] This function is not supported in the version of RawCOPPER format that you're using. : %s %s %d: Exiting...\n", __FILE__,
176 __PRETTY_FUNCTION__, __LINE__);
177 printf("%s\n", err_buf); fflush(stdout);
178 B2FATAL(err_buf);
179 return;
180}

◆ 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 * GetBuffer(int n)
get nth buffer pointer

◆ FillTopBlockRawHeader()

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

should be called by DeSerializerCOPPER.cc and fill contents in RawHeader

Implements RawCOPPERFormat.

Definition at line 396 of file RawCOPPERFormat_v0.cc.

398{
399
400 char err_buf[500];
401 sprintf(err_buf,
402 "This function for format ver.0 is not supported. (node %.8x preveve %u prevrun %u currun %u ) Exiting...\n %s %s %d\n",
403 m_node_id, prev_eve32, prev_exprunsubrun_no, *cur_exprunsubrun_no,
404 __FILE__, __PRETTY_FUNCTION__, __LINE__);
405 printf("%s", err_buf); fflush(stdout);
406 B2FATAL(err_buf);
407 return 0;
408
409// const int cpr_id = 0;
410// // m_temp_value = 12345678;
411// //
412// // This function only fills RawHeader contents for the first datablock.
413// // # of block should be 1
414// if (m_num_nodes * m_num_events != 1) {
415// char err_buf[500];
416// sprintf(err_buf,
417// "This function should be used for RawCOPPERFormat_v0 containing only one datablock, while. this object has num_nodes of %d and num_events of %d\n %s %s %d\n",
418// m_num_nodes, m_num_events, __FILE__, __PRETTY_FUNCTION__, __LINE__);
419// string err_str = err_buf; throw (err_str);
420// }
421
422// //////////////////////////////////////////////////
423// //
424// // Fill info in RawHeader
425// //
426// //////////////////////////////////////////////////
427
428// //
429// // Initialize a RawHeader part
430// //
431// memset(m_buffer, 0, sizeof(int) * tmp_header.RAWHEADER_NWORDS);
432// m_buffer[ tmp_header.POS_HDR_NWORDS ] = tmp_header.RAWHEADER_NWORDS;
433
434// //
435// // Check FINESSEs which containes data
436// //
437// int* copper_buf = &(m_buffer[ tmp_header.RAWHEADER_NWORDS ]);
438// if (copper_buf[ POS_CH_A_DATA_LENGTH ] == 0 &&
439// copper_buf[ POS_CH_B_DATA_LENGTH ] == 0 &&
440// copper_buf[ POS_CH_C_DATA_LENGTH ] == 0 &&
441// copper_buf[ POS_CH_D_DATA_LENGTH ] == 0) {
442// char err_buf[500];
443// sprintf(err_buf,
444// "No FINESSE data in a copper data block. Exiting...\n %s %s %d\n",
445// __FILE__, __PRETTY_FUNCTION__, __LINE__);
446// string err_str = err_buf; throw (err_str);
447// // sleep(12345678);
448// // exit(-1);
449// }
450
451// //
452// // Set total words info
453// //
454// int datablock_nwords =
455// tmp_header.RAWHEADER_NWORDS +
456// (copper_buf[ POS_DATA_LENGTH ]
457// + SIZE_COPPER_DRIVER_HEADER
458// + SIZE_COPPER_DRIVER_TRAILER)
459// + tmp_trailer.RAWTRAILER_NWORDS;
460// m_buffer[ tmp_header.POS_NWORDS ] = datablock_nwords;
461
462// //
463// // Check the consistency between data length and length in RawHeader
464// //
465// if (m_buffer[ tmp_header.POS_NWORDS ] != m_nwords) {
466// char err_buf[500];
467// sprintf(err_buf,
468// "CORRUPTED DATA: Data length is inconsistent m_nwords %d : nwords from COPPER data %d\n %s %s %d\n",
469// m_nwords, m_buffer[ tmp_header.POS_NWORDS ],
470// __FILE__, __PRETTY_FUNCTION__, __LINE__);
471// string err_str = err_buf; throw (err_str);
472// // sleep(12345678);
473// // exit(-1);
474// }
475
476// //
477// // Fill offset values
478// //
479// int offset_1st_finesse = tmp_header.RAWHEADER_NWORDS + SIZE_COPPER_HEADER;
480// int offset_2nd_finesse = offset_1st_finesse + copper_buf[ POS_CH_A_DATA_LENGTH ];
481// int offset_3rd_finesse = offset_2nd_finesse + copper_buf[ POS_CH_B_DATA_LENGTH ];
482// int offset_4th_finesse = offset_3rd_finesse + copper_buf[ POS_CH_C_DATA_LENGTH ];
483// m_buffer[ tmp_header.POS_OFFSET_1ST_FINESSE ] = offset_1st_finesse;
484// m_buffer[ tmp_header.POS_OFFSET_2ND_FINESSE ] = offset_2nd_finesse;
485// m_buffer[ tmp_header.POS_OFFSET_3RD_FINESSE ] = offset_3rd_finesse;
486// m_buffer[ tmp_header.POS_OFFSET_4TH_FINESSE ] = offset_4th_finesse;
487
488// //
489// // Fill Exp/Run value
490// //
491// int* finesse_buf = &
492// (m_buffer[ offset_1st_finesse ]); // In any finesse implementations, the top finesse buffer should be at offset_1st_finesse;
493// m_buffer[ tmp_header.POS_EXP_RUN_NO ] = finesse_buf[ SIZE_B2LHSLB_HEADER + POS_EXP_RUN ];
494
495
496// //
497// // Fill event #
498// //
499// unsigned int cur_ftsw_eve32 = finesse_buf[ SIZE_B2LHSLB_HEADER + POS_TT_TAG ];
500// m_buffer[ tmp_header.POS_EVE_NO ] = cur_ftsw_eve32;
501
502// //
503// // Copy FTSW words from B2LFEE header
504// //
505// m_buffer[ tmp_header.POS_TTCTIME_TRGTYPE ] = finesse_buf[ SIZE_B2LHSLB_HEADER + POS_TT_CTIME_TYPE ];
506// m_buffer[ tmp_header.POS_TTUTIME ] = finesse_buf[ SIZE_B2LHSLB_HEADER + POS_TT_UTIME ];
507
508// //
509// // Set node ID, trunc_mask, data_type
510// //
511// m_buffer[ tmp_header.POS_NODE_ID ] = m_node_id;
512// m_buffer[ tmp_header.POS_TRUNC_MASK_DATATYPE ] = ((m_trunc_mask << 31) & 0x80000000) | (m_data_type & 0x7FFFFFFF);
513
514// //
515// // Set RawHeader magic word
516// //
517// m_buffer[ tmp_header.POS_TERM_HEADER ] = tmp_header.MAGIC_WORD_TERM_HEADER;
518
519
520// //
521// // Add node-info
522// //
523// if (m_buffer[ tmp_header.POS_NUM_NODES ] < tmp_header.NUM_MAX_NODES) {
524// m_buffer[ tmp_header.POS_NODES_1 + m_buffer[ tmp_header.POS_NUM_NODES ] ] = m_node_id;
525// }
526// m_buffer[ tmp_header.POS_NUM_NODES ]++;
527
528
529
530// //////////////////////////////////////////////////
531// //
532// // Fill info in RawTrailer
533// //
534// //////////////////////////////////////////////////
535
536// //
537// // Calculate XOR checksum
538// //
539// unsigned int chksum_top = 0, chksum_body = 0, chksum_bottom = 0;
540
541// int top_end = tmp_header.RAWHEADER_NWORDS;
542// for (int i = 0; i < top_end; i++) {
543// chksum_top ^= m_buffer[ i ];
544// }
545// int body_end = datablock_nwords - SIZE_COPPER_DRIVER_TRAILER - tmp_trailer.RAWTRAILER_NWORDS;
546// for (int i = top_end; i < body_end; i++) {
547// chksum_body ^= m_buffer[ i ];
548// }
549
550// int bottom_end = datablock_nwords - tmp_trailer.RAWTRAILER_NWORDS;
551// for (int i = body_end; i < bottom_end; i++) {
552// chksum_bottom ^= m_buffer[ i ];
553// }
554
555// //
556// // check COPPER driver checksum
557// //
558// if (chksum_body != (unsigned int)(m_buffer[ body_end ])) {
559// char err_buf[500];
560// sprintf(err_buf, "CORRUPTED DATA: COPPER driver checksum is not consistent.: calcd. %.8x data %.8x\n %s %s %d\n",
561// chksum_body, m_buffer[ body_end ],
562// __FILE__, __PRETTY_FUNCTION__, __LINE__);
563// string err_str = err_buf; throw (err_str);
564// // sleep(12345678);
565// // exit(-1);
566// }
567
568// //
569// // Fill trailer info (checksum, magic word)
570// //
571// unsigned int chksum = chksum_top ^ chksum_body ^ chksum_bottom;
572// int* trl = &(m_buffer[ datablock_nwords - tmp_trailer.RAWTRAILER_NWORDS ]);
573// trl[ tmp_trailer.POS_CHKSUM ] = chksum;
574// trl[ tmp_trailer.POS_TERM_WORD ] = tmp_trailer.MAGIC_WORD_TERM_TRAILER;
575
576
577// //////////////////////////////////////////////////
578// //
579// // Data check ( magic word, event incrementation )
580// //
581// //////////////////////////////////////////////////
582
583
584// //
585// // check magic words
586// //
587// int* fpga_trailer_magic = trl - 3;
588// int* driver_trailer_magic = trl - 1;
589// int err_flag = 0;
590// if ((unsigned int)(copper_buf[ POS_MAGIC_COPPER_1 ]) != COPPER_MAGIC_DRIVER_HEADER) {
591// err_flag = 1;
592// } else if ((unsigned int)(copper_buf[ POS_MAGIC_COPPER_2 ]) != COPPER_MAGIC_FPGA_HEADER) {
593// err_flag = 1;
594// } else if ((unsigned int)(*fpga_trailer_magic) != COPPER_MAGIC_FPGA_TRAILER) {
595// err_flag = 1;
596// } else if ((unsigned int)(*driver_trailer_magic) != COPPER_MAGIC_DRIVER_TRAILER) {
597// err_flag = 1;
598// }
599// if (err_flag == 1) {
600// char err_buf[500];
601// sprintf(err_buf, "CORRUPTED DATA: Invalid Magic word 0x7FFFF0008=%u 0xFFFFFAFA=%u 0xFFFFF5F5=%u 0x7FFF0009=%u\n %s %s %d\n",
602// GetMagicDriverHeader(cpr_id),
603// GetMagicFPGAHeader(cpr_id),
604// GetMagicFPGATrailer(cpr_id),
605// GetMagicDriverTrailer(cpr_id),
606// __FILE__, __PRETTY_FUNCTION__, __LINE__);
607// printf("[DEBUG] [ERROR] %s\n", err_buf);
608// #ifndef NO_DATA_CHECK
609// string err_str = err_buf; throw (err_str);
610
611// // sleep(12345678);
612// // exit(-1);
613// #endif
614// }
615
616// //
617// // check incrementation of event #
618// //
619// *cur_runsubrun_no = GetRunNoSubRunNo(cpr_id);
620// if (prev_runsubrun_no == *cur_runsubrun_no && prev_runsubrun_no >= 0) {
621// if (
622// #ifdef WO_FIRST_EVENUM_CHECK
623// (prev_eve32 + 1 != cur_ftsw_eve32) && (prev_eve32 != 0xFFFFFFFF && cur_ftsw_eve32 != 0)
624// #else
625// prev_eve32 + 1 != cur_ftsw_eve32
626// #endif
627// ) {
628
629// #ifndef NO_DATA_CHECK
630// char err_buf[500];
631// sprintf(err_buf, "CORRUPTED DATA: Invalid event_number. Exiting...: cur 32bit eve %u preveve %u prun %d crun %d\n %s %s %d\n",
632// cur_ftsw_eve32, prev_eve32,
633// prev_runsubrun_no, *cur_runsubrun_no,
634// __FILE__, __PRETTY_FUNCTION__, __LINE__);
635// printf("[DEBUG] [ERROR] %s\n", err_buf);
636
637// string err_str = err_buf;
638// printf("[DEBUG] i= %d : num entries %d : Tot words %d\n", 0 , GetNumEntries(), TotalBufNwords());
639// PrintData(GetBuffer(cpr_id), TotalBufNwords());
640// throw (err_str);
641// // exit(-1);
642// #endif
643
644// }
645// }
646
647// return cur_ftsw_eve32;
648
649}

◆ GetB2LFEE32bitEventNumber()

unsigned int GetB2LFEE32bitEventNumber ( int  n)
virtual

get b2l block from "FEE b2link header"

Implements RawCOPPERFormat.

Definition at line 117 of file RawCOPPERFormat_v0.cc.

118{
119
120#ifndef READ_OLD_B2LFEE_FORMAT_FILE
121
122 int err_flag = 0;
123 unsigned int eve_num = 0;
124 int flag = 0;
125 unsigned int eve[4];
126 for (int i = 0; i < 4 ; i++) {
127 eve[ i ] = 12345678;
128 if (GetFINESSENwords(n, i) > 0) {
129 int pos_nwords = GetOffsetFINESSE(n, i) + SIZE_B2LHSLB_HEADER + POS_TT_TAG;
130 eve[ i ] = m_buffer[ pos_nwords ];
131 if (flag != 1) eve_num = eve[ i ];
132 if (eve_num != eve[ i ]) err_flag = 1;
133 flag = 1;
134 }
135 }
136
137 if (flag == 0) {
138 char err_buf[500];
139 sprintf(err_buf, "No HSLB data in COPPER data. Exiting...\n%s %s %d\n",
140 __FILE__, __PRETTY_FUNCTION__, __LINE__);
141 printf("%s\n", err_buf); fflush(stdout);
142 B2FATAL(err_buf);
143 }
144
145 if (err_flag == 1) {
146
147 char err_buf[500];
148 sprintf(err_buf, "CORRUPTED DATA: Different event number over HSLBs : slot A 0x%x : B 0x%x :C 0x%x : D 0x%x\n%s %s %d\n",
149 eve[ 0 ], eve[ 1 ], eve[ 2 ], eve[ 3 ],
150 __FILE__, __PRETTY_FUNCTION__, __LINE__);
151 printf("[DEBUG] [ERROR] %s\n", err_buf);
152#ifndef NO_DATA_CHECK
153 B2FATAL(err_buf);
154#endif //NO_DATA_CHECK
155 }
156 return eve_num;
157
158#else // READ_OLD_B2LFEE_FORMAT_FILE
159
160 char err_buf[500];
161 sprintf(err_buf, "You need comment out READ_OLD_B2LFEE_FORMAT_FILE if you are handling a new data format\n%s %s %d\n",
162 __FILE__, __PRETTY_FUNCTION__, __LINE__);
163 printf("%s", err_buf); fflush(stdout);
164 B2FATAL(err_buf);
165#endif // READ_OLD_B2LFEE_FORMAT_FILE
166
167}

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

◆ 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()

int GetDetectorNwords ( int  n,
int  finesse_num 
)
virtual

get Detector buffer length

Implements RawCOPPERFormat.

Definition at line 57 of file RawCOPPERFormat_v0.cc.

58{
59 switch (finesse_num) {
60 case 0 :
61 return Get1stDetectorNwords(n);
62 break;
63 case 1 :
64 return Get2ndDetectorNwords(n);
65 break;
66 case 2 :
67 return Get3rdDetectorNwords(n);
68 break;
69 case 3 :
70 return Get4thDetectorNwords(n);
71 break;
72 default :
73 break;
74 }
75
76 char err_buf[500];
77 sprintf(err_buf, "Specifined FINESSE number( = %d ) is invalid. Exiting...\n %s %s %d\n", finesse_num,
78 __FILE__, __PRETTY_FUNCTION__, __LINE__);
79 printf("%s\n", err_buf); fflush(stdout);
80 B2FATAL(err_buf);
81}
int Get3rdDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot C
int Get4thDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot D
int Get2ndDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot B
int Get1stDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot A

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

◆ GetEventCRCError()

int GetEventCRCError ( int  n)
virtualinherited

check CRC event Error

Reimplemented in RawCOPPERFormat_latest, and RawCOPPERFormat_v2.

Definition at line 134 of file RawCOPPERFormat.cc.

135{
136 char err_buf[500];
137 sprintf(err_buf,
138 "[FATAL] This function is not supported in the version of RawCOPPER format that you're using. n=%d : %s %s %d: Exiting...\n",
139 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
140 printf("%s\n", err_buf); fflush(stdout);
141 B2FATAL(err_buf);
142 return -1;
143}

◆ GetFINESSEBuffer()

int * GetFINESSEBuffer ( int  n,
int  finesse_num 
)
virtualinherited

get FINESSE buffer pointer

Reimplemented in RawCOPPERFormat_latest.

Definition at line 65 of file RawCOPPERFormat.cc.

66{
67 switch (finesse_num) {
68 case 0 :
69 return Get1stFINESSEBuffer(n);
70 break;
71 case 1 :
72 return Get2ndFINESSEBuffer(n);
73 break;
74 case 2 :
75 return Get3rdFINESSEBuffer(n);
76 break;
77 case 3 :
78 return Get4thFINESSEBuffer(n);
79 break;
80 default :
81 break;
82 }
83
84 char err_buf[500];
85 sprintf(err_buf, "[FATAL] Specifined FINESSE number( = %d ) is invalid. Exiting...\n%s %s %d\n", finesse_num,
86 __FILE__, __PRETTY_FUNCTION__, __LINE__);
87 printf("%s", err_buf); fflush(stdout);
88 B2FATAL(err_buf);
89}
virtual int * Get3rdFINESSEBuffer(int n)
get FINESSE buffer pointer for slot C
virtual int * Get2ndFINESSEBuffer(int n)
get FINESSE buffer pointer for slot B
virtual int * Get4thFINESSEBuffer(int n)
get FINESSE buffer pointer for slot D
virtual int * Get1stFINESSEBuffer(int n)
get FINESSE buffer pointer for slot A

◆ GetFINESSENwords()

int GetFINESSENwords ( int  n,
int  finesse 
)
virtual

get data size of FINESSE buffer

Implements RawCOPPERFormat.

Definition at line 84 of file RawCOPPERFormat_v0.cc.

85{
86 switch (finesse_num) {
87 case 0 :
88 return Get1stFINESSENwords(n);
89 break;
90 case 1 :
91 return Get2ndFINESSENwords(n);
92 break;
93 case 2 :
94 return Get3rdFINESSENwords(n);
95 break;
96 case 3 :
97 return Get4thFINESSENwords(n);
98 break;
99 default :
100 break;
101 }
102
103 char err_buf[500];
104 sprintf(err_buf, "Specifined FINESSE number( = %d ) is invalid. Exiting...\n %s %s %d\n",
105 finesse_num, __FILE__, __PRETTY_FUNCTION__, __LINE__);
106 printf("%s\n", err_buf); fflush(stdout);
107 B2FATAL(err_buf);
108}
int Get3rdFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot C buffer
int Get1stFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot A buffer
int Get4thFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot D buffer
int Get2ndFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot B buffer

◆ 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 42 of file RawCOPPERFormat_v0.cc.

43{
44
45 int cnt = 0;
46 int pos_nwords = GetBufferPos(n) + POS_CH_A_DATA_LENGTH + tmp_header.RAWHEADER_NWORDS;
47 if (m_buffer[ pos_nwords ] > 0) cnt++;
48 pos_nwords = GetBufferPos(n) + POS_CH_B_DATA_LENGTH + tmp_header.RAWHEADER_NWORDS;
49 if (m_buffer[ pos_nwords ] > 0) cnt++;
50 pos_nwords = GetBufferPos(n) + POS_CH_C_DATA_LENGTH + tmp_header.RAWHEADER_NWORDS;
51 if (m_buffer[ pos_nwords ] > 0) cnt++;
52 pos_nwords = GetBufferPos(n) + POS_CH_D_DATA_LENGTH + tmp_header.RAWHEADER_NWORDS;
53 if (m_buffer[ pos_nwords ] > 0) cnt++;
54 return cnt;
55}

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

◆ 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

◆ GetPacketCRCError()

int GetPacketCRCError ( int  n)
virtualinherited

check CRC packet Error

Reimplemented in RawCOPPERFormat_latest, and RawCOPPERFormat_v2.

Definition at line 122 of file RawCOPPERFormat.cc.

123{
124 char err_buf[500];
125 sprintf(err_buf,
126 "[FATAL] This function is not supported in the version of RawCOPPER format that you're using. n=%d : %s %s %d: Exiting...\n",
127 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
128 printf("%s\n", err_buf); fflush(stdout);
129 B2FATAL(err_buf);
130 return -1;
131}

◆ GetPreAllocFlag()

virtual int GetPreAllocFlag ( )
inlinevirtualinherited

get malloc_flag

Definition at line 58 of file RawDataBlockFormat.h.

58{ return m_use_prealloc_buf; }

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

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 
)
virtual

Pack data (format ver. = -1 -> Select the latest format version)

Implements RawCOPPERFormat.

Definition at line 703 of file RawCOPPERFormat_v0.cc.

709{
710 char err_buf[500];
711 sprintf(err_buf, "This function is not supported (%p %p %d %p %d %p %d %p %d %p ) Exiting...\n%s %s %d\n"
712 , packed_buf_nwords, detector_buf_1st, nwords_1st, detector_buf_2nd, nwords_2nd, detector_buf_3rd,
713 nwords_3rd, detector_buf_4th, nwords_4th, &rawcprpacker_info, __FILE__, __PRETTY_FUNCTION__, __LINE__);
714 printf("%s", err_buf); fflush(stdout);
715 B2FATAL(err_buf);
716}

◆ 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_v0 tmp_header

header ( not recorded )

Definition at line 368 of file RawCOPPERFormat_v0.h.

◆ tmp_trailer

RawTrailer_v0 tmp_trailer

trailer ( not recorded )

Definition at line 371 of file RawCOPPERFormat_v0.h.


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