Belle II Software  release-08-01-10
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 
11 using namespace std;
12 using namespace Belle2;
13 
14 
15 SndHdrTemp::SndHdrTemp()
16 {
17  Initialize();
18  // cout << "SndHdrTemp NULL constructor" << endl;
19 }
20 
21 SndHdrTemp::SndHdrTemp(int* buffer)
22 {
23  // cout << "SndHdrTemp constructor with buffer" << endl;
24  memcpy(m_buffer, buffer, SENDHDR_NWORDS * sizeof(int));
25 }
26 
27 SndHdrTemp::~SndHdrTemp()
28 {
29 }
30 
31 int* SndHdrTemp::GetBuffer()
32 {
33  return m_buffer;
34 }
35 
36 void SndHdrTemp::SetBuffer(int* bufin)
37 {
38  memcpy(m_buffer, bufin, SENDHDR_NWORDS * sizeof(int));
39 }
40 
41 void 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 
50 void SndHdrTemp::SetNwords(int total_data_nwords)
51 {
52  m_buffer[ POS_NWORDS ] = total_data_nwords;
53 }
54 
55 void SndHdrTemp::SetExpRunWord(unsigned int exp_run)
56 {
57  m_buffer[ POS_EXP_RUN_NUM ] = exp_run;
58 }
59 
60 void SndHdrTemp::SetNumEventsinPacket(int num_events)
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 
67 void 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 
75 void SndHdrTemp::SetEventNumber(int eve_num)
76 {
77  m_buffer[ POS_EVE_NUM ] = eve_num;
78 }
79 
80 
81 void SndHdrTemp::SetNodeID(int node_id)
82 {
83  m_buffer[ POS_NODE_ID ] = node_id;
84 }
85 
86 
87 void 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 
98 void 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 
107 void 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 
122 int SndHdrTemp::GetTotalNwords() { return m_buffer[ POS_NWORDS ];}
123 int SndHdrTemp::GetHdrNwords() { return SENDHDR_NWORDS; }
124 int SndHdrTemp::GetNumEventsinPacket()
125 {
126  return
127  ((m_buffer[ POS_NUM_EVE_NUM_NODES ] & 0xFFFF0000) >> 16) & 0x0000FFFF;
128 
129 }
130 int SndHdrTemp::GetNumNodesinPacket() { return m_buffer[ POS_NUM_EVE_NUM_NODES ] & 0x0000FFFF; }
131 
132 int SndHdrTemp::GetEventNumber() { return m_buffer[ POS_EVE_NUM ]; }
133 
134 int SndHdrTemp::GetNodeID() { return m_buffer[ POS_NODE_ID ]; }
135 
136 int SndHdrTemp::GetRunNum()
137 {
138  return (((unsigned int)(m_buffer[ POS_EXP_RUN_NUM ]) & tmp_header.RUNNO_MASK) >> tmp_header.RUNNO_SHIFT);
139 }
140 
141 int SndHdrTemp::GetSubRunNum()
142 {
143  return ((unsigned int)(m_buffer[ POS_EXP_RUN_NUM ]) & tmp_header.SUBRUNNO_MASK);
144 }
145 
146 int 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 
154 int 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 
Abstract base class for different kinds of events.