00001 //Dear emacs, this is -*- c++ -*- 00002 00014 #ifndef EFORMAT_FULLEVENTFRAGMENT_H 00015 #define EFORMAT_FULLEVENTFRAGMENT_H 00016 00017 #include "eformat/Header.h" 00018 #include "eformat/HeaderMarker.h" 00019 #include "eformat/SubDetectorFragment.h" 00020 #include "eformat/SizeCheckIssue.h" 00021 00022 namespace eformat { 00023 00028 template <class TPointer> 00029 class FullEventFragment : public eformat::Header<TPointer> { 00030 00031 public: //interface 00032 00039 FullEventFragment (const TPointer& it); 00040 00044 FullEventFragment () : Header<TPointer>(), m_start() {} 00045 00051 FullEventFragment (const FullEventFragment& other) 00052 : Header<TPointer>(other), m_start(other.m_start) {} 00053 00057 virtual ~FullEventFragment() {} 00058 00064 FullEventFragment& operator= (const FullEventFragment& other) 00065 { Header<TPointer>::operator=(other); m_start=other.m_start; return *this; } 00066 00072 FullEventFragment& assign (const TPointer& it); 00073 00077 virtual bool check () const; 00078 00082 bool check_tree () const; 00083 00088 inline uint32_t time() const 00089 { return m_start[0]; } 00090 00094 inline uint32_t global_id() const 00095 { return m_start[1]; } 00096 00100 inline uint32_t run_no() const 00101 { return m_start[2]; } 00102 00106 inline uint32_t lvl1_id() const 00107 { return m_start[3]; } 00108 00112 inline uint32_t lvl1_trigger_type() const 00113 { return m_start[4]; } 00114 00118 inline uint32_t lvl2_trigger_info() const 00119 { return m_start[5]; } 00120 00124 inline uint32_t nevent_filter_info () const { return 4; } 00125 00131 void event_filter_info(TPointer& it) const; 00132 00133 private: //static stuff 00134 00135 static const uint32_t NSPECIFIC; 00136 00137 private: //representation 00138 00139 TPointer m_start; 00140 00141 }; 00142 00143 } 00144 00145 template <class TPointer> 00146 const uint32_t eformat::FullEventFragment<TPointer>::NSPECIFIC = 10; 00147 00148 template <class TPointer> 00149 eformat::FullEventFragment<TPointer>::FullEventFragment (const TPointer& it) 00150 : eformat::Header<TPointer>(it, eformat::FULL_EVENT), 00151 m_start() 00152 { 00153 specific_header(m_start); 00154 } 00155 00156 template <class TPointer> eformat::FullEventFragment<TPointer>& 00157 eformat::FullEventFragment<TPointer>::assign (const TPointer& it) 00158 { 00159 ERS_DEBUG_3("Re-building FullEventFragment from pointer"); 00160 eformat::Header<TPointer>::assign(it, eformat::FULL_EVENT); 00161 specific_header(m_start); 00162 ERS_DEBUG_1("Initialized header with source identifier = %s", 00163 eformat::helper::SourceIdentifier(source_id()).human().c_str()); 00164 return *this; 00165 } 00166 00167 template <class TPointer> 00168 void eformat::FullEventFragment<TPointer>::event_filter_info(TPointer& it) 00169 const 00170 { 00171 it = m_start; 00172 it += 6; 00173 } 00174 00175 template <class TPointer> 00176 bool eformat::FullEventFragment<TPointer>::check () const 00177 { 00178 ERS_DEBUG_2("Checking for consistency of FullEventFragment"); 00179 eformat::Header<TPointer>::check(); //< first do a generic check 00180 if (this->nspecific() != NSPECIFIC) { 00181 throw EFORMAT_SIZE_CHECK(NSPECIFIC, this->nspecific()); 00182 } 00183 return true; 00184 } 00185 00186 template <class TPointer> 00187 bool eformat::FullEventFragment<TPointer>::check_tree () const 00188 { 00189 ERS_DEBUG_2("Checking recursively for consistency of FullEventFragment"); 00190 check(); // check myself 00191 uint32_t total = this->nchildren(); 00192 for (size_t i=0; i<total; ++i) { 00193 TPointer fp; 00194 child(fp, i); 00195 eformat::SubDetectorFragment<TPointer> f(fp); 00196 f.check_tree(); 00197 } 00198 return true; 00199 } 00200 00201 #endif /* EFORMAT_FULLEVENTFRAGMENT_H */