Belle II Software development
SendHeader.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include "daq/dataobjects/SendHeader.h"
10
11using namespace std;
12using namespace Belle2;
13
14//ClassImp(SendHeader);
15
17{
18 Initialize();
19 // cout << "SendHeader NULL constructor" << endl;
20}
21
23{
24 // cout << "SendHeader constructor with buffer" << endl;
25 memcpy(m_buffer, buffer, SENDHDR_NWORDS * sizeof(int));
26}
27
29{
30}
31
33{
34 return m_buffer;
35}
36
37void SendHeader::SetBuffer(int* bufin)
38{
39 memcpy(m_buffer, bufin, SENDHDR_NWORDS * sizeof(int));
40}
41
42void SendHeader::Initialize()
43{
44 memset(m_buffer, 0, sizeof(int)* SENDHDR_NWORDS);
45 m_buffer[ POS_HDR_NWORDS ] = SENDHDR_NWORDS;
46}
47
48
49// Set Values
50
51void SendHeader::SetNwords(int total_data_nwords)
52{
53 m_buffer[ POS_NWORDS ] = total_data_nwords;
54}
55
56void SendHeader::SetExpRunWord(unsigned int exp_run)
57{
58 m_buffer[ POS_EXP_RUN_NUM ] = exp_run;
59}
60
62{
63 m_buffer[ POS_NUM_EVE_NUM_NODES ] =
64 (m_buffer[ POS_NUM_EVE_NUM_NODES ] & 0x0000FFFF) |
65 ((num_events << 16) & 0xFFFF0000);
66}
67
68void SendHeader::SetNumNodesinPacket(int num_nodes)
69{
70 m_buffer[ POS_NUM_EVE_NUM_NODES ] =
71 (m_buffer[ POS_NUM_EVE_NUM_NODES ] & 0xFFFF0000) |
72 (num_nodes & 0x0000FFFF);
73}
74
75
76void SendHeader::SetEventNumber(int eve_num)
77{
78 m_buffer[ POS_EVE_NUM ] = eve_num;
79}
80
81
82void SendHeader::SetNodeID(int node_id)
83{
84 m_buffer[ POS_NODE_ID ] = node_id;
85}
86
87
88void SendHeader::SetRunNum(int run_num)
89{
90
91 unsigned int inv_mask = ~((unsigned int)(RUNNO_MASK));
92 m_buffer[ POS_EXP_RUN_NUM ] =
93 ((unsigned int)m_buffer[ POS_EXP_RUN_NUM ] & inv_mask) |
94 (((unsigned int)run_num << RUNNO_SHIFT) & RUNNO_MASK);
95
96 return;
97}
98
99void SendHeader::SetSubRunNum(int subrun_num)
100{
101
102 unsigned int inv_mask = ~((unsigned int)(SUBRUNNO_MASK));
103 m_buffer[ POS_EXP_RUN_NUM ] =
104 ((unsigned int)m_buffer[ POS_EXP_RUN_NUM ] & inv_mask) | ((unsigned int)subrun_num & SUBRUNNO_MASK);
105 return;
106}
107
108void SendHeader::SetExpNum(int exp_num)
109{
110
111 unsigned int inv_mask = ~((unsigned int)(EXP_MASK));
112 m_buffer[ POS_EXP_RUN_NUM ] =
113 ((unsigned int)m_buffer[ POS_EXP_RUN_NUM ] & inv_mask) |
114 (((unsigned int)exp_num << EXP_SHIFT) & EXP_MASK);
115
116 return;
117}
118
119
120
121// Get Values
122
123int SendHeader::GetTotalNwords() { return m_buffer[ POS_NWORDS ];}
124int SendHeader::GetHdrNwords() { return SENDHDR_NWORDS; }
126{
127 return
128 ((m_buffer[ POS_NUM_EVE_NUM_NODES ] & 0xFFFF0000) >> 16) & 0x0000FFFF;
129
130}
131int SendHeader::GetNumNodesinPacket() { return m_buffer[ POS_NUM_EVE_NUM_NODES ] & 0x0000FFFF; }
132
133int SendHeader::GetEventNumber() { return m_buffer[ POS_EVE_NUM ]; }
134
135int SendHeader::GetNodeID() { return m_buffer[ POS_NODE_ID ]; }
136
137int SendHeader::GetRunNum()
138{
139 return (((unsigned int)(m_buffer[ POS_EXP_RUN_NUM ]) & RUNNO_MASK) >> RUNNO_SHIFT);
140}
141
142int SendHeader::GetSubRunNum()
143{
144 return ((unsigned int)(m_buffer[ POS_EXP_RUN_NUM ]) & SUBRUNNO_MASK);
145}
146
147int SendHeader::GetRunNumSubRunNum()
148{
149
150 return ((unsigned int)(m_buffer[ POS_EXP_RUN_NUM ]) &
151 (RUNNO_MASK | SUBRUNNO_MASK));
152}
153
154
155int SendHeader::GetExpNum()
156{
157
158 return (((unsigned int)(m_buffer[ POS_EXP_RUN_NUM ]) & EXP_MASK) >> EXP_SHIFT);
159}
160
161
void SetBuffer(int *hdr)
set buffer
Definition: SendHeader.cc:37
~SendHeader()
Destructor.
Definition: SendHeader.cc:28
void SetNumEventsinPacket(int num_events)
set contents of Header
Definition: SendHeader.cc:61
int GetHdrNwords()
get contents of Header
Definition: SendHeader.cc:124
void SetNwords(int total_data_nwords)
initialize Header
Definition: SendHeader.cc:51
int GetNumEventsinPacket()
get contents of Header
Definition: SendHeader.cc:125
int * GetBuffer(void)
Get Header contents.
Definition: SendHeader.cc:32
SendHeader()
Default constructor.
Definition: SendHeader.cc:16
Abstract base class for different kinds of events.
STL namespace.