CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
ROSFragment.h
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/**
4 * @file eformat/ROSFragment.h
5 * @author <a href="mailto:[email protected]">Andre DOS ANJOS</a>
6 * $Author: maqm $
7 * $Revision: 1.2 $
8 * $Date: 2011/02/20 23:38:21 $
9 *
10 * @brief Describes the ROS fragment as defined in the Event Format note.
11 */
12
13#ifndef EFORMAT_ROSFRAGMENT_H
14#define EFORMAT_ROSFRAGMENT_H
15
16#include "eformat/Header.h"
18#include "eformat/ROBFragment.h"
20
21namespace eformat {
22
23 /**
24 * Describes how to access the contents of a subdetector fragment, as
25 * prescribed by the event format note.
26 */
27 template <class TPointer>
28 class ROSFragment : public eformat::Header<TPointer> {
29
30 public: //interface
31
32 /**
33 * To build a fragment given the containing buffer. I need to know
34 * where the fragment starts in order to do that.
35 *
36 * @param it The exact position where this fragment should start.
37 */
38 ROSFragment (const TPointer& it);
39
40 /**
41 * Builds an empty, otherwise useless ROSFragment
42 */
43 ROSFragment () : Header<TPointer>(), m_start() {}
44
45 /**
46 * Copy constructor
47 *
48 * @param other The fragment to be copied
49 */
50 ROSFragment (const ROSFragment& other)
51 : Header<TPointer>(other), m_start(other.m_start) {}
52
53 /**
54 * Destructor virtualisation
55 */
56 virtual ~ROSFragment() {}
57
58 /**
59 * Copy operator
60 *
61 * @param other The fragment to be copied
62 */
64 { Header<TPointer>::operator=(other); m_start=other.m_start; return *this; }
65
66 /**
67 * Manual re-assignment
68 *
69 * @param it The position pointing the first word of this fragment
70 */
71 ROSFragment& assign (const TPointer& it);
72
73 /**
74 * Says if the the fragment is valid. This may throw exceptions.
75 */
76 virtual bool check () const;
77
78 /**
79 * Says if the the fragment is valid. This may throw exceptions.
80 */
81 bool check_tree () const;
82
83 /**
84 * Returns the run number
85 */
86 inline uint32_t run_no() const { return m_start[0]; }
87
88 /**
89 * Returns the lvl1 identifier
90 */
91 inline uint32_t lvl1_id() const { return m_start[1]; }
92
93 /**
94 * Returns the bunch crossing identifier
95 */
96 inline uint32_t bc_id() const { return m_start[2]; }
97
98 private: //static stuff
99
100 static const uint32_t NSPECIFIC;
101
102 private: //representation
103
104 TPointer m_start; ///< my start word
105
106 };
107
108}
109
110template <class TPointer>
112
113template <class TPointer>
115 : eformat::Header<TPointer>(it, eformat::ROS),
116 m_start()
117{
118 specific_header(m_start);
119}
120
121template <class TPointer> eformat::ROSFragment<TPointer>&
123{
124 ERS_DEBUG_3("Re-building ROSFragment from pointer");
126 specific_header(m_start);
127 ERS_DEBUG_1("Initialized header with source identifier = %s",
128 eformat::helper::SourceIdentifier(source_id()).human().c_str());
129 return *this;
130}
131
132template <class TPointer>
134{
135 ERS_DEBUG_2("Checking for consistency of ROSFragment");
136 eformat::Header<TPointer>::check(); //< first do a generic check
137 if (eformat::Header<TPointer>::nspecific() != NSPECIFIC)
138 throw EFORMAT_SIZE_CHECK(NSPECIFIC, this->nspecific());
139 return true;
140}
141
142template <class TPointer>
144{
145 ERS_DEBUG_2("Checking recursively for consistency of ROSFragment");
146 check(); // check myself
147 uint32_t total = this->nchildren();
148 for (size_t i=0; i<total; ++i) {
149 TPointer fp;
150 child(fp, i);
152 f.check_tree();
153 }
154 return true;
155}
156
157#endif /* EFORMAT_ROSFRAGMENT_H */
Defines the constants used by Event Fragments.
Defines the Header entity. The definition is based on the update of ATL-DAQ-98-129,...
Defines the ROB fragment entity as described in the Event Format note.
When size checks do not match, this exception must be thrown.
#define EFORMAT_SIZE_CHECK(actual, informed)
#define ERS_DEBUG_1(...)
#define ERS_DEBUG_3(...)
#define ERS_DEBUG_2(...)
Header & operator=(const Header &other)
Definition Header.h:75
Header & assign(const TPointer &it, uint32_t match)
Definition Header.h:236
void specific_header(TPointer &it) const
Definition Header.h:172
virtual bool check() const
Definition Header.h:249
bool check_tree() const
Definition ROBFragment.h:83
virtual bool check() const
uint32_t bc_id() const
Definition ROSFragment.h:96
ROSFragment & assign(const TPointer &it)
bool check_tree() const
ROSFragment & operator=(const ROSFragment &other)
Definition ROSFragment.h:63
uint32_t run_no() const
Definition ROSFragment.h:86
ROSFragment(const ROSFragment &other)
Definition ROSFragment.h:50
uint32_t lvl1_id() const
Definition ROSFragment.h:91
@ ROS
The ROS marker.