BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
SubDetectorFragment.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
20 : m_parent(0),
21 m_child(0),
22 m_last(0),
23 m_next(0),
24 m_extra_count(0)
25{
26 m_header[0] = eformat::SUB_DETECTOR; //marker
27 m_header[1] = 8; //this header size + status size
28 m_header[2] = 8; //this header size + status size
29 m_header[3] = eformat::DEFAULT_VERSION; //format version
30 m_header[4] = source_id;
31 m_header[5] = 1; //number of status
32 m_header[6] = 0; //number of fragment specific
33
34 //now initialize pages
35 set(m_node[0], m_header, 6, &m_node[1]);
36 set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
37 set(m_node[2], &m_header[6], 1, 0);
38 ERS_DEBUG_3("%s Source Id. = 0x%x.",
39 "Built (write) subdetector from scratch, with",
41}
42
44 : m_parent(0),
45 m_child(0),
46 m_last(0),
47 m_next(0),
48 m_extra_count(0)
49{
50 m_header[0] = eformat::SUB_DETECTOR; //marker
51 m_header[1] = 8; //this header size + status size
52 m_header[2] = 8; //this header size + status size
53 m_header[3] = eformat::DEFAULT_VERSION; //format version
54 m_header[4] = 0; //source identifier
55 m_header[5] = 1; //number of status
56 m_header[6] = 0; //number of fragment specific
57
58 //now initialize pages
59 set(m_node[0], m_header, 6, &m_node[1]);
60 set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
61 set(m_node[2], &m_header[6], 1, 0);
62 ERS_DEBUG_3("%s Source Id. = 0x%x.",
63 "Built empty (write) subdetector from scratch, with",
65}
66
68 : m_parent(0),
69 m_child(0),
70 m_last(0),
71 m_next(0),
72 m_extra_count(0)
73{
74 //now initialize pages
75 set(m_node[0], sd, 6, &m_node[1]);
76 set(m_node[1], &sd[6], sd[5], &m_node[2]);
77 set(m_node[2], &sd[6+sd[5]], 1, &m_extra);
78 eformat::write::set(m_extra, &sd[7+sd[5]], sd[1]-sd[2], 0);
79 ++m_extra_count;
80 ERS_DEBUG_3("%s Source Id. = 0x%x.",
81 "Built (write) subdetector from contiguous memory, with",
82 source_id());
83}
84
87 : m_parent(0),
88 m_child(0),
89 m_last(0),
90 m_next(0),
91 m_extra_count(0)
92{
93 //now initialize pages
94 set(m_node[0], sd->base, 6, &m_node[1]);
95 set(m_node[1], &sd->base[6], sd->base[5], &m_node[2]);
96 set(m_node[2], &sd->base[6+sd->base[5]], 1, &m_extra);
97 eformat::write::set(m_extra, &sd->base[7+sd->base[5]],
98 sd->size_word - sd->base[2], sd->next);
99 m_extra_count += eformat::write::count(m_extra);
100 ERS_DEBUG_3("%s Source Id. = 0x%x.",
101 "Built (write) subdetector from paged memory, with",
102 source_id());
103}
104
107 : m_parent(0),
108 m_child(0),
109 m_last(0),
110 m_next(0),
111 m_extra_count(0)
112{
113 *this = other;
114 ERS_DEBUG_3("%s Source Id. = 0x%x.",
115 "Built (write) subdetector from copy, with",
116 source_id());
117}
118
120eformat::write::SubDetectorFragment::operator=
122{
123 memcpy(reinterpret_cast<void*>(m_header),
124 reinterpret_cast<const void*>(other.m_node[0].base),
125 6*sizeof(uint32_t));
126 m_header[6] = other.m_node[2].base[0];
127
128 //now initialize pages
129 set(m_node[0], m_header, 6, &m_node[1]);
130 set(m_node[1], other.m_node[1].base, other.m_node[1].size_word, &m_node[2]);
131 set(m_node[2], &m_header[6], 1, 0);
132 ERS_DEBUG_3("%s Source Id. = 0x%x.",
133 "Copied (write) subdetector with",
135 return *this;
136}
137
139(uint32_t n, const uint32_t* status)
140{
141 if (m_parent) m_parent->size_change(m_node[0].base[1],
142 m_node[0].base[1]-m_node[0].base[5]+n);
143 m_node[0].base[1] -= m_node[0].base[5]; //remove count from previous status
144 m_node[0].base[2] -= m_node[0].base[5]; //remove count from previous status
145 m_node[1].size_word = m_node[0].base[5] = n; //set new values
146 m_node[0].base[1] += n;
147 m_node[0].base[2] += n;
148 m_node[1].base = const_cast<uint32_t*>(status);
149}
150
152{
153 uint32_t old_size = m_node[0].base[1];
154 m_node[0].base[1] -= o;
155 m_node[0].base[1] += n;
156 if (m_parent) m_parent->size_change(old_size, m_node[0].base[1]);
157}
158
161{
162 ERS_DEBUG_3("%s Source Id. = 0x%x to subdetector with Source Id. = 0x%x",
163 "Appending ros fragment with",
164 ros->source_id(), source_id());
165 ros->parent(this);
166 uint32_t old_size = m_node[0].base[1];
167 m_node[0].base[1] += ros->size_word();
168
169 //adjust `m_last' and `m_child' to point to the new last ROB
170 if (m_last) m_last->next(ros);
171 else m_child = ros;
172 m_last = ros;
173
174 //propagate changes to my parent
175 if (m_parent) m_parent->size_change(old_size, m_node[0].base[1]);
176}
177
179{
180 uint32_t retval = 3 + m_extra_count;
181 for (const ROSFragment* curr = m_child; curr; curr = curr->next())
182 retval += curr->page_count();
183 return retval;
184}
185
188{
189 //the header is already concatenated by construction
190 eformat::write::node_t* last = &m_node[2];
191 if (m_extra_count) {
192 last = &m_extra;
193 while (last->next) last = last->next;
194 }
195 for (ROSFragment* curr = m_child; curr;
196 curr = const_cast<ROSFragment*>(curr->next())) {
197 last->next = const_cast<eformat::write::node_t*>(curr->bind());
198 while (last->next) last = last->next; //advance until end
199 }
200 return m_node;
201}
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(...)
uint32_t size_word(void) const
void size_change(uint32_t o, uint32_t n)
const ROSFragment * next(void) const
const SubDetectorFragment * parent(void) const
const eformat::write::node_t * bind(void)
void append(eformat::write::ROSFragment *ros)
void size_change(uint32_t o, uint32_t n)
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
@ SUB_DETECTOR
The SubDet. marker.
Definition: HeaderMarker.h:29
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.