BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
ROBFragment.cxx
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/**
4 * @file ROBFragment.cxx
5 * @author <a href="mailto:[email protected]">Andre DOS ANJOS</a>
6 * $Author: zhangy $
7 * $Revision: 1.1.1.1 $
8 * $Date: 2009/06/19 07:35:41 $
9 *
10 * Implements the ROB fragment writing helper class
11 */
12
13#include "eformat/write/ROBFragment.h"
14#include "eformat/write/ROSFragment.h"
15#include "eformat/HeaderMarker.h"
16#include "eformat/Status.h"
17#include <cstring>
18#include "ers/StreamFactory.h"
19
21(uint32_t source_id,
22 uint32_t run_no,
23 uint32_t lvl1_id,
24 uint32_t bc_id,
25 uint32_t lvl1_type,
26 uint32_t detev_type,
27 uint32_t ndata, const uint32_t* data, uint32_t status_position)
28 : m_parent(0),
29 m_next(0)
30{
31 m_header[0] = eformat::ROB; //marker
32 m_header[1] = 21 + ndata; //total fragment size in words
33 m_header[2] = 8; //this header size + status size
34 m_header[3] = eformat::DEFAULT_VERSION; //format version
35 m_header[4] = source_id;
36 m_header[5] = 1; //number of status
37 m_header[6] = 0; //number of fragment specific
38 m_rod_header[0] = eformat::ROD; //ROD marker
39 m_rod_header[1] = 9; //ROD header size
40 m_rod_header[2] = eformat::DEFAULT_VERSION; //format version
41 m_rod_header[3] = source_id;
42 m_rod_header[4] = run_no;
43 m_rod_header[5] = lvl1_id;
44 m_rod_header[6] = bc_id;
45 m_rod_header[7] = lvl1_type;
46 m_rod_header[8] = detev_type;
47 m_rod_trailer[0] = 1; //number of status in the ROD
48 m_rod_trailer[1] = ndata; //number of data words in the ROD
49 m_rod_trailer[2] = status_position;
50
51 //now initialize pages
52 set(m_node[0], m_header, 6, &m_node[1]);
53 set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
54 set(m_node[2], &m_header[6], 1, &m_node[3]); //specific part
55 if (m_rod_trailer[2] == eformat::STATUS_FRONT) {
56 set(m_node[3], m_rod_header, 9, &m_node[4]);
57 set(m_node[4], &eformat::DEFAULT_STATUS, 1, &m_node[5]); //status
58 set(m_node[5], data, ndata, &m_node[6]); //data
59 }
60 else {
61 set(m_node[3], m_rod_header, 9, &m_node[5]);
62 set(m_node[5], data, ndata, &m_node[4]); //data
63 set(m_node[4], &eformat::DEFAULT_STATUS, 1, &m_node[6]); //status
64 }
65 set(m_node[6], m_rod_trailer, 3, 0);
66 ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d",
67 "Built (write) rob/rod fragment from scratch, with",
69}
70
72 : m_parent(0),
73 m_next(0)
74{
75 m_header[0] = eformat::ROB; //marker
76 m_header[1] = 21;
77 m_header[2] = 8; //this header size + status size
78 m_header[3] = eformat::DEFAULT_VERSION; //format version
79 m_header[4] = 0; //source identifier of the ROB fragment
80 m_header[5] = 1; //number of status
81 m_header[6] = 0; //number of fragment specific
82 m_rod_header[0] = eformat::ROD; //ROD marker
83 m_rod_header[1] = 9; //ROD header size
84 m_rod_header[2] = eformat::DEFAULT_VERSION; //format version
85 m_rod_header[3] = 0; //source identifier of the ROD fragment
86 m_rod_header[4] = 0; //run number
87 m_rod_header[5] = 0; //LVL1 identifier
88 m_rod_header[6] = 0; //bunch crossing identifier
89 m_rod_header[7] = 0; //LVL1 type
90 m_rod_header[8] = 0; //detector event type
91 m_rod_trailer[0] = 1; //number of status in the ROD
92 m_rod_trailer[1] = 0; //number of data words in the ROD
93 m_rod_trailer[2] = eformat::STATUS_FRONT; //status block position
94
95 //now initialize pages
96 set(m_node[0], m_header, 6, &m_node[1]);
97 set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
98 set(m_node[2], &m_header[6], 1, &m_node[3]); //specific part
99 if (m_rod_trailer[2] == eformat::STATUS_FRONT) {
100 set(m_node[3], m_rod_header, 9, &m_node[4]);
101 set(m_node[4], &eformat::DEFAULT_STATUS, 1, &m_node[5]); //status
102 set(m_node[5], 0, 0, &m_node[6]); //data
103 }
104 else {
105 set(m_node[3], m_rod_header, 9, &m_node[5]);
106 set(m_node[5], 0, 0, &m_node[4]); //data
107 set(m_node[4], &eformat::DEFAULT_STATUS, 1, &m_node[6]); //status
108 }
109 set(m_node[6], m_rod_trailer, 3, 0);
110 ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d",
111 "Built (write) empty rob/rod fragment, with",
113}
114
116(const eformat::write::ROBFragment& other)
117 : m_parent(0),
118 m_next(0)
119{
120 *this = other;
121 ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d",
122 "Built new (write) rob/rod fragment from copy, with",
124}
125
126eformat::write::ROBFragment::ROBFragment (uint32_t* rod, uint32_t size_word)
127 : m_parent(0),
128 m_next(0)
129{
130 m_header[0] = eformat::ROB; //marker
131 m_header[1] = 8 + size_word; //total fragment size in words
132 m_header[2] = 8; //this header size + status size
133 m_header[3] = eformat::DEFAULT_VERSION; //format version
134 m_header[4] = rod[3];
135 m_header[5] = 1; //number of status
136 m_header[6] = 0; //number of fragment specific
137
138 //now initialize pages
139 set(m_node[0], m_header, 6, &m_node[1]);
140 set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
141 set(m_node[2], &m_header[6], 1, &m_node[3]);
142 set(m_node[6], &rod[size_word-3], 3, 0); //ROD trailer
143 if (m_node[6].base[2] == eformat::STATUS_FRONT) {
144 set(m_node[3], rod, 9, &m_node[4]); //ROD header
145 set(m_node[4], &rod[9], m_node[6].base[0], &m_node[5]); //status
146 set(m_node[5], &rod[9+m_node[6].base[0]], m_node[6].base[1], &m_node[6]);
147 }
148 else {
149 set(m_node[3], rod, 9, &m_node[5]); //ROD header
150 set(m_node[4], &rod[9+m_node[6].base[1]], m_node[6].base[0], &m_node[6]);
151 set(m_node[5], &rod[9], m_node[6].base[1], &m_node[4]); //data
152 }
153 ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d",
154 "Built (write) rob/rod fragment from rod on memory, with",
156}
157
159 : m_parent(0),
160 m_next(0)
161{
162 //now initialize pages
163 set(m_node[0], rob, 6, &m_node[1]);
164 set(m_node[1], &rob[6], rob[5], &m_node[2]);
165 set(m_node[2], &rob[6+rob[5]], 1, &m_node[3]);
166 set(m_node[6], &rob[rob[1]-3], 3, 0); //ROD trailer
167 if (m_node[6].base[2] == eformat::STATUS_FRONT) {
168 set(m_node[3], &rob[rob[2]], 9, &m_node[4]); //ROD header
169 set(m_node[4], &rob[rob[2]+9], m_node[6].base[0], &m_node[5]); //status
170 set(m_node[5], &rob[rob[2]+9+m_node[6].base[0]], m_node[6].base[1],
171 &m_node[6]); //data
172 }
173 else {
174 set(m_node[3], &rob[rob[2]], 9, &m_node[5]); //ROD header
175 set(m_node[4], &rob[rob[2]+9+m_node[6].base[1]], m_node[6].base[0],
176 &m_node[6]);
177 set(m_node[5], &rob[rob[2]+9], m_node[6].base[1], &m_node[4]); //data
178 }
179 ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d",
180 "Built (write) rob/rod fragment from cont. memory, with",
182}
183
184eformat::write::ROBFragment& eformat::write::ROBFragment::operator=
185 (const eformat::write::ROBFragment& other)
186{
187 //get the ROB header
188 memcpy(reinterpret_cast<void*>(m_header),
189 reinterpret_cast<const void*>(other.m_node[0].base),
190 6*sizeof(uint32_t));
191 m_header[6] = other.m_node[2].base[0];
192 memcpy(reinterpret_cast<void*>(m_rod_header),
193 reinterpret_cast<const void*>(other.m_node[3].base),
194 9*sizeof(uint32_t));
195 memcpy(reinterpret_cast<void*>(m_rod_trailer),
196 reinterpret_cast<const void*>(other.m_node[6].base),
197 3*sizeof(uint32_t));
198
199 //now re-initialize the pages
200 set(m_node[0], m_header, 6, &m_node[1]);
201 set(m_node[1], other.m_node[1].base, other.m_node[1].size_word, &m_node[2]);
202 set(m_node[2], &m_header[6], 1, &m_node[3]); //specific part
203 if (m_rod_trailer[2] == eformat::STATUS_FRONT) {
204 set(m_node[3], m_rod_header, 9, &m_node[4]);
205 set(m_node[4], other.m_node[4].base,
206 other.m_node[4].size_word, &m_node[5]); //status
207 set(m_node[5], other.m_node[5].base,
208 other.m_node[5].size_word, &m_node[6]); //data
209 }
210 else {
211 set(m_node[3], m_rod_header, 9, &m_node[5]);
212 set(m_node[5], other.m_node[5].base,
213 other.m_node[5].size_word, &m_node[4]); //data
214 set(m_node[4], other.m_node[4].base,
215 other.m_node[4].size_word, &m_node[6]); //status
216 }
217 set(m_node[6], m_rod_trailer, 3, 0);
218 ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d",
219 "Copied (write) rob/rod fragment with",
220 ROBFragment::source_id(), rod_lvl1_id(), rod_run_no());
221
222 return *this;
223}
224
225void eformat::write::ROBFragment::status (uint32_t n, const uint32_t* status)
226{
227 if (m_parent) m_parent->size_change(m_node[0].base[1],
228 m_node[0].base[1]-m_node[0].base[5]+n);
229 m_node[0].base[1] -= m_node[0].base[5]; //remove count from previous status
230 m_node[0].base[2] -= m_node[0].base[5]; //remove count from previous status
231 m_node[1].size_word = m_node[0].base[5] = n; //set new values
232 m_node[0].base[1] += n;
233 m_node[0].base[2] += n;
234 m_node[1].base = const_cast<uint32_t*>(status);
235}
236
238 const uint32_t* status)
239{
240 if (m_parent) m_parent->size_change(m_node[0].base[1],
241 m_node[0].base[1]-m_node[6].base[0]+n);
242 m_node[0].base[1] -= m_node[6].base[0]; //remove count from previous status
243 m_node[4].size_word = m_node[6].base[0] = n; //set new values
244 m_node[0].base[1] += n; //set ROB header's total fragment size
245 m_node[4].base = const_cast<uint32_t*>(status);
246}
247
249{
250 if (v == m_node[6].base[2]) return; //do nothing in this case:)
251 m_node[6].base[2] = v;
252 if (m_node[6].base[2] == eformat::STATUS_FRONT) {
253 m_node[3].next = &m_node[4];
254 m_node[4].next = &m_node[5];
255 m_node[5].next = &m_node[6];
256 }
257 else {
258 m_node[3].next = &m_node[5];
259 m_node[5].next = &m_node[4];
260 m_node[4].next = &m_node[6];
261 }
262}
263
264void eformat::write::ROBFragment::rod_data (uint32_t n, const uint32_t* data)
265{
266 if (m_parent) m_parent->size_change(m_node[0].base[1],
267 m_node[0].base[1]-m_node[6].base[1]+n);
268
269 //remove count from previous data size
270 m_node[0].base[1] -= m_node[6].base[1];
271 m_node[5].size_word = m_node[6].base[1] = n; //set new values
272 m_node[0].base[1] += n; //set ROB header's total fragment size back
273 m_node[5].base = const_cast<uint32_t*>(data);
274}
const Int_t n
TTree * data
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
void set(node_t &i, const uint32_t *b, size_t l, node_t *n=0)
Definition: node.cxx:16
const uint32_t STATUS_FRONT
status goes in front of data block