Belle II Software development
dhc_frames Class Reference

DHC frame wrapper class. More...

#include <PXDRawDataStructs.h>

Public Member Functions

 dhc_frames (void)
 set default values
 
int getFrameType (void)
 get type of frame
 
void set (const void *d, unsigned int t)
 set data and type (and length to 0)
 
void set (const void *d, unsigned int t, unsigned int l)
 set data, type and length
 
void set (const void *d)
 set data (get type from dhc_frame_header_word0 and set length to 0)
 
unsigned int getEventNrLo (void) const
 get event nr lo (from data)
 
void check_padding (PXDErrorFlags &errormask)
 check padding and return it
 
void check_crc (PXDErrorFlags &errormask, bool ignore_crc_flag=false)
 check crc and return it
 
unsigned int getFixedSize (void)
 get fixed size
 

Public Attributes

union {
   const void *   data
 no type More...
 
   const dhc_onsen_trigger_frame *   data_onsen_trigger_frame
 data_onsen_trigger_frame More...
 
   const dhc_start_frame *   data_dhc_start_frame
 data_dhc_start_frame More...
 
   const dhc_end_frame *   data_dhc_end_frame
 data_dhc_end_frame More...
 
   const dhc_dhe_start_frame *   data_dhe_start_frame
 data_dhe_start_frame More...
 
   const dhc_dhe_end_frame *   data_dhe_end_frame
 data_dhe_end_frame More...
 
   const dhc_commode_frame *   data_commode_frame
 data_commode_frame More...
 
   const dhc_direct_readout_frame *   data_direct_readout_frame
 data_direct_readout_frame More...
 
   const dhc_direct_readout_frame_raw *   data_direct_readout_frame_raw
 data_direct_readout_frame_raw More...
 
   const dhc_direct_readout_frame_zsd *   data_direct_readout_frame_zsd
 data_direct_readout_frame_zsd More...
 
   const dhc_ghost_frame *   data_ghost_frame
 data_ghost_frame More...
 
   const dhc_onsen_roi_frame *   data_onsen_roi_frame
 data_onsen_roi_frame More...
 
}; 
 
unsigned int datasize
 datasize
 
int type
 type
 
int length
 length
 

Detailed Description

DHC frame wrapper class.

Contains functions common for all type of frames (CRC etc) Provides a union pointer to the different struct types See Data format definitions [BELLE2-NOTE-TE-2016-009] on https://docs.belle2.org/

Definition at line 550 of file PXDRawDataStructs.h.

Constructor & Destructor Documentation

◆ dhc_frames()

dhc_frames ( void  )
inline

set default values

Definition at line 571 of file PXDRawDataStructs.h.

572 {
573 data = 0;
574 datasize = 0;
575 type = -1;
576 length = 0;
577 };
const void * data
no type
unsigned int datasize
datasize

Member Function Documentation

◆ check_crc()

void check_crc ( PXDErrorFlags &  errormask,
bool  ignore_crc_flag = false 
)

check crc and return it

Definition at line 233 of file PXDRawDataStructs.cc.

234 {
235 dhc_crc_32_type bocrc;
236
237 if (length > 65536 * 16) {
238 if (!ignore_crc_flag) B2WARNING("DHC Data Frame CRC not calculated because of too large packet (>1MB)!");
239 return; // such large packets should trigger an error elsewhere
240 } else {
241 bocrc.process_bytes(data, length - 4);
242 }
243 unsigned int c;
244 c = bocrc.checksum();
245
246 ubig32_t crc32;
247 crc32 = *(ubig32_t*)(((unsigned char*)data) + length - 4);
248
249 if (c != crc32) {
250 if (!ignore_crc_flag) {
251 B2WARNING("DHC Data Frame CRC FAIL");
252 B2DEBUG(1, "DHC Data Frame CRC FAIL: " << std::hex << c << "!=" << crc32 << " data "
253 << * (unsigned int*)(((unsigned char*)data) + length - 8) << " "
254 << * (unsigned int*)(((unsigned char*)data) + length - 6) << " "
255 << * (unsigned int*)(((unsigned char*)data) + length - 4) << " len $" << length);
256 }
257 errorMask[c_nrDHE_CRC] = true;
258 }
259 };

◆ check_padding()

void check_padding ( PXDErrorFlags &  errormask)

check padding and return it

TODO many false positives, we should remove that check after we KNOW that it has been fixed in DHH Firmware

Definition at line 223 of file PXDRawDataStructs.cc.

224 {
225 unsigned int crc = *(ubig32_t*)(((unsigned char*)data) + length - 4);
226 if ((crc & 0xFFFF0000) == 0 || (crc & 0xFFFF) == 0) {
228 B2INFO("Suspicious Padding $" << std::hex << crc);
229 errorMask[c_nrSUSP_PADDING] = true;
230 }
231 };

◆ getEventNrLo()

unsigned int getEventNrLo ( void  ) const
inline

get event nr lo (from data)

Definition at line 614 of file PXDRawDataStructs.h.

615 {
616 return ((ubig16_t*)data)[1];
617 };

◆ getFixedSize()

unsigned int getFixedSize ( void  )

get fixed size

size is not a fixed number

size is not a fixed number

size is not a fixed number

size is not a fixed number

Definition at line 262 of file PXDRawDataStructs.cc.

263 {
264 unsigned int s = 0;
265 switch (getFrameType()) {
266 case EDHCFrameHeaderDataType::c_DHP_RAW:
267 s = 0;
268 break;
269 case EDHCFrameHeaderDataType::c_ONSEN_DHP:
270 case EDHCFrameHeaderDataType::c_DHP_ZSD:
271 s = 0;
272 break;
273 case EDHCFrameHeaderDataType::c_ONSEN_FCE:
274 case EDHCFrameHeaderDataType::c_FCE_RAW:
275 s = 0;
276 break;
277 case EDHCFrameHeaderDataType::c_COMMODE:
279 break;
280 case EDHCFrameHeaderDataType::c_GHOST:
282 break;
283 case EDHCFrameHeaderDataType::c_DHE_START:
285 break;
286 case EDHCFrameHeaderDataType::c_DHE_END:
288 break;
289 case EDHCFrameHeaderDataType::c_DHC_START:
291 break;
292 case EDHCFrameHeaderDataType::c_DHC_END:
294 break;
295 case EDHCFrameHeaderDataType::c_ONSEN_ROI:
296 s = 0;
297 break;
298 case EDHCFrameHeaderDataType::c_ONSEN_TRG:
300 break;
301 default:
302 B2INFO("Error: not a valid data frame!");
303 // Error will be set elsewhere in another check
304 s = 0;
305 break;
306 }
307 datasize = s;
308 return s;
309 };
const dhc_ghost_frame * data_ghost_frame
data_ghost_frame
const dhc_end_frame * data_dhc_end_frame
data_dhc_end_frame
int getFrameType(void)
get type of frame
const dhc_dhe_start_frame * data_dhe_start_frame
data_dhe_start_frame
const dhc_start_frame * data_dhc_start_frame
data_dhc_start_frame
const dhc_dhe_end_frame * data_dhe_end_frame
data_dhe_end_frame
const dhc_commode_frame * data_commode_frame
data_commode_frame
const dhc_onsen_trigger_frame * data_onsen_trigger_frame
data_onsen_trigger_frame
unsigned int getFixedSize(void) const
100 words
unsigned int getFixedSize(void) const
get fixed size
unsigned int getFixedSize(void) const
8 words
unsigned int getFixedSize(void) const
get fixed size
unsigned int getFixedSize(void) const
fixed length
unsigned int getFixedSize(void) const
8*4 bytes might still be changed
unsigned int getFixedSize(void) const
get fixed size (byte)

◆ getFrameType()

int getFrameType ( void  )
inline

get type of frame

Definition at line 579 of file PXDRawDataStructs.h.

580 {
581 return type;
582 };

◆ set() [1/3]

void set ( const void *  d)
inline

set data (get type from dhc_frame_header_word0 and set length to 0)

Parameters
ddata

Definition at line 607 of file PXDRawDataStructs.h.

608 {
609 data = d;
610 type = reinterpret_cast <const dhc_frame_header_word0*>(data)->getFrameType();
611 length = 0;
612 };

◆ set() [2/3]

void set ( const void *  d,
unsigned int  t 
)
inline

set data and type (and length to 0)

Parameters
ddata
ttype

Definition at line 587 of file PXDRawDataStructs.h.

588 {
589 data = d;
590 type = t;
591 length = 0;
592 };

◆ set() [3/3]

void set ( const void *  d,
unsigned int  t,
unsigned int  l 
)
inline

set data, type and length

Parameters
ddata
ttype
llength

Definition at line 598 of file PXDRawDataStructs.h.

599 {
600 data = d;
601 type = t;
602 length = l;
603 };

Member Data Documentation

◆ data

const void* data

no type

Definition at line 553 of file PXDRawDataStructs.h.

◆ data_commode_frame

const dhc_commode_frame* data_commode_frame

data_commode_frame

Definition at line 559 of file PXDRawDataStructs.h.

◆ data_dhc_end_frame

const dhc_end_frame* data_dhc_end_frame

data_dhc_end_frame

Definition at line 556 of file PXDRawDataStructs.h.

◆ data_dhc_start_frame

const dhc_start_frame* data_dhc_start_frame

data_dhc_start_frame

Definition at line 555 of file PXDRawDataStructs.h.

◆ data_dhe_end_frame

const dhc_dhe_end_frame* data_dhe_end_frame

data_dhe_end_frame

Definition at line 558 of file PXDRawDataStructs.h.

◆ data_dhe_start_frame

const dhc_dhe_start_frame* data_dhe_start_frame

data_dhe_start_frame

Definition at line 557 of file PXDRawDataStructs.h.

◆ data_direct_readout_frame

const dhc_direct_readout_frame* data_direct_readout_frame

data_direct_readout_frame

Definition at line 560 of file PXDRawDataStructs.h.

◆ data_direct_readout_frame_raw

const dhc_direct_readout_frame_raw* data_direct_readout_frame_raw

data_direct_readout_frame_raw

Definition at line 561 of file PXDRawDataStructs.h.

◆ data_direct_readout_frame_zsd

const dhc_direct_readout_frame_zsd* data_direct_readout_frame_zsd

data_direct_readout_frame_zsd

Definition at line 562 of file PXDRawDataStructs.h.

◆ data_ghost_frame

const dhc_ghost_frame* data_ghost_frame

data_ghost_frame

Definition at line 563 of file PXDRawDataStructs.h.

◆ data_onsen_roi_frame

const dhc_onsen_roi_frame* data_onsen_roi_frame

data_onsen_roi_frame

Definition at line 564 of file PXDRawDataStructs.h.

◆ data_onsen_trigger_frame

const dhc_onsen_trigger_frame* data_onsen_trigger_frame

data_onsen_trigger_frame

Definition at line 554 of file PXDRawDataStructs.h.

◆ datasize

unsigned int datasize

datasize

Definition at line 566 of file PXDRawDataStructs.h.

◆ length

int length

length

Definition at line 568 of file PXDRawDataStructs.h.

◆ type

int type

type

Definition at line 567 of file PXDRawDataStructs.h.


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