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