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

Member Function Documentation

◆ check_crc()

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

check crc and return it

Definition at line 235 of file PXDRawDataStructs.cc.

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

◆ 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 225 of file PXDRawDataStructs.cc.

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

◆ getEventNrLo()

unsigned int getEventNrLo ( void ) const
inline

get event nr lo (from data)

Definition at line 614 of file PXDRawDataStructs.h.

615 {
616 return (reinterpret_cast<const 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 264 of file PXDRawDataStructs.cc.

265 {
266 unsigned int s = 0;
267 switch (getFrameType()) {
268 case EDHCFrameHeaderDataType::c_DHP_RAW:
269 s = 0;
270 break;
271 case EDHCFrameHeaderDataType::c_ONSEN_DHP:
272 case EDHCFrameHeaderDataType::c_DHP_ZSD:
273 s = 0;
274 break;
275 case EDHCFrameHeaderDataType::c_ONSEN_FCE:
276 case EDHCFrameHeaderDataType::c_FCE_RAW:
277 s = 0;
278 break;
279 case EDHCFrameHeaderDataType::c_COMMODE:
280 s = data_commode_frame->getFixedSize();
281 break;
282 case EDHCFrameHeaderDataType::c_GHOST:
283 s = data_ghost_frame->getFixedSize();
284 break;
285 case EDHCFrameHeaderDataType::c_DHE_START:
286 s = data_dhe_start_frame->getFixedSize();
287 break;
288 case EDHCFrameHeaderDataType::c_DHE_END:
289 s = data_dhe_end_frame->getFixedSize();
290 break;
291 case EDHCFrameHeaderDataType::c_DHC_START:
292 s = data_dhc_start_frame->getFixedSize();
293 break;
294 case EDHCFrameHeaderDataType::c_DHC_END:
295 s = data_dhc_end_frame->getFixedSize();
296 break;
297 case EDHCFrameHeaderDataType::c_ONSEN_ROI:
298 s = 0;
299 break;
300 case EDHCFrameHeaderDataType::c_ONSEN_TRG:
301 s = data_onsen_trigger_frame->getFixedSize();
302 break;
303 default:
304 B2INFO("Error: not a valid data frame!");
305 // Error will be set elsewhere in another check
306 s = 0;
307 break;
308 }
309 datasize = s;
310 return s;
311 };

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