eformat::write::SubDetectorFragment Class Reference

forward More...

#include <SubDetectorFragment.h>

List of all members.

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)

Private Attributes

uint32_t m_header [7]
 The SubDetector Header.
eformat::write::node_t m_node [3]
 Node representation.
eformat::write::FullEventFragmentm_parent
 my parent
eformat::write::ROSFragmentm_child
 my ROS children
eformat::write::ROSFragmentm_last
 my last ROS child
const eformat::write::SubDetectorFragmentm_next
 Next sibling.
eformat::write::node_t m_extra
 Extra pages I may have.
uint32_t m_extra_count
 How many extra pages I have.


Detailed Description

forward

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

Definition at line 27 of file SubDetectorFragment.h.


Constructor & Destructor Documentation

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

Builds a new SubDetector fragment from scratch

Parameters:
source_id The source identifier to be using for this SubDetector

Definition at line 19 of file SubDetectorFragment.cxx.

References eformat::DEFAULT_STATUS, eformat::DEFAULT_VERSION, ERS_DEBUG_3, m_header, m_node, eformat::write::set(), source_id(), and eformat::SUB_DETECTOR.

00020   : m_parent(0),
00021     m_child(0),
00022     m_last(0),
00023     m_next(0),
00024     m_extra_count(0)
00025 {
00026   m_header[0] = eformat::SUB_DETECTOR; //marker
00027   m_header[1] = 8; //this header size + status size
00028   m_header[2] = 8; //this header size + status size
00029   m_header[3] = eformat::DEFAULT_VERSION; //format version
00030   m_header[4] = source_id;
00031   m_header[5] = 1; //number of status
00032   m_header[6] = 0; //number of fragment specific
00033 
00034   //now initialize pages
00035   set(m_node[0], m_header, 6, &m_node[1]);
00036   set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
00037   set(m_node[2], &m_header[6], 1, 0);
00038   ERS_DEBUG_3("%s Source Id. = 0x%x.", 
00039               "Built (write) subdetector from scratch, with", 
00040               SubDetectorFragment::source_id());
00041 }

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

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

Parameters:
sd The existing SubDetector fragment

Definition at line 67 of file SubDetectorFragment.cxx.

References ERS_DEBUG_3, m_extra, m_extra_count, m_node, eformat::write::set(), and source_id().

00068   : m_parent(0),
00069     m_child(0),
00070     m_last(0),
00071     m_next(0),
00072     m_extra_count(0)
00073 {
00074   //now initialize pages
00075   set(m_node[0], sd, 6, &m_node[1]);
00076   set(m_node[1], &sd[6], sd[5], &m_node[2]);
00077   set(m_node[2], &sd[6+sd[5]], 1, &m_extra);
00078   eformat::write::set(m_extra, &sd[7+sd[5]], sd[1]-sd[2], 0);
00079   ++m_extra_count;
00080   ERS_DEBUG_3("%s Source Id. = 0x%x.", 
00081               "Built (write) subdetector from contiguous memory, with",
00082               source_id());
00083 }

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:
sd The existing SubDetector fragment, as a list of nodes, pre-concatenated by the caller.

Definition at line 86 of file SubDetectorFragment.cxx.

References eformat::write::node_t::base, eformat::write::count(), ERS_DEBUG_3, eformat::write::node_t::next, eformat::write::set(), and eformat::write::node_t::size_word.

00087   : m_parent(0),
00088     m_child(0),
00089     m_last(0),
00090     m_next(0),
00091     m_extra_count(0)
00092 {
00093   //now initialize pages
00094   set(m_node[0], sd->base, 6, &m_node[1]);
00095   set(m_node[1], &sd->base[6], sd->base[5], &m_node[2]);
00096   set(m_node[2], &sd->base[6+sd->base[5]], 1, &m_extra);
00097   eformat::write::set(m_extra, &sd->base[7+sd->base[5]],
00098                       sd->size_word - sd->base[2], sd->next);
00099   m_extra_count += eformat::write::count(m_extra);
00100   ERS_DEBUG_3("%s Source Id. = 0x%x.", 
00101               "Built (write) subdetector from paged memory, with", 
00102               source_id());
00103 }

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.

References eformat::DEFAULT_STATUS, eformat::DEFAULT_VERSION, ERS_DEBUG_3, m_header, m_node, eformat::write::set(), source_id(), and eformat::SUB_DETECTOR.

00044   : m_parent(0),
00045     m_child(0),
00046     m_last(0),
00047     m_next(0),
00048     m_extra_count(0)
00049 {
00050   m_header[0] = eformat::SUB_DETECTOR; //marker
00051   m_header[1] = 8; //this header size + status size
00052   m_header[2] = 8; //this header size + status size
00053   m_header[3] = eformat::DEFAULT_VERSION; //format version
00054   m_header[4] = 0; //source identifier
00055   m_header[5] = 1; //number of status
00056   m_header[6] = 0; //number of fragment specific
00057 
00058   //now initialize pages
00059   set(m_node[0], m_header, 6, &m_node[1]);
00060   set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
00061   set(m_node[2], &m_header[6], 1, 0);
00062   ERS_DEBUG_3("%s Source Id. = 0x%x.", 
00063               "Built empty (write) subdetector from scratch, with", 
00064               SubDetectorFragment::source_id());
00065 }

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:
other The other fragment to take the meta data from.

Definition at line 106 of file SubDetectorFragment.cxx.

References ERS_DEBUG_3, and EvtCyclic3::other().

00107   : m_parent(0),
00108     m_child(0),
00109     m_last(0),
00110     m_next(0),
00111     m_extra_count(0)
00112 {
00113   *this = other;
00114   ERS_DEBUG_3("%s Source Id. = 0x%x.", 
00115               "Built (write) subdetector from copy, with", 
00116               source_id());
00117 }

virtual eformat::write::SubDetectorFragment::~SubDetectorFragment (  )  [inline, virtual]

Base destructor

Definition at line 81 of file SubDetectorFragment.h.

00081 {}


Member Function Documentation

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:
ros The ROS fragment to be appended to myself

Definition at line 160 of file SubDetectorFragment.cxx.

References ERS_DEBUG_3, eformat::write::ROSFragment::parent(), eformat::write::ROSFragment::size_word(), and eformat::write::ROSFragment::source_id().

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

00161 {
00162   ERS_DEBUG_3("%s Source Id. = 0x%x to subdetector with Source Id. = 0x%x", 
00163               "Appending ros fragment with",
00164               ros->source_id(), source_id());
00165   ros->parent(this);
00166   uint32_t old_size = m_node[0].base[1];
00167   m_node[0].base[1] += ros->size_word();
00168 
00169   //adjust `m_last' and `m_child' to point to the new last ROB
00170   if (m_last) m_last->next(ros);
00171   else m_child = ros;
00172   m_last = ros;
00173 
00174   //propagate changes to my parent
00175   if (m_parent) m_parent->size_change(old_size, m_node[0].base[1]);
00176 }

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.

References m_child, m_extra, m_extra_count, m_node, and eformat::write::node_t::next.

00188 {
00189   //the header is already concatenated by construction
00190   eformat::write::node_t* last = &m_node[2];
00191   if (m_extra_count) {
00192     last = &m_extra;
00193     while (last->next) last = last->next;
00194   }
00195   for (ROSFragment* curr = m_child; curr; 
00196        curr = const_cast<ROSFragment*>(curr->next())) {
00197     last->next = const_cast<eformat::write::node_t*>(curr->bind());
00198     while (last->next) last = last->next; //advance until end
00199   }
00200   return m_node;
00201 }

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 SubDetectorFragment.h.

References m_child.

Referenced by PackedRawDataCnvSvc::commitOutput().

00178 { return m_child; }

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 SubDetectorFragment.h.

References eformat::write::node_t::base, and m_node.

00150       { return m_node[0].base[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 SubDetectorFragment.h.

References eformat::write::node_t::base, and m_node.

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

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

Changes the minor version number of the fragment

Parameters:
s The new minor version for this header

Definition at line 121 of file SubDetectorFragment.h.

References eformat::write::node_t::base, eformat::DEFAULT_VERSION, and m_node.

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

00122       { m_node[0].base[3] = eformat::DEFAULT_VERSION | v; }

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

Sets the next sibling

Parameters:
n The sibling following this fragment

Definition at line 213 of file SubDetectorFragment.h.

References m_next.

00213 { m_next = n; }

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

Returns the next sibling

Definition at line 206 of file SubDetectorFragment.h.

References m_next.

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

00206 { return m_next; }

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

Returns the number of status wors in this fragment

Definition at line 109 of file SubDetectorFragment.h.

References eformat::write::node_t::base, and m_node.

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

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:
other The other fragment to take the meta data from.

Definition at line 121 of file SubDetectorFragment.cxx.

References ERS_DEBUG_3, EvtCyclic3::other(), eformat::write::set(), and source_id().

00122 {
00123   memcpy(reinterpret_cast<void*>(m_header),
00124          reinterpret_cast<const void*>(other.m_node[0].base), 
00125          6*sizeof(uint32_t));
00126   m_header[6] = other.m_node[2].base[0];
00127 
00128   //now initialize pages
00129   set(m_node[0], m_header, 6, &m_node[1]);
00130   set(m_node[1], other.m_node[1].base, other.m_node[1].size_word, &m_node[2]);
00131   set(m_node[2], &m_header[6], 1, 0);
00132   ERS_DEBUG_3("%s Source Id. = 0x%x.",
00133               "Copied (write) subdetector with",
00134               SubDetectorFragment::source_id());
00135   return *this;
00136 }

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.

References m_child, m_extra_count, and eformat::write::ROSFragment::next().

00179 {
00180   uint32_t retval = 3 + m_extra_count;
00181   for (const ROSFragment* curr = m_child; curr; curr = curr->next())
00182     retval += curr->page_count();
00183   return retval;
00184 }

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

This sets the parent fragment

Parameters:
fe The FullEventFragment parent fragment of this SubDetector

Definition at line 200 of file SubDetectorFragment.h.

References m_parent.

00201       { m_parent = fe; }

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

This returns the parent fragment

Definition at line 192 of file SubDetectorFragment.h.

References m_parent.

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

00193       { return m_parent; }

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:
o The old size, in 32-bit words
n The new size, in 32-bit words

Definition at line 151 of file SubDetectorFragment.cxx.

References eformat::write::node_t::base, m_node, m_parent, and eformat::write::FullEventFragment::size_change().

Referenced by eformat::write::ROSFragment::append(), eformat::write::ROSFragment::size_change(), and eformat::write::ROSFragment::status().

00152 { 
00153   uint32_t old_size = m_node[0].base[1];
00154   m_node[0].base[1] -= o;
00155   m_node[0].base[1] += n;
00156   if (m_parent) m_parent->size_change(old_size, m_node[0].base[1]);
00157 }

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 SubDetectorFragment.h.

References eformat::write::node_t::base, and m_node.

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

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

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

Returns the source identifier of this fragment

Definition at line 141 of file SubDetectorFragment.h.

References eformat::write::node_t::base, and m_node.

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

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

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

Changes the source identifier for this fragment

Parameters:
s The new value to set

Definition at line 135 of file SubDetectorFragment.h.

References eformat::write::node_t::base, and m_node.

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

00136       { m_node[0].base[4] = s; }

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 SubDetectorFragment.h.

References eformat::write::node_t::base, and m_node.

00114 { return m_node[1].base; }

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:
n How many status words the underlying SubDetectorFragment fragment supposed to have.
status A pointer to n pre-allocated words

Definition at line 139 of file SubDetectorFragment.cxx.

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

00140 {
00141   if (m_parent) m_parent->size_change(m_node[0].base[1],
00142                                       m_node[0].base[1]-m_node[0].base[5]+n);
00143   m_node[0].base[1] -= m_node[0].base[5]; //remove count from previous status
00144   m_node[0].base[2] -= m_node[0].base[5]; //remove count from previous status
00145   m_node[1].size_word = m_node[0].base[5] = n; //set new values
00146   m_node[0].base[1] += n;
00147   m_node[0].base[2] += n;
00148   m_node[1].base = const_cast<uint32_t*>(status);
00149 }


Member Data Documentation

eformat::write::ROSFragment* eformat::write::SubDetectorFragment::m_child [private]

my ROS children

Definition at line 238 of file SubDetectorFragment.h.

Referenced by bind(), first_child(), and page_count().

eformat::write::node_t eformat::write::SubDetectorFragment::m_extra [private]

Extra pages I may have.

Definition at line 241 of file SubDetectorFragment.h.

Referenced by bind(), and SubDetectorFragment().

uint32_t eformat::write::SubDetectorFragment::m_extra_count [private]

How many extra pages I have.

Definition at line 242 of file SubDetectorFragment.h.

Referenced by bind(), page_count(), and SubDetectorFragment().

uint32_t eformat::write::SubDetectorFragment::m_header[7] [private]

The SubDetector Header.

Definition at line 235 of file SubDetectorFragment.h.

Referenced by SubDetectorFragment().

eformat::write::ROSFragment* eformat::write::SubDetectorFragment::m_last [private]

my last ROS child

Definition at line 239 of file SubDetectorFragment.h.

const eformat::write::SubDetectorFragment* eformat::write::SubDetectorFragment::m_next [private]

Next sibling.

Definition at line 240 of file SubDetectorFragment.h.

Referenced by next().

eformat::write::node_t eformat::write::SubDetectorFragment::m_node[3] [private]

Node representation.

Definition at line 236 of file SubDetectorFragment.h.

Referenced by bind(), meta_size_word(), minor_version(), nstatus(), size_change(), size_word(), source_id(), status(), and SubDetectorFragment().

eformat::write::FullEventFragment* eformat::write::SubDetectorFragment::m_parent [private]

my parent

Definition at line 237 of file SubDetectorFragment.h.

Referenced by parent(), and size_change().


Generated on Tue Nov 29 23:36:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7