BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
FullEventFragment.cxx
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/**
4 * @file SubDetectorFragment.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 SubDetector fragment writing helper class
11 */
12
16#include "eformat/Status.h"
17#include "ers/StreamFactory.h"
18#include <ctime>
19
21(uint32_t source_id, uint32_t use_time,
22 uint32_t global_id, uint32_t run_no,
23 uint32_t lvl1_id, uint32_t lvl1_type,
24 uint32_t lvl2_info, const uint32_t* ef_info)
25 : m_child(0),
26 m_last(0),
27 m_extra_count(0)
28{
29 m_header[0] = eformat::FULL_EVENT; //marker
30 m_header[1] = 18; //this header size + status size
31 m_header[2] = 18; //this header size + status size
32 m_header[3] = eformat::DEFAULT_VERSION; //format version
33 m_header[4] = source_id;
34 m_header[5] = 1; //number of status
35 m_header[6] = 10; //number of fragment specific
36 m_header[7] = use_time;
37 m_header[8] = global_id;
38 m_header[9] = run_no;
39 m_header[10] = lvl1_id;
40 m_header[11] = lvl1_type;
41 m_header[12] = lvl2_info;
42 memcpy(&m_header[13], ef_info, 4*sizeof(uint32_t));
43
44 //now initialize pages
45 set(m_node[0], m_header, 6, &m_node[1]);
46 set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
47 set(m_node[2], &m_header[6], 11, 0);
48 ERS_DEBUG_3("%s Source Id. = 0x%x, LVL1 Id. = %d and Run Number = %d",
49 "Built (write) full event from scratch, with",
52}
53
55(uint32_t source_id, uint32_t global_id, uint32_t run_no,
56 uint32_t lvl1_id, uint32_t lvl1_type,
57 uint32_t lvl2_info, const uint32_t* ef_info)
58 : m_child(0),
59 m_last(0),
60 m_extra_count(0)
61{
62 m_header[0] = eformat::FULL_EVENT; //marker
63 m_header[1] = 18; //this header size + status size
64 m_header[2] = 18; //this header size + status size
65 m_header[3] = eformat::DEFAULT_VERSION; //format version
66 m_header[4] = source_id;
67 m_header[5] = 1; //number of status
68 m_header[6] = 10; //number of fragment specific
69 m_header[7] = std::time(0);
70 m_header[8] = global_id;
71 m_header[9] = run_no;
72 m_header[10] = lvl1_id;
73 m_header[11] = lvl1_type;
74 m_header[12] = lvl2_info;
75 memcpy(&m_header[13], ef_info, 4*sizeof(uint32_t));
76
77 //now initialize pages
78 set(m_node[0], m_header, 6, &m_node[1]);
79 set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
80 set(m_node[2], &m_header[6], 11, 0);
81 ERS_DEBUG_3("%s Source Id. = 0x%x, LVL1 Id. = %d and Run Number = %d",
82 "Built (write) full event from scratch, with",
85}
86
88 : m_child(0),
89 m_last(0),
90 m_extra_count(0)
91{
92 //now initialize pages
93 set(m_node[0], fe, 6, &m_node[1]);
94 set(m_node[1], &fe[6], fe[5], &m_node[2]);
95 set(m_node[2], &fe[6+fe[5]], 11, 0);
96 eformat::write::set(m_extra, &fe[17+fe[5]], fe[1]-fe[2], 0);
97 ++m_extra_count;
98 ERS_DEBUG_3("%s Source Id. = 0x%x, LVL1 Id. = %d and Run Number = %d",
99 "Built (write) full event from contiguos memory, with",
100 source_id(), lvl1_id(), run_no());
101}
102
105 : m_child(0),
106 m_last(0),
107 m_extra_count(0)
108{
109 //now initialize pages
110 set(m_node[0], fe->base, 6, &m_node[1]);
111 set(m_node[1], &fe->base[6], fe->base[5], &m_node[2]);
112 set(m_node[2], &fe->base[6+fe->base[5]], 11, 0);
113 eformat::write::set(m_extra, &fe->base[17+fe->base[5]],
114 fe->size_word - fe->base[2], fe->next);
115 m_extra_count += eformat::write::count(m_extra);
116 ERS_DEBUG_3("%s Source Id. = 0x%x, LVL1 Id. = %d and Run Number = %d",
117 "Built (write) full event from paged memory, with",
118 source_id(), lvl1_id(), run_no());
119}
120
122 : m_child(0),
123 m_last(0),
124 m_extra_count(0)
125{
126 m_header[0] = eformat::FULL_EVENT; //marker
127 m_header[1] = 18; //this header size + status size
128 m_header[2] = 18; //this header size + status size
129 m_header[3] = eformat::DEFAULT_VERSION; //format version
130 m_header[4] = 0; //source identifier
131 m_header[5] = 1; //number of status
132 m_header[6] = 10; //number of fragment specific
133 m_header[7] = std::time(0);
134 m_header[8] = 0; //global identifier
135 m_header[9] = 0; //run number
136 m_header[10] = 0; //LVL1 identifier
137 m_header[11] = 0; //LVL1 type
138 m_header[12] = 0; //LVL2 info
139 m_header[13] = 0; //EF info [0]
140 m_header[14] = 0; //EF info [1]
141 m_header[15] = 0; //EF info [2]
142 m_header[16] = 0; //EF info [3]
143
144 //now initialize pages
145 set(m_node[0], m_header, 6, &m_node[1]);
146 set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
147 set(m_node[2], &m_header[6], 11, 0);
148 ERS_DEBUG_3("%s Source Id. = 0x%x, LVL1 Id. = %d and Run Number = %d",
149 "Built empty (write) full event from scratch, with",
152}
153
156 : m_child(0),
157 m_last(0),
158 m_extra_count(0)
159{
160 *this = other;
161 ERS_DEBUG_3("%s Source Id. = 0x%x, LVL1 Id. = %d and Run Number = %d",
162 "Built (write) full event from copy, with",
165}
166
168eformat::write::FullEventFragment::operator=
170{
171 memcpy(reinterpret_cast<void*>(m_header),
172 reinterpret_cast<const void*>(other.m_node[0].base),
173 6*sizeof(uint32_t));
174 memcpy(reinterpret_cast<void*>(m_header+6),
175 reinterpret_cast<const void*>(other.m_node[2].base),
176 11*sizeof(uint32_t));
177
178 //now initialize pages
179 set(m_node[0], m_header, 6, &m_node[1]);
180 set(m_node[1], other.m_node[1].base, other.m_node[1].size_word, &m_node[2]);
181 set(m_node[2], &m_header[6], 11, 0);
182 ERS_DEBUG_3("%s Source Id. = 0x%x, LVL1 Id. = %d and Run Number = %d",
183 "Copied (write) full event, with",
186 return *this;
187}
188
190(uint32_t n, const uint32_t* status)
191{
192 m_node[0].base[1] -= m_node[0].base[5]; //remove count from previous status
193 m_node[0].base[2] -= m_node[0].base[5]; //remove count from previous status
194 m_node[1].size_word = m_node[0].base[5] = n; //set new values
195 m_node[0].base[1] += n;
196 m_node[0].base[2] += n;
197 m_node[1].base = const_cast<uint32_t*>(status);
198}
199
202{
203 ERS_DEBUG_3("%s Source Id. = 0x%x to full event with Source Id. = 0x%x",
204 "Appending subdetector with",
205 sd->source_id(), source_id());
206 sd->parent(this);
207 m_node[0].base[1] += sd->size_word();
208
209 //adjust `m_last' and `m_child' to point to the new last ROB
210 if (m_last) m_last->next(sd);
211 else m_child = sd;
212 m_last = sd;
213}
214
216{
217 uint32_t retval = 3 + m_extra_count;
218 for (const SubDetectorFragment* curr = m_child; curr; curr = curr->next())
219 retval += curr->page_count();
220 return retval;
221}
222
225{
226 //the header is already concatenated by construction
227 eformat::write::node_t* last = &m_node[2];
228 if (m_extra_count) {
229 last = &m_extra;
230 while (last->next) last = last->next;
231 }
232 for (SubDetectorFragment* curr = m_child; curr;
233 curr = const_cast<SubDetectorFragment*>(curr->next())) {
234 last->next = const_cast<eformat::write::node_t*>(curr->bind());
235 while (last->next) last = last->next; //advance until end
236 }
237 return m_node;
238}
const Int_t n
Defines the constants used by Event Fragments.
A helper class to help the user to interpret the status information in the first status word and to c...
#define ERS_DEBUG_3(...)
void append(eformat::write::SubDetectorFragment *sd)
const uint32_t * status(void) const
const eformat::write::node_t * bind(void)
const FullEventFragment * parent(void) const
const SubDetectorFragment * next(void) const
uint32_t count(const node_t &list)
Definition: node.cxx:42
void set(node_t &i, const uint32_t *b, size_t l, node_t *n=0)
Definition: node.cxx:16
@ FULL_EVENT
Definition: HeaderMarker.h:30
const uint32_t DEFAULT_VERSION
Definition: Version.h:24
const uint32_t DEFAULT_STATUS
Definition: Status.h:44
node_t * next
The next node.
Definition: node.h:29
uint32_t * base
The base address for this page.
Definition: node.h:27
size_t size_word
The size, in 4-byte words for this page.
Definition: node.h:28
Helps the user to define and build a FullEvent fragment.
Helps the user to define and build a SubDetector fragment.