BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/eformat/include/eformat/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:Andre.dos.Anjos@cern.ch">Andre DOS ANJOS</a>
6 * $Author: maqm $
7 * $Revision: 1.3 $
8 * $Date: 2022/01/06 21:15:37 $
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"
17#include "eformat/HeaderMarker.h"
18#include "eformat/ROBFragment.h"
19#include "eformat/SizeCheckIssue.h"
20#include <zlib.h>
21
22namespace eformat {
23
24 /**
25 * Describes how to access the contents of a subdetector fragment, as
26 * prescribed by the event format note.
27 */
28 template <class TPointer> class ROSFragment : public eformat::Header<TPointer> {
29
30 public: // interface
31 /**
32 * To build a fragment given the containing buffer. I need to know
33 * where the fragment starts in order to do that.
34 *
35 * @param it The exact position where this fragment should start.
36 */
37 ROSFragment( const TPointer& it );
38
39 /**
40 * Builds an empty, otherwise useless ROSFragment
41 */
42 ROSFragment() : Header<TPointer>(), m_start() {}
43
44 /**
45 * Copy constructor
46 *
47 * @param other The fragment to be copied
48 */
49 ROSFragment( const ROSFragment& other )
50 : Header<TPointer>( other ), m_start( other.m_start ) {}
51
52 /**
53 * Destructor virtualisation
54 */
55 virtual ~ROSFragment() {}
56
57 /**
58 * Copy operator
59 *
60 * @param other The fragment to be copied
61 */
64 m_start = other.m_start;
65 return *this;
66 }
67
68 /**
69 * Manual re-assignment
70 *
71 * @param it The position pointing the first word of this fragment
72 */
73 ROSFragment& assign( const TPointer& it );
74
75 /**
76 * Says if the the fragment is valid. This may throw exceptions.
77 */
78 virtual bool check() const;
79
80 /**
81 * Says if the the fragment is valid. This may throw exceptions.
82 */
83 bool check_tree() const;
84
85 /**
86 * Returns the run number
87 */
88 inline uint32_t run_no() const { return m_start[0]; }
89
90 /**
91 * Returns the lvl1 identifier
92 */
93 inline uint32_t lvl1_id() const { return m_start[1]; }
94
95 /**
96 * Returns the bunch crossing identifier
97 */
98 inline uint32_t bc_id() const { return m_start[2]; }
99
100 private: // static stuff
101 static const uint32_t NSPECIFIC;
102
103 private: // representation
104 TPointer m_start; ///< my start word
105 };
106
107} // namespace eformat
108
109template <class TPointer> const uint32_t eformat::ROSFragment<TPointer>::NSPECIFIC = 3;
110
111template <class TPointer>
113 : eformat::Header<TPointer>( it, eformat::ROS ), m_start() {
115}
116
117template <class TPointer>
119 ERS_DEBUG_3( "Re-building ROSFragment from pointer" );
122 ERS_DEBUG_1( "Initialized header with source identifier = %s",
123 eformat::helper::SourceIdentifier( source_id() ).human().c_str() );
124 return *this;
125}
126
127template <class TPointer> bool eformat::ROSFragment<TPointer>::check() const {
128 ERS_DEBUG_2( "Checking for consistency of ROSFragment" );
129 eformat::Header<TPointer>::check(); //< first do a generic check
130 if ( eformat::Header<TPointer>::nspecific() != NSPECIFIC )
131 throw EFORMAT_SIZE_CHECK( NSPECIFIC, this->nspecific() );
132 return true;
133}
134
135template <class TPointer> bool eformat::ROSFragment<TPointer>::check_tree() const {
136 ERS_DEBUG_2( "Checking recursively for consistency of ROSFragment" );
137 check(); // check myself
138 uint32_t total = this->nchildren();
139 for ( size_t i = 0; i < total; ++i )
140 {
141 TPointer fp;
144 f.check_tree();
145 }
146 return true;
147}
148
149#endif /* EFORMAT_ROSFRAGMENT_H */
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
#define EFORMAT_SIZE_CHECK(actual, informed)
#define ERS_DEBUG_1(...)
#define ERS_DEBUG_3(...)
#define ERS_DEBUG_2(...)
Header & operator=(const Header &other)
Header(const TPointer &it, uint32_t match)
Header & assign(const TPointer &it, uint32_t match)
void specific_header(TPointer &it) const
virtual void child(TPointer &p, size_t n) const
ROSFragment & assign(const TPointer &it)
ROSFragment & operator=(const ROSFragment &other)