Belle II Software development
ONSENBinData Class Reference
Inheritance diagram for ONSENBinData:
BinData

Classes

struct  sose_frame_t
 

Public Member Functions

 ONSENBinData (void *buf)
 
unsigned int getTrigger () const
 
unsigned int getTimetag () const
 
unsigned int getTriggerType () const
 
unsigned int getEventNumber () const
 
unsigned int getFrameNumber () const
 
unsigned int getFrameByteSize () const
 
unsigned int getONSENMagic () const
 
int getExpNumber () const
 
int getRunNumber () const
 
int getSubNumber () const
 
int setEventNumber (int number)
 
int setExpNumber (int exp_no)
 
int setRunNumber (int run_no, int sub_no)
 
int getNEvent () const
 
int getNBoard () const
 
int setNEvent (int nev)
 
int setNBoard (int nb)
 
void setWordSize (int nword)
 
int getWordSize () const
 
int getByteSize () const
 
int getHeaderWordSize () const
 
int getHeaderByteSize () const
 
int getBodyByteSize () const
 
void setBodyWordSize (int nword)
 
int getBodyWordSize () const
 
unsigned int getTrailerMagic ()
 
int getNodeId () const
 
void setNodeId (int id)
 
unsigned int recvEvent (TCPSocket &socket)
 
unsigned int sendEvent (TCPSocket &socket) const
 
int * getBuffer ()
 
const int * getBuffer () const
 
void setBuffer (void *buf)
 
void print () noexcept
 
BinHeadergetHeader ()
 
const BinHeadergetHeader () const
 
BinTrailergetTrailer ()
 
const BinTrailergetTrailer () const
 
unsigned int * getBody ()
 
const unsigned int * getBody () const
 

Static Public Attributes

static const unsigned int MAX_PXD_FRAMES = 256
 
static const unsigned int MAGIC = 0xBEBAFECA
 
static const unsigned int TRAILER_MAGIC = 0x7FFF0007
 
static const unsigned int MAX_EVENT_WORDS = 2 * 1024 * 1024
 

Protected Attributes

BinTrailerm_trailer
 
BinHeaderm_header
 
unsigned int * m_body
 
int * m_buf
 

Private Attributes

sose_frame_tm_start_frame
 

Detailed Description

Definition at line 19 of file ONSENBinData.h.

Constructor & Destructor Documentation

◆ ONSENBinData()

ONSENBinData ( void *  buf)

Definition at line 14 of file ONSENBinData.cc.

14 : BinData(buf)
15{
16
17}

◆ ~ONSENBinData()

~ONSENBinData ( )
throw (
)

Definition at line 19 of file ONSENBinData.cc.

20{
21
22}

Member Function Documentation

◆ getBody() [1/2]

unsigned int * getBody ( )
inlineinherited

Definition at line 109 of file BinData.h.

109{ return m_body; };

◆ getBody() [2/2]

const unsigned int * getBody ( ) const
inlineinherited

Definition at line 110 of file BinData.h.

110{ return m_body; };

◆ getBodyByteSize()

int getBodyByteSize ( ) const
inlineinherited

Definition at line 77 of file BinData.h.

78 {
79 return getByteSize() - sizeof(BinHeader) - sizeof(BinTrailer);
80 }

◆ getBodyWordSize()

int getBodyWordSize ( ) const
inlineinherited

Definition at line 87 of file BinData.h.

87{ return (getBodyByteSize() / 4); };

◆ getBuffer() [1/2]

int * getBuffer ( )
inlineinherited

Definition at line 99 of file BinData.h.

99{ return m_buf; }

◆ getBuffer() [2/2]

const int * getBuffer ( ) const
inlineinherited

Definition at line 100 of file BinData.h.

100{ return m_buf; }

◆ getByteSize()

int getByteSize ( ) const
inlineinherited

Definition at line 74 of file BinData.h.

74{ return m_header->nword * 4; };

◆ getEventNumber()

unsigned int getEventNumber ( ) const

Definition at line 39 of file ONSENBinData.cc.

40{
41 unsigned int nframe = getFrameNumber();
42 if (nframe > MAX_PXD_FRAMES) return 0;
43 m_start_frame = reinterpret_cast<sose_frame_t*>(m_body + nframe + 2);
44 return getTrigger();
45}

◆ getExpNumber()

int getExpNumber ( ) const
inlineinherited

Definition at line 44 of file BinData.h.

44{ return (m_header->exp_run >> 22) & 0x3FF; };

◆ getFrameByteSize()

unsigned int getFrameByteSize ( ) const

Definition at line 57 of file ONSENBinData.cc.

58{
59 const unsigned int nframe = getFrameNumber();
60 unsigned int nbyte = 0;
61 for (unsigned int i = 0; i < nframe; i++) {
62 nbyte += ntohl(m_body[2 + i]);
63 }
64 if (m_body[2 + nframe] != ntohs(0x3000)) {
65 return nbyte - 8;
66 } else {
67 return nbyte;
68 }
69}

◆ getFrameNumber()

unsigned int getFrameNumber ( ) const

Definition at line 52 of file ONSENBinData.cc.

53{
54 return ntohl(m_body[1]);
55}

◆ getHeader() [1/2]

BinHeader * getHeader ( )
inlineinherited

Definition at line 105 of file BinData.h.

105{ return m_header; };

◆ getHeader() [2/2]

const BinHeader * getHeader ( ) const
inlineinherited

Definition at line 106 of file BinData.h.

106{ return m_header; };

◆ getHeaderByteSize()

int getHeaderByteSize ( ) const
inlineinherited

Definition at line 76 of file BinData.h.

76{ return m_header->nword_in_header * 4; };

◆ getHeaderWordSize()

int getHeaderWordSize ( ) const
inlineinherited

Definition at line 75 of file BinData.h.

75{ return m_header->nword_in_header; };

◆ getNBoard()

int getNBoard ( ) const
inlineinherited

Definition at line 61 of file BinData.h.

61{ return (m_header->nevent_nboard & 0xFFFF); };

◆ getNEvent()

int getNEvent ( ) const
inlineinherited

Definition at line 60 of file BinData.h.

60{ return (m_header->nevent_nboard >> 16); };

◆ getNodeId()

int getNodeId ( ) const
inlineinherited

Definition at line 93 of file BinData.h.

93{ return m_header->node_id; };

◆ getONSENMagic()

unsigned int getONSENMagic ( ) const

Definition at line 71 of file ONSENBinData.cc.

72{
73 return ntohl(m_body[0]);
74}

◆ getRunNumber()

int getRunNumber ( ) const
inlineinherited

Definition at line 45 of file BinData.h.

45{ return (m_header->exp_run & 0x3FFFFF) >> 8; };

◆ getSubNumber()

int getSubNumber ( ) const
inlineinherited

Definition at line 46 of file BinData.h.

46{ return (m_header->exp_run & 0x3FFFFF) & 0xFF; };

◆ getTimetag()

unsigned int getTimetag ( ) const

Definition at line 30 of file ONSENBinData.cc.

31{
32 uint64_t retval =
33 ((uint64_t)ntohs(m_start_frame->time_tag_hi) << 32)
34 | ((uint64_t)ntohs(m_start_frame->time_tag_mid) << 16)
35 | (uint64_t)ntohs(m_start_frame->time_tag_lo_and_type);
36 return (retval >> 4);
37}

◆ getTrailer() [1/2]

BinTrailer * getTrailer ( )
inlineinherited

Definition at line 107 of file BinData.h.

107{ return m_trailer; }

◆ getTrailer() [2/2]

const BinTrailer * getTrailer ( ) const
inlineinherited

Definition at line 108 of file BinData.h.

108{ return m_trailer; }

◆ getTrailerMagic()

unsigned int getTrailerMagic ( )
inlineinherited

Definition at line 88 of file BinData.h.

89 {
90 m_trailer = reinterpret_cast<BinTrailer*>(m_body + getBodyWordSize());
91 return m_trailer->magic;
92 }

◆ getTrigger()

unsigned int getTrigger ( ) const

Definition at line 24 of file ONSENBinData.cc.

25{
26 return (ntohs(m_start_frame->trigger_hi) << 16)
27 + ntohs(m_start_frame->trigger_lo);
28}

◆ getTriggerType()

unsigned int getTriggerType ( ) const

Definition at line 47 of file ONSENBinData.cc.

48{
49 return (ntohs(m_start_frame->time_tag_lo_and_type) & 0xF);
50}

◆ getWordSize()

int getWordSize ( ) const
inlineinherited

Definition at line 73 of file BinData.h.

73{ return m_header->nword; };

◆ print()

void print ( )
noexceptinherited

Definition at line 69 of file BinData.cc.

70{
71 printf("headerwords=%d, nwords=%d, nboard=%d, nevent=%d, evtno=%d, expno=%d, runno=%d, subno=%d, nodeid=%d, trailer=%04x\n",
72 getHeaderWordSize(),
73 getWordSize(),
74 // getBodyWordSize(),
75 getNBoard(),
76 getNEvent(),
77 getEventNumber(),
78 getExpNumber(),
79 getRunNumber(),
80 getSubNumber(),
81 getNodeId(),
82 getTrailerMagic());
83}

◆ recvEvent()

unsigned int recvEvent ( TCPSocket socket)
inherited

Definition at line 47 of file BinData.cc.

48{
49 unsigned int count = socket.read(m_header, sizeof(BinHeader));
50 if (m_header->nword_in_header * 4 != sizeof(BinHeader)) {
51 throw (IOException("unexpected header size %d words",
52 m_header->nword_in_header));
53 }
54 const int nbytes_remains = getByteSize() - sizeof(BinHeader);
55 count += socket.read(m_body, nbytes_remains);
56 m_trailer = (BinTrailer*)(((char*)m_body) + nbytes_remains - sizeof(BinTrailer));
57 if (m_trailer->magic != TRAILER_MAGIC) {
58 throw (IOException("unexpected header trailer magic %08x",
59 m_trailer->magic));
60 }
61 return count;
62}

◆ sendEvent()

unsigned int sendEvent ( TCPSocket socket) const
inherited

Definition at line 64 of file BinData.cc.

65{
66 return socket.write(m_buf, getByteSize());
67}

◆ setBodyWordSize()

void setBodyWordSize ( int  nword)
inlineinherited

Definition at line 81 of file BinData.h.

82 {
83 setWordSize(nword + (sizeof(BinHeader) + sizeof(BinTrailer)) / 4);
84 m_trailer = reinterpret_cast<BinTrailer*>(m_body + getBodyWordSize());
85 m_trailer->magic = TRAILER_MAGIC;
86 }

◆ setBuffer()

void setBuffer ( void *  buf)
inherited

Definition at line 36 of file BinData.cc.

37{
38 if (buf != NULL) {
39 m_buf = (int*)buf;
40 m_header = (BinHeader*)buf;
41 m_body = (unsigned int*)(((char*)buf) + sizeof(BinHeader));
42 } else {
43 m_buf = NULL;
44 }
45}

◆ setEventNumber()

int setEventNumber ( int  number)
inlineinherited

Definition at line 48 of file BinData.h.

48{ return m_header->event_number = number; };

◆ setExpNumber()

int setExpNumber ( int  exp_no)
inlineinherited

Definition at line 49 of file BinData.h.

50 {
51 m_header->exp_run = ((exp_no & 0x3FF) << 22) | (m_header->exp_run & 0x3FFFFF);
52 return getExpNumber();
53 };

◆ setNBoard()

int setNBoard ( int  nb)
inlineinherited

Definition at line 67 of file BinData.h.

68 {
69 m_header->nevent_nboard = (m_header->nevent_nboard & 0xFFFF0000) | (nb & 0xFFFF);
70 return getNBoard();
71 };

◆ setNEvent()

int setNEvent ( int  nev)
inlineinherited

Definition at line 62 of file BinData.h.

63 {
64 m_header->nevent_nboard = ((nev & 0xFFFF) << 16) | (m_header->nevent_nboard & 0xFFFF);
65 return getNEvent();
66 };

◆ setNodeId()

void setNodeId ( int  id)
inlineinherited

Definition at line 94 of file BinData.h.

94{ m_header->node_id = id; };

◆ setRunNumber()

int setRunNumber ( int  run_no,
int  sub_no 
)
inlineinherited

Definition at line 54 of file BinData.h.

55 {
56 m_header->exp_run = (m_header->exp_run & 0xFFC00000) |
57 (run_no & 0x3FFFFF) << 8 | (sub_no & 0xFF);
58 return getRunNumber();
59 };

◆ setWordSize()

void setWordSize ( int  nword)
inlineinherited

Definition at line 72 of file BinData.h.

72{ m_header->nword = nword; };

Member Data Documentation

◆ m_body

unsigned int* m_body
protectedinherited

Definition at line 115 of file BinData.h.

◆ m_buf

int* m_buf
mutableprotectedinherited

Definition at line 116 of file BinData.h.

◆ m_header

BinHeader* m_header
protectedinherited

Definition at line 114 of file BinData.h.

◆ m_start_frame

sose_frame_t* m_start_frame
mutableprivate

Definition at line 51 of file ONSENBinData.h.

◆ m_trailer

BinTrailer* m_trailer
protectedinherited

Definition at line 113 of file BinData.h.

◆ MAGIC

const unsigned int MAGIC = 0xBEBAFECA
static

Definition at line 35 of file ONSENBinData.h.

◆ MAX_EVENT_WORDS

const unsigned int MAX_EVENT_WORDS = 2 * 1024 * 1024
staticinherited

Definition at line 37 of file BinData.h.

◆ MAX_PXD_FRAMES

const unsigned int MAX_PXD_FRAMES = 256
static

Definition at line 34 of file ONSENBinData.h.

◆ TRAILER_MAGIC

const unsigned int TRAILER_MAGIC = 0x7FFF0007
staticinherited

Definition at line 36 of file BinData.h.


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