//////////////////////////////////////////////////////////////////// /// \class RAT::DS::HeaderInfo /// /// \brief Data Structure: Event-level HeaderInfo information (Trig, eped banks) /// /// \author Gabriel Orebi Gann /// /// REVISION HISTORY:\n /// 2013/11/18 : A. Mastbaum - Update header classes, use containers\n /// 2014-02-27 : P G Jones - refactor in line with dsreview \n /// /// \details This structure holds HeaderInfo information on an event-level /// basis. It can currently hold branches for ECAHeader and /// TrigHeader information. /// /// Internally, headers are stored in STL vectors with length 0 or 1. /// Storing objects rather than pointers helps ROOT (de)serialize since /// it knows the types and sizes of DS objects. /// //////////////////////////////////////////////////////////////////// #ifndef __RAT_DS_HeaderInfo__ #define __RAT_DS_HeaderInfo__ #include #include #include #include #include namespace RAT { namespace DS { class HeaderInfo : public TObject { public: HeaderInfo() : TObject() {} /// Set the ECA header /// /// @param[in] header to set void SetECAHeader( const ECAHeader& header ) { if( ecaHeader.empty() ) ecaHeader.resize(1); ecaHeader[0] = header; } /// See if there is an ECA header /// /// @return true if there is an ECA header Bool_t ECAHeaderExists() const { return !ecaHeader.empty(); } /// Get the ECA header /// /// @return reference to the ECA header /// @throws DataNotFound error if the header does not exist ECAHeader& GetECAHeader() { if( ecaHeader.empty() ) throw DataNotFound( "HeaderInfo", "ecaHeader" ); return ecaHeader.at(0); } /// @copydoc GetECAHeader() const ECAHeader& GetECAHeader() const { if( ecaHeader.empty() ) throw DataNotFound( "HeaderInfo", "ecaHeader" ); return ecaHeader.at(0); } /// Delete the ECA header, if any void PruneECAHeader() { clear_vector( ecaHeader ); } /// Set the Trigger header /// /// @param[in] header to set void SetTrigHeader( const TrigHeader& header ) { if( trigHeader.empty() ) trigHeader.resize(1); trigHeader[0] = header; } /// See if there is an Trigger header /// /// @return true if there is an Trigger header Bool_t TrigHeaderExists() const { return !trigHeader.empty(); } /// Get the Trigger header /// /// @return reference to the Trigger header /// @throws DataNotFound error if the header does not exist TrigHeader& GetTrigHeader() { if( trigHeader.empty() ) throw DataNotFound( "HeaderInfo", "trigHeader" ); return trigHeader.at(0); } /// @copydoc GetTrigHeader() const TrigHeader& GetTrigrHeader() const { if( trigHeader.empty() ) throw DataNotFound( "HeaderInfo", "trigHeader" ); return trigHeader.at(0); } /// Delete the Trigger header, if any void PruneTrigHeader() { clear_vector( trigHeader ); } // This ROOT macro adds dictionary methods to this class. // The number should be incremented whenever this class's members are changed. // It assumes this class has no virtual methods, use ClassDef if change this. ClassDefNV(HeaderInfo, 4); protected: std::vector ecaHeader; ///< The ECA header, should only be 1 std::vector trigHeader; ///< The trigger header, should only be 1 }; } // namespace DS } // namespace RAT #endif // __RAT_DS_HeaderInfo__