BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
eformat::write::SubDetectorFragment Class Reference

forward More...

#include <SubDetectorFragment.h>

Public Member Functions

 SubDetectorFragment (uint32_t source_id)
 
 SubDetectorFragment (uint32_t *sd)
 
 SubDetectorFragment (eformat::write::node_t *sd)
 
 SubDetectorFragment ()
 
 SubDetectorFragment (const SubDetectorFragment &other)
 
virtual ~SubDetectorFragment ()
 
SubDetectorFragmentoperator= (const SubDetectorFragment &other)
 
void status (uint32_t n, const uint32_t *status)
 
uint32_t nstatus (void) const
 
const uint32_t * status (void) const
 
void minor_version (uint16_t v)
 
uint16_t minor_version (void) const
 
void source_id (uint32_t s)
 
uint32_t source_id (void) const
 
uint32_t meta_size_word (void) const
 
uint32_t size_word (void) const
 
void append (eformat::write::ROSFragment *ros)
 
const ROSFragmentfirst_child (void) const
 
void size_change (uint32_t o, uint32_t n)
 
const FullEventFragmentparent (void) const
 
void parent (eformat::write::FullEventFragment *fe)
 
const SubDetectorFragmentnext (void) const
 
void next (const SubDetectorFragment *n)
 
uint32_t page_count (void) const
 
const eformat::write::node_tbind (void)
 

Detailed Description

forward

Defines a helper class to aid the creation of SubDetector fragments.

Definition at line 27 of file write/SubDetectorFragment.h.

Constructor & Destructor Documentation

◆ SubDetectorFragment() [1/5]

eformat::write::SubDetectorFragment::SubDetectorFragment ( uint32_t  source_id)

Builds a new SubDetector fragment from scratch

Parameters
source_idThe source identifier to be using for this SubDetector

Definition at line 19 of file SubDetectorFragment.cxx.

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}
#define ERS_DEBUG_3(...)
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

◆ SubDetectorFragment() [2/5]

eformat::write::SubDetectorFragment::SubDetectorFragment ( uint32_t *  sd)

Builds a new SubDetector fragment from an existing SubDetector fragment in contiguous memory.

Parameters
sdThe existing SubDetector fragment

Definition at line 67 of file SubDetectorFragment.cxx.

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}

◆ SubDetectorFragment() [3/5]

eformat::write::SubDetectorFragment::SubDetectorFragment ( eformat::write::node_t sd)

Builds a new SubDetector fragment from an existing SubDetector fragment in non-contiguous memory. The top-level fragment header is expected to be on a contiguous area of memory, together with the first word of the first child fragment (i.e. the ROS header marker). The following data can be spread around.

Parameters
sdThe existing SubDetector fragment, as a list of nodes, pre-concatenated by the caller.

Definition at line 85 of file SubDetectorFragment.cxx.

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}
uint32_t count(const node_t &list)
Definition: node.cxx:42
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

◆ SubDetectorFragment() [4/5]

eformat::write::SubDetectorFragment::SubDetectorFragment ( )

Builds a new empty SubDetectorFragment, otherwise invalid. This is useful for array builds and standard containers.

Definition at line 43 of file SubDetectorFragment.cxx.

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}

◆ SubDetectorFragment() [5/5]

eformat::write::SubDetectorFragment::SubDetectorFragment ( const SubDetectorFragment other)

Copy constructor. This will only copy the meta data, not the fragment relationships and block-data (children, parent and status block) contained in the to-be-copied fragment. If you wish this fragment has the same parents, and children of the copied fragment, you have to do this operation manually, after copying. If you wish to make a copy of the status as well, do it manually and then assign it to this fragment using the status() method.

Parameters
otherThe other fragment to take the meta data from.

Definition at line 105 of file SubDetectorFragment.cxx.

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}
Index other(Index i, Index j)
Definition: EvtCyclic3.cc:118

◆ ~SubDetectorFragment()

virtual eformat::write::SubDetectorFragment::~SubDetectorFragment ( )
inlinevirtual

Base destructor

Definition at line 81 of file write/SubDetectorFragment.h.

81{}

Member Function Documentation

◆ append()

void eformat::write::SubDetectorFragment::append ( eformat::write::ROSFragment ros)

Appends a new ROS fragment to this SubDetector fragment.

Warning
This will change the page structure of the last ROS fragment inserted here, in order to concatenate the ROS fragments together. Please note that this operation is not compatible with multiple threads of operation, if you would like to share eformat::write::ROSFragment's between threads. A better strategy would be create, for every thread of operation, a proper ROSFragment instead.
Parameters
rosThe ROS fragment to be appended to myself

Definition at line 159 of file SubDetectorFragment.cxx.

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}
void size_change(uint32_t o, uint32_t n)
uint32_t size_word(void) const
const ROSFragment * next(void) const
const SubDetectorFragment * parent(void) const

Referenced by Builder::append2event(), eformat::old::convert(), and main().

◆ bind()

const eformat::write::node_t * eformat::write::SubDetectorFragment::bind ( void  )

Returns the first node of a list of nodes that represent the fragment you have constructed. To make use of it, just browse the list as defined in node.h

Definition at line 187 of file SubDetectorFragment.cxx.

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}

◆ first_child()

const ROSFragment * eformat::write::SubDetectorFragment::first_child ( void  ) const
inline

This returns the first child of this fragment. The system operates as a concatenated list of fragments. From this child you can get to the next.

Definition at line 178 of file write/SubDetectorFragment.h.

178{ return m_child; }

Referenced by PackedRawDataCnvSvc::commitOutput().

◆ meta_size_word()

uint32_t eformat::write::SubDetectorFragment::meta_size_word ( void  ) const
inline

Returns the total size for the meta data (everything that does not encompass the contents of the m_data pointer in the private representation of this class) in the fragment, in words

Definition at line 149 of file write/SubDetectorFragment.h.

150 { return m_node[0].base[2]; }

◆ minor_version() [1/2]

void eformat::write::SubDetectorFragment::minor_version ( uint16_t  v)
inline

Changes the minor version number of the fragment

Parameters
sThe new minor version for this header

Definition at line 121 of file write/SubDetectorFragment.h.

122 { m_node[0].base[3] = eformat::DEFAULT_VERSION | v; }
**********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

Referenced by eformat::old::convert().

◆ minor_version() [2/2]

uint16_t eformat::write::SubDetectorFragment::minor_version ( void  ) const
inline

Returns the minor version number of the fragment

Definition at line 127 of file write/SubDetectorFragment.h.

128 { return 0xffff & m_node[0].base[3]; }

◆ next() [1/2]

void eformat::write::SubDetectorFragment::next ( const SubDetectorFragment n)
inline

Sets the next sibling

Parameters
nThe sibling following this fragment

Definition at line 213 of file write/SubDetectorFragment.h.

213{ m_next = n; }
const Int_t n

◆ next() [2/2]

const SubDetectorFragment * eformat::write::SubDetectorFragment::next ( void  ) const
inline

Returns the next sibling

Definition at line 206 of file write/SubDetectorFragment.h.

206{ return m_next; }

Referenced by PackedRawDataCnvSvc::commitOutput(), and eformat::write::FullEventFragment::page_count().

◆ nstatus()

uint32_t eformat::write::SubDetectorFragment::nstatus ( void  ) const
inline

Returns the number of status wors in this fragment

Definition at line 109 of file write/SubDetectorFragment.h.

109{ return m_node[0].base[5]; }

◆ operator=()

eformat::write::SubDetectorFragment & eformat::write::SubDetectorFragment::operator= ( const SubDetectorFragment other)

Assigment operator. This will only copy the meta data, not the fragment relationships and block-data (children and parent and status block) contained in the to-be-copied fragment. If you wish this fragment has the same parents, and children of the copied fragment, you have to do this operation manually, after copying. If you wish to make a copy of the status as well, do it manually and then assign it to this fragment using the status() method.

Parameters
otherThe other fragment to take the meta data from.

Definition at line 120 of file SubDetectorFragment.cxx.

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}

◆ page_count()

uint32_t eformat::write::SubDetectorFragment::page_count ( void  ) const

Returns the total number of (raw memory) pages this fragment is composed of.

Warning
This operation navigates at a potentially large list of child page nodes (for a full ATLAS event this should be bigger than 2,000 pages when built from scratch). If you don't do your bookkeeping, avoid calling this too often.

Definition at line 178 of file SubDetectorFragment.cxx.

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}

◆ parent() [1/2]

void eformat::write::SubDetectorFragment::parent ( eformat::write::FullEventFragment fe)
inline

This sets the parent fragment

Parameters
feThe FullEventFragment parent fragment of this SubDetector

Definition at line 200 of file write/SubDetectorFragment.h.

201 { m_parent = fe; }

◆ parent() [2/2]

const FullEventFragment * eformat::write::SubDetectorFragment::parent ( void  ) const
inline

This returns the parent fragment

Definition at line 192 of file write/SubDetectorFragment.h.

193 { return m_parent; }

Referenced by eformat::write::FullEventFragment::append().

◆ size_change()

void eformat::write::SubDetectorFragment::size_change ( uint32_t  o,
uint32_t  n 
)

This method is used by children of this fragment to notify fragment size changes.

Parameters
oThe old size, in 32-bit words
nThe new size, in 32-bit words

Definition at line 151 of file SubDetectorFragment.cxx.

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}

◆ size_word()

uint32_t eformat::write::SubDetectorFragment::size_word ( void  ) const
inline

Returns the total size for this fragment, in words

Definition at line 155 of file write/SubDetectorFragment.h.

156 { return m_node[0].base[1]; }

Referenced by eformat::write::FullEventFragment::append().

◆ source_id() [1/2]

void eformat::write::SubDetectorFragment::source_id ( uint32_t  s)
inline

Changes the source identifier for this fragment

Parameters
sThe new value to set

Definition at line 135 of file write/SubDetectorFragment.h.

136 { m_node[0].base[4] = s; }
XmlRpcServer s
Definition: HelloServer.cpp:11

Referenced by eformat::write::FullEventFragment::append().

◆ source_id() [2/2]

uint32_t eformat::write::SubDetectorFragment::source_id ( void  ) const
inline

Returns the source identifier of this fragment

Definition at line 141 of file write/SubDetectorFragment.h.

142 { return m_node[0].base[4]; }

Referenced by operator=(), and SubDetectorFragment().

◆ status() [1/2]

void eformat::write::SubDetectorFragment::status ( uint32_t  n,
const uint32_t *  status 
)

Changes the number of status words and the status words themselves from the fragment

Parameters
nHow many status words the underlying SubDetectorFragment fragment supposed to have.
statusA pointer to n pre-allocated words

Definition at line 138 of file SubDetectorFragment.cxx.

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}

Referenced by Builder::append2event(), and eformat::old::convert().

◆ status() [2/2]

const uint32_t * eformat::write::SubDetectorFragment::status ( void  ) const
inline

Returns a pointer to the first status word to be used by this fragment

Definition at line 114 of file write/SubDetectorFragment.h.

114{ return m_node[1].base; }

The documentation for this class was generated from the following files: