8#ifndef _Belle2_BinData_h
9#define _Belle2_BinData_h
11#include <daq/slc/system/TCPSocket.h>
20 unsigned int reserved;
26 unsigned int nword_in_header;
27 unsigned int nevent_nboard;
29 unsigned int event_number;
36 static const unsigned int TRAILER_MAGIC;
37 static const unsigned int MAX_EVENT_WORDS = 2 * 1024 * 1024;
44 int getExpNumber()
const {
return (m_header->exp_run >> 22) & 0x3FF; };
45 int getRunNumber()
const {
return (m_header->exp_run & 0x3FFFFF) >> 8; };
46 int getSubNumber()
const {
return (m_header->exp_run & 0x3FFFFF) & 0xFF; };
47 int getEventNumber()
const {
return m_header->event_number; };
48 int setEventNumber(
int number) {
return m_header->event_number = number; };
49 int setExpNumber(
int exp_no)
51 m_header->exp_run = ((exp_no & 0x3FF) << 22) | (m_header->exp_run & 0x3FFFFF);
52 return getExpNumber();
54 int setRunNumber(
int run_no,
int sub_no)
56 m_header->exp_run = (m_header->exp_run & 0xFFC00000) |
57 (run_no & 0x3FFFFF) << 8 | (sub_no & 0xFF);
58 return getRunNumber();
60 int getNEvent()
const {
return (m_header->nevent_nboard >> 16); };
61 int getNBoard()
const {
return (m_header->nevent_nboard & 0xFFFF); };
62 int setNEvent(
int nev)
64 m_header->nevent_nboard = ((nev & 0xFFFF) << 16) | (m_header->nevent_nboard & 0xFFFF);
69 m_header->nevent_nboard = (m_header->nevent_nboard & 0xFFFF0000) | (nb & 0xFFFF);
72 void setWordSize(
int nword) { m_header->nword = nword; };
73 int getWordSize()
const {
return m_header->nword; };
74 int getByteSize()
const {
return m_header->nword * 4; };
75 int getHeaderWordSize()
const {
return m_header->nword_in_header; };
76 int getHeaderByteSize()
const {
return m_header->nword_in_header * 4; };
77 int getBodyByteSize()
const
81 void setBodyWordSize(
int nword)
84 m_trailer =
reinterpret_cast<BinTrailer*
>(m_body + getBodyWordSize());
85 m_trailer->magic = TRAILER_MAGIC;
87 int getBodyWordSize()
const {
return (getBodyByteSize() / 4); };
88 unsigned int getTrailerMagic()
90 m_trailer =
reinterpret_cast<BinTrailer*
>(m_body + getBodyWordSize());
91 return m_trailer->magic;
93 int getNodeId()
const {
return m_header->node_id; };
94 void setNodeId(
int id) { m_header->node_id = id; };
97 unsigned int recvEvent(
TCPSocket& socket);
98 unsigned int sendEvent(
TCPSocket& socket)
const;
99 int* getBuffer() {
return m_buf; }
100 const int* getBuffer()
const {
return m_buf; }
101 void setBuffer(
void* buf);
102 void print()
noexcept;
105 BinHeader* getHeader() {
return m_header; };
106 const BinHeader* getHeader()
const {
return m_header; };
107 BinTrailer* getTrailer() {
return m_trailer; }
108 const BinTrailer* getTrailer()
const {
return m_trailer; }
109 unsigned int* getBody() {
return m_body; };
110 const unsigned int* getBody()
const {
return m_body; };
115 unsigned int* m_body;
Abstract base class for different kinds of events.