diff --git a/Rich/RichFutureDAQ/include/RichFutureDAQ/EncodeTel40Data.h b/Rich/RichFutureDAQ/include/RichFutureDAQ/EncodeTel40Data.h index 32815b94d13f5f1c35148154ffa460e6eee8dc88..122ef7436d0468a9a9b8ffca2eef8ccba182682b 100644 --- a/Rich/RichFutureDAQ/include/RichFutureDAQ/EncodeTel40Data.h +++ b/Rich/RichFutureDAQ/include/RichFutureDAQ/EncodeTel40Data.h @@ -22,6 +22,7 @@ #include <vector> // RICH Utils +#include "RichFutureUtils/RichMessaging.h" #include "RichUtils/RichDAQDefinitions.h" // local @@ -36,8 +37,9 @@ #include "boost/format/group.hpp" #include "boost/range/adaptor/reversed.hpp" -// Gaudi -#include "GaudiKernel/CommonMessaging.h" +namespace Gaudi { + class Algorithm; +} namespace Rich::Future::DAQ { @@ -49,8 +51,8 @@ namespace Rich::Future::DAQ { public: /// Constructor from RICH detector elements - EncodeTel40( const Tel40CableMapping& tel40Maps, // - CommonMessagingBase const* parent = nullptr ); + EncodeTel40( const Tel40CableMapping& tel40Maps, // + const Gaudi::Algorithm* parent = nullptr ); public: /// 8-bit data words for the two halves of each Tel40 data frame @@ -147,24 +149,23 @@ namespace Rich::Future::DAQ { /// Add data to the storage void add( const Rich::DAQ::SourceID sID, // const Rich::DAQ::Tel40Connector conn, // - const Rich::DAQ::FrameBitIndex bit ) { - assert( m_tel40Data.find( sID ) != m_tel40Data.end() ); - assert( m_tel40Data[sID].find( conn ) != m_tel40Data[sID].end() ); - auto& frame = m_tel40Data[sID][conn]; - m_parent->verbose() << "Setting SourceID=" << sID << " Con=" << conn << " Bit=" << bit << endmsg; - m_parent->verbose() << " Before " << frame << endmsg; - frame.add( bit ); - m_parent->verbose() << " After " << frame << endmsg; - } + const Rich::DAQ::FrameBitIndex bit ); /// Fill RawBanks into a RawEvent void fill( LHCb::RawEvent& rawEv, const std::uint8_t version ); + private: + /// Define the messenger entity + inline auto messenger() const noexcept { + assert( m_parent ); + return m_parent; + } + private: // data /// pointer to parent - CommonMessagingBase const* m_parent = nullptr; + const Gaudi::Algorithm* m_parent = nullptr; /// AllTel40 data storage AllTel40 m_tel40Data; diff --git a/Rich/RichFutureDAQ/src/lib/EncodeTel40Data.cpp b/Rich/RichFutureDAQ/src/lib/EncodeTel40Data.cpp index 39c8f282c090276390ec35a1b7ca385d5c07275c..9f18b6b00491fbfd1e9891ca68a4fdf7b0fcc6bd 100644 --- a/Rich/RichFutureDAQ/src/lib/EncodeTel40Data.cpp +++ b/Rich/RichFutureDAQ/src/lib/EncodeTel40Data.cpp @@ -14,10 +14,16 @@ #include "RichFutureDAQ/RichPackedFrameSizes.h" // Gaudi +#include "Gaudi/Algorithm.h" #include "GaudiKernel/Kernel.h" using namespace Rich::Future::DAQ; +#define debug( ... ) \ + if ( messenger() ) { ri_debug( __VA_ARGS__ ); } +#define verbo( ... ) \ + if ( messenger() ) { ri_verbo( __VA_ARGS__ ); } + namespace { /// Set a given bit on @@ -34,18 +40,27 @@ namespace { } // namespace -EncodeTel40::EncodeTel40( const Tel40CableMapping& tel40Maps, // - CommonMessagingBase const* parent ) +void EncodeTel40::add( const Rich::DAQ::SourceID sID, // + const Rich::DAQ::Tel40Connector conn, // + const Rich::DAQ::FrameBitIndex bit ) { + assert( m_tel40Data.find( sID ) != m_tel40Data.end() ); + assert( m_tel40Data[sID].find( conn ) != m_tel40Data[sID].end() ); + auto& frame = m_tel40Data[sID][conn]; + verbo( "Setting SourceID=", sID, " Con=", conn, " Bit=", bit, endmsg ); + verbo( " Before ", frame, endmsg ); + frame.add( bit ); + verbo( " After ", frame, endmsg ); +} + +EncodeTel40::EncodeTel40( const Tel40CableMapping& tel40Maps, // + const Gaudi::Algorithm* parent ) : m_parent( parent ) { // init. the data struture to fill // get the list of active Tel40s and the links for each const auto& links = tel40Maps.linksPerSourceID(); // loop over tel40's for ( const auto& tel40 : links ) { - if ( m_parent ) { - m_parent->verbose() << "Initialising " << tel40.second.size() << " (active+inactive) links for SourceID " - << tel40.first << endmsg; - } + verbo( "Initialising ", tel40.second.size(), " (active+inactive) links for SourceID ", tel40.first, endmsg ); // tel40 connection for this link auto& connData = tel40Maps.tel40Data( tel40.first ); // make entry for this Tel40 @@ -55,7 +70,7 @@ EncodeTel40::EncodeTel40( const Tel40CableMapping& tel40Maps, // assert( (std::size_t)c.data() < connData.size() ); auto& l = t[c]; l.setActive( connData[c.data()].isActive ); - if ( m_parent ) { m_parent->verbose() << " -> Link " << c << connData[c.data()] << endmsg; } + verbo( " -> Link ", c, connData[c.data()], endmsg ); } } } @@ -123,7 +138,7 @@ void EncodeTel40::fill( LHCb::RawEvent& rawEv, const std::uint8_t version ) { // Loop over the Tel40s filled for ( const auto& tel40 : m_tel40Data ) { - if ( m_parent ) { m_parent->debug() << "Creating RawBank for Source ID = " << tel40.first << endmsg; } + debug( "Creating RawBank for Source ID = ", tel40.first, endmsg ); /// container for packed frame sizes std::vector<PackedFrameSizes> packedFrameSizes; @@ -134,7 +149,7 @@ void EncodeTel40::fill( LHCb::RawEvent& rawEv, const std::uint8_t version ) { // loop over connections for this Tel40 and collect frame sizes std::uint8_t word = 1; - if ( m_parent ) { m_parent->debug() << " -> Found " << tel40.second.size() << " connections" << endmsg; } + debug( " -> Found ", tel40.second.size(), " connections", endmsg ); for ( const auto& con : tel40.second ) { // Number of bytes in the frame payload const auto bSize = con.second.nBytes(); @@ -149,7 +164,7 @@ void EncodeTel40::fill( LHCb::RawEvent& rawEv, const std::uint8_t version ) { word = 1; // Next time through start a new word. } } else { - if ( m_parent ) { m_parent->verbose() << " -> Skipping inactive link " << con.first << endmsg; } + verbo( " -> Skipping inactive link ", con.first, endmsg ); assert( 0 == bSize ); } } @@ -160,24 +175,22 @@ void EncodeTel40::fill( LHCb::RawEvent& rawEv, const std::uint8_t version ) { // Pipe the data size header words to the RawBank for ( const auto h : packedFrameSizes ) { - if ( m_parent ) { m_parent->verbose() << " -> Size Header " << h << endmsg; } + verbo( " -> Size Header ", h, endmsg ); payload.emplace_back( h.data() ); } const auto nHeaderWords = payload.size(); - m_parent->verbose() << " -> Added " << nHeaderWords << " packed size header words" << endmsg; + verbo( " -> Added ", nHeaderWords, " packed size header words", endmsg ); // now save the rest of the payload for each connector for ( const auto& con : tel40.second ) { - if ( m_parent ) { - // zero pad its to two digits... - boost::format twoDigits( "%u" ); - twoDigits.modify_item( 1, boost::io::group( std::setw( 2 ), std::setfill( '0' ) ) ); - m_parent->verbose() << " -> Con:" << twoDigits % (int)con.first.data() << " " << con.second << endmsg; - } + // zero pad its too two digits... + boost::format twoDigits( "%u" ); + twoDigits.modify_item( 1, boost::io::group( std::setw( 2 ), std::setfill( '0' ) ) ); + verbo( " -> Con:", twoDigits % (int)con.first.data(), " ", con.second, endmsg ); // save to payload con.second.appendTo( payload ); } - m_parent->verbose() << " -> Added " << payload.size() - nHeaderWords << " payload words" << endmsg; + verbo( " -> Added ", payload.size() - nHeaderWords, " payload words", endmsg ); // finally save to RawEvent rawEv.addBank( tel40.first.data(), LHCb::RawBank::Rich, version, std::move( payload ) );