diff --git a/Event/FaserByteStreamCnvSvc/CMakeLists.txt b/Event/FaserByteStreamCnvSvc/CMakeLists.txt index 80fae1ae449f093bc0e50a7d5ea886cfd415d4c7..5b5d18d6b26d0db6f2e7c442112572b1e6c3b52a 100644 --- a/Event/FaserByteStreamCnvSvc/CMakeLists.txt +++ b/Event/FaserByteStreamCnvSvc/CMakeLists.txt @@ -9,8 +9,8 @@ atlas_subdir( FaserByteStreamCnvSvc ) atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps - Event/ByteStreamCnvSvcBase #Event/ByteStreamData + Event/FaserEventStorage GaudiKernel PRIVATE Control/AthenaKernel @@ -20,10 +20,10 @@ atlas_depends_on_subdirs( Database/APR/FileCatalog Database/AthenaPOOL/AthenaPoolUtilities Database/PersistentDataModel - Event/FaserEventStorage Event/EventInfo Event/xAOD/xAODEventInfo Event/xAOD/xAODTrigger + Event/FaserByteStreamCnvSvcBase EventFormats Logging) @@ -38,11 +38,12 @@ atlas_add_library( FaserByteStreamCnvSvcLib FaserByteStreamCnvSvc/*.h src/*.h src/*.cxx PUBLIC_HEADERS FaserByteStreamCnvSvc PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} - LINK_LIBRARIES AthenaBaseComps ByteStreamData GaudiKernel - ByteStreamCnvSvcLib ByteStreamCnvSvcBaseLib StoreGateLib rt + LINK_LIBRARIES AthenaBaseComps FaserEventStorageLib GaudiKernel + StoreGateLib rt PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} AthenaKernel SGTools CollectionBase FileCatalog - AthenaPoolUtilities PersistentDataModel FaserEventStorageLib EventInfo + AthenaPoolUtilities PersistentDataModel EventInfo + FaserByteStreamCnvSvcBaseLib xAODEventInfo xAODTrigger) atlas_add_component( FaserByteStreamCnvSvc diff --git a/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/ByteStreamInputSvc.h b/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/ByteStreamInputSvc.h deleted file mode 100644 index 2d92e6523abf8bb76441fe830d0e72a0fab10833..0000000000000000000000000000000000000000 --- a/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/ByteStreamInputSvc.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef BYTESTREAMCNVSVC_BYTESTREAMINPUTSVC_H -#define BYTESTREAMCNVSVC_BYTESTREAMINPUTSVC_H - -/** @file ByteStreamInputSvc.h - * @brief This file contains the class definition for the ByteStreamInputSvc class. - * @author Peter van Gemmeren <gemmeren@anl.gov> - * $Id: ByteStreamInputSvc.h,v 1.51 2009-03-03 16:03:22 gemmeren Exp $ - **/ - -#include <exception> -#include "AthenaBaseComps/AthService.h" -#include "EventFormats/DAQFormats.hpp" - -//#include "ByteStreamData/RawEvent.h" -//#include "ByteStreamCnvSvc/ByteStreamExceptions.h" - - -/** @class ByteStreamInputSvc - * @brief This class provides the base class to services to read bytestream data. - * The concrete class can provide Raw event from a file, transient store, or through network. - **/ -class ByteStreamInputSvc : public ::AthService { - public: - /// constructor - ByteStreamInputSvc(const std::string& name, ISvcLocator* svcloc); - /// destructor - virtual ~ByteStreamInputSvc(void); - - /// Retrieve interface ID - static const InterfaceID& interfaceID(); - - /// virtual method for advance to the next event - virtual const DAQFormats::EventFull* nextEvent() = 0; - virtual const DAQFormats::EventFull* previousEvent() = 0; - virtual void setEvent(void* /*data*/, unsigned int /*status*/) {} - /// virtual method for accessing the current event - virtual const DAQFormats::EventFull* currentEvent() const = 0; - /// virtual method for accessing the current event status - virtual unsigned int currentEventStatus() const; - virtual std::pair<long,std::string> getBlockIterator(const std::string /* file */); - virtual void closeBlockIterator(bool); - virtual bool ready() const; - virtual StatusCode generateDataHeader(); - virtual long positionInBlock(); - virtual void validateEvent(); -}; - -inline const InterfaceID& ByteStreamInputSvc::interfaceID() { - /// Declaration of the interface ID ( interface id, major version, minor version) - static const InterfaceID IID_ByteStreamInputSvc("ByteStreamInputSvc", 1, 0); - return(IID_ByteStreamInputSvc); -} - -inline unsigned int ByteStreamInputSvc::currentEventStatus() const { - return(0); -} - -// Virtual methods needed for file input -inline std::pair<long,std::string> ByteStreamInputSvc::getBlockIterator(const std::string /* file */) {return std::make_pair(-1,"GUID");} -inline void ByteStreamInputSvc::closeBlockIterator(bool) {} -inline bool ByteStreamInputSvc::ready() const {return false;} -inline StatusCode ByteStreamInputSvc::generateDataHeader() {return StatusCode::SUCCESS;} -inline long ByteStreamInputSvc::positionInBlock() {return -1;} -inline void ByteStreamInputSvc::validateEvent() {} -#endif diff --git a/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc.h b/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc.h index 1258f3869bb4f41f1a061a6e468d4709801bb6e6..f3035103b1222a6372263d3d34afbff5e78d16ae 100644 --- a/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc.h +++ b/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc.h @@ -5,7 +5,7 @@ #ifndef FASERBYTESTREAMCNVSVC_FASERBYTESTREAMCNVSVC_H #define FASERBYTESTREAMCNVSVC_FASERBYTESTREAMCNVSVC_H -#include "ByteStreamCnvSvcBase/ByteStreamCnvSvcBase.h" +#include "FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase.h" #include "StoreGate/StoreGateSvc.h" #include "GaudiKernel/ServiceHandle.h" @@ -28,7 +28,7 @@ class FullEventAssemblerBase; method through ByteStreamOutputSvc. */ -class FaserByteStreamCnvSvc : public ByteStreamCnvSvcBase/*, virtual public IService*/ { +class FaserByteStreamCnvSvc : public FaserByteStreamCnvSvcBase/*, virtual public IService*/ { public: /// Standard Constructor diff --git a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.h b/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/FaserByteStreamInputSvc.h similarity index 85% rename from Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.h rename to Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/FaserByteStreamInputSvc.h index 00efecd0ad4c90e40901a544f05409e883876a1c..8428beedbcf2a0a085343d85e3ec0befb140fbae 100644 --- a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.h +++ b/Event/FaserByteStreamCnvSvc/FaserByteStreamCnvSvc/FaserByteStreamInputSvc.h @@ -13,31 +13,24 @@ // Originally copied from ByteStreamEventStorageInputSvc // Include files. -#include "FaserByteStreamCnvSvc/ByteStreamInputSvc.h" -#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" +#include "FaserByteStreamCnvSvcBase/IFaserROBDataProviderSvc.h" #include "AthenaKernel/SlotSpecificObj.h" #include "FaserEventStorage/DataReader.h" -// Do I want to try to update this? It looks like it is only used -// here and in the detector-specific code. Lets try without it. -//#include "ByteStreamData/RawEvent.h" - // FrameWork includes +#include "AthenaBaseComps/AthService.h" #include "GaudiKernel/ServiceHandle.h" -//#include "EventFormats/DAQFormats.hpp" +#include "EventFormats/DAQFormats.hpp" +#include <exception> -//typedef DAQFormats::EventFull RawEvent; -namespace DAQFormats { - class EventFull; -} class StoreGateSvc; class DataHeaderElement; /** @class ByteStreamFaserInputSvc * @brief This class is the ByteStreamInputSvc for reading events written by Faser. **/ -class FaserByteStreamInputSvc : public ByteStreamInputSvc { +class FaserByteStreamInputSvc : public ::AthService { public: /// Constructors: @@ -46,10 +39,12 @@ public: /// Destructor. virtual ~FaserByteStreamInputSvc(); + /// Retrieve interface ID + static const InterfaceID& interfaceID(); + /// Required of all Gaudi Services virtual StatusCode initialize(); virtual StatusCode stop(); - /// Required of all Gaudi Services virtual StatusCode finalize(); /// Required of all Gaudi services: see Gaudi documentation for details @@ -59,13 +54,12 @@ public: virtual const DAQFormats::EventFull* currentEvent() const; virtual const DAQFormats::EventFull* nextEvent(); //!< ++, new virtual const DAQFormats::EventFull* previousEvent(); //!< --, old - virtual void setEvent(void* data, unsigned int eventStatus); + virtual void setEvent(void* data, unsigned int eventStatus); /// Return the current event status virtual unsigned int currentEventStatus() const; virtual void validateEvent(); - virtual long positionInBlock(); virtual std::pair<long,std::string> getBlockIterator(const std::string fileName); void closeBlockIterator(bool clearMetadata=true); @@ -78,7 +72,6 @@ private: // data struct EventCache { std::unique_ptr<DAQFormats::EventFull> rawEvent = NULL; - //DAQFormats::EventFull* rawEvent = 0; //!< current event unsigned int eventStatus = 0; //!< check_tree() status of the current event long long int eventOffset = 0; //!< event offset within a file, can be -1 void releaseEvent(); //!< deletes event @@ -98,7 +91,7 @@ private: // data private: // properties ServiceHandle<StoreGateSvc> m_storeGate; //!< StoreGateSvc //ServiceHandle<StoreGateSvc> m_inputMetadata; //!< StoreGateSvc - ServiceHandle<IROBDataProviderSvc> m_robProvider; + ServiceHandle<IFaserROBDataProviderSvc> m_robProvider; Gaudi::Property<bool> m_sequential; //!< enable sequential reading. diff --git a/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamAuxCnv.cxx b/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamAuxCnv.cxx index a8ec0f18500cd866c00de9b2dca20d15a3dd0bb2..a0998bda45d428b4aaada929afea0859c7c6013d 100644 --- a/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamAuxCnv.cxx +++ b/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamAuxCnv.cxx @@ -4,10 +4,10 @@ #include "EventInfoByteStreamAuxCnv.h" #include "FaserByteStreamCnvSvc/FaserByteStreamCnvSvc.h" -#include "FaserByteStreamCnvSvc/ByteStreamInputSvc.h" +//#include "FaserByteStreamCnvSvc/FaserByteStreamInputSvc.h" -#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" -#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" +#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" +#include "FaserByteStreamCnvSvcBase/IFaserROBDataProviderSvc.h" /* #include "ByteStreamData/RawEvent.h" @@ -53,7 +53,7 @@ const CLID& EventInfoByteStreamAuxCnv::classID() long EventInfoByteStreamAuxCnv::storageType() { - return ByteStreamAddress::storageType(); + return FaserByteStreamAddress::storageType(); } StatusCode EventInfoByteStreamAuxCnv::initialize() @@ -78,7 +78,7 @@ StatusCode EventInfoByteStreamAuxCnv::initialize() return StatusCode::FAILURE; } - //CHECK(m_robDataProvider.retrieve()); + CHECK(m_robDataProvider.retrieve()); //CHECK(m_mdSvc.retrieve()); SimpleProperty<bool> propIsSimulation("IsSimulation", m_isSimulation); @@ -133,10 +133,10 @@ StatusCode EventInfoByteStreamAuxCnv::createObj(IOpaqueAddress* pAddr, DataObjec ATH_MSG_DEBUG("EventInfoByteStreamAuxCnv::createObj() called"); - ByteStreamAddress *pRE_Addr{nullptr}; - pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr); + FaserByteStreamAddress *pRE_Addr{nullptr}; + pRE_Addr = dynamic_cast<FaserByteStreamAddress*>(pAddr); if (!pRE_Addr) { - ATH_MSG_ERROR("Cannot cast to ByteStreamAddress "); + ATH_MSG_ERROR("Cannot cast to FaserByteStreamAddress "); return StatusCode::FAILURE; } diff --git a/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamAuxCnv.h b/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamAuxCnv.h index 90fb3113ea6c384fb2788215dcf890e433c747f4..a43006e1b9367feef0261010cfac0a7ea66640e1 100644 --- a/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamAuxCnv.h +++ b/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamAuxCnv.h @@ -20,7 +20,7 @@ #include "AthenaBaseComps/AthMessaging.h" class FaserByteStreamCnvSvc; -class IROBDataProviderSvc; +class IFaserROBDataProviderSvc; class StoreGateSvc; // Abstract factory to create the converter @@ -48,7 +48,7 @@ class EventInfoByteStreamAuxCnv : public Converter, public AthMessaging private: const char* ascTime(unsigned int t); //!< convert timestamp to ascii time. FaserByteStreamCnvSvc* m_ByteStreamCnvSvc; //!< pointer to BS CnvSvc - ServiceHandle<IROBDataProviderSvc> m_robDataProvider; //!< RODDataProviderSvc handle + ServiceHandle<IFaserROBDataProviderSvc> m_robDataProvider; //!< RODDataProviderSvc handle //ServiceHandle<StoreGateSvc> m_mdSvc; //!< TDS handle // flags for EventType diff --git a/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamxAODCnv.cxx b/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamxAODCnv.cxx index 8fd407d8fa04ae9bd3e6b8549cff386bb9b1461e..f9dcfe9df514304fe778491a141a33b58980b6ea 100644 --- a/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamxAODCnv.cxx +++ b/Event/FaserByteStreamCnvSvc/src/EventInfoByteStreamxAODCnv.cxx @@ -3,7 +3,7 @@ */ #include "EventInfoByteStreamxAODCnv.h" -#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" #include "AthenaKernel/errorcheck.h" #include "GaudiKernel/MsgStream.h" @@ -29,7 +29,7 @@ const CLID& EventInfoByteStreamxAODCnv::classID() long EventInfoByteStreamxAODCnv::storageType() { - return ByteStreamAddress::storageType(); + return FaserByteStreamAddress::storageType(); } StatusCode EventInfoByteStreamxAODCnv::initialize() @@ -52,10 +52,10 @@ StatusCode EventInfoByteStreamxAODCnv::finalize() StatusCode EventInfoByteStreamxAODCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj) { - ByteStreamAddress *pRE_Addr{nullptr}; - pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr); + FaserByteStreamAddress *pRE_Addr{nullptr}; + pRE_Addr = dynamic_cast<FaserByteStreamAddress*>(pAddr); if (!pRE_Addr) { - ATH_MSG_ERROR("Cannot cast to ByteStreamAddress "); + ATH_MSG_ERROR("Cannot cast to FaserByteStreamAddress "); return StatusCode::FAILURE; } diff --git a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamCnvSvc.cxx b/Event/FaserByteStreamCnvSvc/src/FaserByteStreamCnvSvc.cxx index 437f0f4ca7ef0a1aa432ec90d8cd21442704449d..a28f22ff891726420500032f2ab99279d0563f98 100644 --- a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamCnvSvc.cxx +++ b/Event/FaserByteStreamCnvSvc/src/FaserByteStreamCnvSvc.cxx @@ -4,8 +4,8 @@ #include "FaserByteStreamCnvSvc/FaserByteStreamCnvSvc.h" //#include "ByteStreamCnvSvc/ByteStreamOutputSvc.h" -#include "ByteStreamCnvSvcBase/FullEventAssembler.h" -#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +//#include "ByteStreamCnvSvcBase/FullEventAssembler.h" +//#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" #include "StoreGate/StoreGate.h" #include "xAODEventInfo/EventInfo.h" @@ -22,7 +22,7 @@ /// Standard constructor FaserByteStreamCnvSvc::FaserByteStreamCnvSvc(const std::string& name, ISvcLocator* pSvcLocator) - : ByteStreamCnvSvcBase(name, pSvcLocator), + : FaserByteStreamCnvSvcBase(name, pSvcLocator), m_evtStore ("StoreGateSvc", name) { declareProperty("ByteStreamOutputSvc", m_ioSvcName); @@ -41,7 +41,7 @@ FaserByteStreamCnvSvc::~FaserByteStreamCnvSvc() { /// Initialize the service. StatusCode FaserByteStreamCnvSvc::initialize() { - if (!ByteStreamCnvSvcBase::initialize().isSuccess()) { + if (!FaserByteStreamCnvSvcBase::initialize().isSuccess()) { ATH_MSG_FATAL("FaserByteStreamCnvSvcBase::initialize() failed"); return(StatusCode::FAILURE); } @@ -94,7 +94,7 @@ StatusCode FaserByteStreamCnvSvc::initialize() { } StatusCode FaserByteStreamCnvSvc::finalize() { - return(ByteStreamCnvSvcBase::finalize()); + return(FaserByteStreamCnvSvcBase::finalize()); } StatusCode FaserByteStreamCnvSvc::connectOutput(const std::string& t, const std::string& /*mode*/) { diff --git a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx b/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx index 593bd1891c224ff6f9a16c32da062913b9adf041..8cf7385933093789970bd5434fa778bf65988756 100644 --- a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx +++ b/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx @@ -2,11 +2,12 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -#include "FaserByteStreamInputSvc.h" +#include "FaserByteStreamCnvSvc/FaserByteStreamInputSvc.h" + #include "DumpFrags.h" #include "ByteStreamData/ByteStreamMetadataContainer.h" -#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" #include "FaserEventStorage/pickFaserDataReader.h" #include "GaudiKernel/IJobOptionsSvc.h" @@ -39,7 +40,7 @@ using DAQFormats::EventFull; // Constructor. FaserByteStreamInputSvc::FaserByteStreamInputSvc( const std::string& name, ISvcLocator* svcloc) - : ByteStreamInputSvc(name, svcloc) + : AthService(name, svcloc) , m_readerMutex() , m_eventsCache() , m_reader() @@ -49,7 +50,7 @@ FaserByteStreamInputSvc::FaserByteStreamInputSvc( , m_fileGUID("") , m_storeGate ("StoreGateSvc", name) //, m_inputMetadata("StoreGateSvc/InputMetaDataStore", name) - , m_robProvider ("ROBDataProviderSvc", name) + , m_robProvider ("FaserROBDataProviderSvc", name) , m_sequential (this, "EnableSequential", false, "") , m_dump (this, "DumpFlag", false, "Dump fragments") , m_wait (this, "WaitSecs", 0., "Seconds to wait if input is in wait state") @@ -69,7 +70,7 @@ FaserByteStreamInputSvc::~FaserByteStreamInputSvc() { StatusCode FaserByteStreamInputSvc::initialize() { ATH_MSG_INFO("Initializing " << name() << " - package version " << PACKAGE_VERSION); - ATH_CHECK(ByteStreamInputSvc::initialize()); + ATH_CHECK(FaserByteStreamInputSvc::initialize()); //ATH_CHECK(m_inputMetadata.retrieve()); ATH_CHECK(m_storeGate.retrieve()); ATH_CHECK(m_robProvider.retrieve()); @@ -78,7 +79,7 @@ StatusCode FaserByteStreamInputSvc::initialize() { } //________________________________________________________________________________ StatusCode FaserByteStreamInputSvc::stop() { - ATH_MSG_DEBUG("Calling ByteStreamInputSvc::stop()"); + ATH_MSG_DEBUG("Calling FaserByteStreamInputSvc::stop()"); // close moved to EventSelector for explicit coupling with incident return(StatusCode::SUCCESS); } @@ -89,7 +90,7 @@ StatusCode FaserByteStreamInputSvc::finalize() { ATH_CHECK(m_robProvider.release()); //ATH_CHECK(m_inputMetadata.release()); - return(ByteStreamInputSvc::finalize()); + return(FaserByteStreamInputSvc::finalize()); } //------------------------------------------------------------------------------ long FaserByteStreamInputSvc::positionInBlock() @@ -161,7 +162,7 @@ const EventFull* FaserByteStreamInputSvc::nextEvent() { // Set it for the data provider ATH_MSG_DEBUG( "call robProvider->setNextEvent "); - m_robProvider->setNextEvent(context, reinterpret_cast<const RawEvent*>(cache->rawEvent.get()) ); + m_robProvider->setNextEvent(context, cache->rawEvent.get() ); m_robProvider->setEventStatus(context, cache->eventStatus ); // dump @@ -264,7 +265,7 @@ StatusCode FaserByteStreamInputSvc::generateDataHeader() key = m_eventInfoKey.value(); ATH_CHECK(deleteEntry<xAOD::EventInfo>(key)); // Now add ref to xAOD::EventInfo - std::unique_ptr<IOpaqueAddress> iopx = std::make_unique<ByteStreamAddress>( + std::unique_ptr<IOpaqueAddress> iopx = std::make_unique<FaserByteStreamAddress>( ClassID_traits<xAOD::EventInfo>::ID(), key, ""); ATH_CHECK(m_storeGate->recordAddress(key, iopx.release())); const SG::DataProxy* ptmpx = m_storeGate->transientProxy( @@ -278,7 +279,7 @@ StatusCode FaserByteStreamInputSvc::generateDataHeader() key = m_eventInfoKey.value() + "Aux."; ATH_CHECK(deleteEntry<xAOD::EventAuxInfo>(key)); // Now add ref to xAOD::EventAuxInfo - std::unique_ptr<IOpaqueAddress> iopaux = std::make_unique<ByteStreamAddress>( + std::unique_ptr<IOpaqueAddress> iopaux = std::make_unique<FaserByteStreamAddress>( ClassID_traits<xAOD::EventAuxInfo>::ID(), key, ""); ATH_CHECK(m_storeGate->recordAddress(key, iopaux.release())); const SG::DataProxy* ptmpaux = m_storeGate->transientProxy( @@ -418,8 +419,8 @@ void FaserByteStreamInputSvc::setEvent( const EventContext& context, void* data, cache->eventStatus = eventStatus; // Set it for the data provider - m_robProvider->setNextEvent(context, reinterpret_cast<const RawEvent*>(cache->rawEvent.get()) ); - m_robProvider->setEventStatus(context, cache->eventStatus ); + m_robProvider->setNextEvent(context, cache->rawEvent.get()); + m_robProvider->setEventStatus(context, cache->eventStatus); // Build a DH for use by other components StatusCode rec_sg = generateDataHeader(); @@ -427,6 +428,13 @@ void FaserByteStreamInputSvc::setEvent( const EventContext& context, void* data, ATH_MSG_ERROR("Fail to record BS DataHeader in StoreGate. Skipping events?! " << rec_sg); } } + +//__________________________________________________________________________ +inline const InterfaceID& FaserByteStreamInputSvc::interfaceID() { + /// Declaration of the interface ID ( interface id, major version, minor version) + static const InterfaceID IID_ByteStreamInputSvc("ByteStreamInputSvc", 1, 0); + return(IID_ByteStreamInputSvc); +} //__________________________________________________________________________ const EventFull* FaserByteStreamInputSvc::currentEvent() const { const EventContext context{ Gaudi::Hive::currentContext() }; @@ -439,8 +447,8 @@ unsigned int FaserByteStreamInputSvc::currentEventStatus() const { } //________________________________________________________________________________ StatusCode FaserByteStreamInputSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) { - if (ByteStreamInputSvc::interfaceID().versionMatch(riid)) { - *ppvInterface = dynamic_cast<ByteStreamInputSvc*>(this); + if (FaserByteStreamInputSvc::interfaceID().versionMatch(riid)) { + *ppvInterface = dynamic_cast<FaserByteStreamInputSvc*>(this); } else { // Interface is not directly available: try out a base class return(::AthService::queryInterface(riid, ppvInterface)); diff --git a/Event/FaserByteStreamCnvSvc/src/FaserEventSelectorByteStream.cxx b/Event/FaserByteStreamCnvSvc/src/FaserEventSelectorByteStream.cxx index 6311fc550e8c4063b4fa4d15828481afccb2748a..c4f3e1464f5107cf2d19ad0c736a89832898fc93 100644 --- a/Event/FaserByteStreamCnvSvc/src/FaserEventSelectorByteStream.cxx +++ b/Event/FaserByteStreamCnvSvc/src/FaserEventSelectorByteStream.cxx @@ -9,9 +9,10 @@ // Include files. #include "FaserEventSelectorByteStream.h" #include "FaserEventContextByteStream.h" -#include "FaserByteStreamInputSvc.h" +#include "FaserByteStreamCnvSvc/FaserByteStreamInputSvc.h" #include "FaserByteStreamCnvSvc/ByteStreamExceptions.h" -#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +//#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" +#include "EventFormats/DAQFormats.hpp" #include "GaudiKernel/ClassID.h" #include "GaudiKernel/FileIncident.h" diff --git a/Event/FaserByteStreamCnvSvc/src/FaserEventSelectorByteStream.h b/Event/FaserByteStreamCnvSvc/src/FaserEventSelectorByteStream.h index 34bdec974fd816c7404d42dcab5cdc4d4143d577..1cf2abb707510a654d8ce71921020fef52bef53c 100644 --- a/Event/FaserByteStreamCnvSvc/src/FaserEventSelectorByteStream.h +++ b/Event/FaserByteStreamCnvSvc/src/FaserEventSelectorByteStream.h @@ -33,7 +33,6 @@ class ISvcLocator; class IAthenaIPCTool; class FaserEventContextByteStream; class FaserByteStreamInputSvc; -class IROBDataProviderSvc; // Class EventSelectorByteStream. class FaserEventSelectorByteStream : public ::AthService, diff --git a/Event/FaserByteStreamCnvSvc/src/components/FaserByteStreamCnvSvc_entries.cxx b/Event/FaserByteStreamCnvSvc/src/components/FaserByteStreamCnvSvc_entries.cxx index c3490e2bbea3e7f7fb47ee1e144323c1f90790cf..72174e55a1c752dd9c912600f5ca810d287f3c39 100644 --- a/Event/FaserByteStreamCnvSvc/src/components/FaserByteStreamCnvSvc_entries.cxx +++ b/Event/FaserByteStreamCnvSvc/src/components/FaserByteStreamCnvSvc_entries.cxx @@ -1,5 +1,5 @@ #include "FaserByteStreamCnvSvc/FaserByteStreamCnvSvc.h" -#include "../FaserByteStreamInputSvc.h" +#include "FaserByteStreamCnvSvc/FaserByteStreamInputSvc.h" #include "../FaserEventSelectorByteStream.h" #include "../EventInfoByteStreamxAODCnv.h" #include "../EventInfoByteStreamAuxCnv.h" diff --git a/Event/FaserByteStreamCnvSvcBase/CMakeLists.txt b/Event/FaserByteStreamCnvSvcBase/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d3dcab1b3ba26fd1460a5b7d459a98687acc1278 --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/CMakeLists.txt @@ -0,0 +1,46 @@ +################################################################################ +# Package: FaserByteStreamCnvSvcBase +################################################################################ + +# Declare the package name: +atlas_subdir( FaserByteStreamCnvSvcBase ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + Control/AthenaKernel + Control/StoreGate + #Event/ByteStreamData + GaudiKernel + ByteStreamCnvSvcBase + PRIVATE + Control/SGTools + AtlasTest/TestTools + EventFormats + Logging) + +# External dependencies: +# find_package( tdaq-common COMPONENTS eformat eformat_write ) + +# Component(s) in the package: +atlas_add_library( FaserByteStreamCnvSvcBaseLib + src/*.cxx + PUBLIC_HEADERS FaserByteStreamCnvSvcBase + # INCLUDE_DIRS ${TDAQ-COMMON_INCLUDE_DIRS} + LINK_LIBRARIES AthenaBaseComps AthenaKernel GaudiKernel StoreGateLib SGtests ByteStreamCnvSvcBaseLib + PRIVATE_LINK_LIBRARIES SGTools ) + +atlas_add_component( FaserByteStreamCnvSvcBase + src/components/*.cxx + # INCLUDE_DIRS ${TDAQ-COMMON_INCLUDE_DIRS} + LINK_LIBRARIES AthenaBaseComps AthenaKernel StoreGateLib SGtests GaudiKernel SGTools FaserByteStreamCnvSvcBaseLib ) + + +#atlas_add_test( ROBDataProviderSvcMT +# SCRIPT test/test_ROBDataProviderSvcMT.sh +# PROPERTIES TIMEOUT 1200 ) +# + +# Install files from the package: +atlas_install_joboptions( share/*.py ) + diff --git a/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h new file mode 100644 index 0000000000000000000000000000000000000000..c2f608bf8926af74cb3cbfa4a9efb8740c1feacd --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERBYTESTREAMCNVSVCBASE_FASERBYTESTREAMADDRESS_H +#define FASERBYTESTREAMCNVSVCBASE_FASERBYTESTREAMADDRESS_H + +// Framework include files +#include "GaudiKernel/GenericAddress.h" +#include "GaudiKernel/EventContext.h" + +#include <stdint.h> +#include <vector> + +/** + * @class ByteStreamAddress + * @brief IOpaqueAddress for ByteStreamCnvSvc, with ROB ids + * + * Package : ByteStreamCnvSvcBase + * + * description : Definition of RawEvent address class + * This class holds a vector of ROBIDs + * @author : H. Ma + * Revision : July 10, 2002, Use new eformat package + * Revision : Sept 19, 2002, Store ROB IDs, to be used with ROBDataProviderSvc + */ + +class FaserByteStreamAddress : public GenericAddress { + public: + // @brief Constructor + FaserByteStreamAddress(const CLID& clid, const std::string& fname, const std::string& cname, int p1 = 0, int p2 = 0); + // @brief Constructor + FaserByteStreamAddress(const CLID& clid); + + // @brief Destructor + virtual ~FaserByteStreamAddress() {}; //doesn't own event + + // @brief Add a rob id + void add(uint32_t robid); + + // @brief Add event id + void setEventContext(const EventContext& eid); + + // @brief access the ROB fragment IDs + const std::vector<uint32_t>& getRobIDs() const; + + // @brief get event id + const EventContext& getEventContext() const; + + // @brief storage type to be used by all bytestream converters + static constexpr long storageType() { return 0x43; } + + private: + // @brief it holds a vector of rob ids + std::vector<uint32_t> m_robIDs; + EventContext m_eid; +}; + +inline void FaserByteStreamAddress::setEventContext(const EventContext& eid) +{ m_eid = eid; } + +inline const EventContext& FaserByteStreamAddress::getEventContext() const +{ return m_eid; } + +#endif diff --git a/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamAddressProviderSvc.h b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamAddressProviderSvc.h new file mode 100644 index 0000000000000000000000000000000000000000..7e62ffb8622335d6b86c395abe9ec7940424e687 --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamAddressProviderSvc.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERBYTESTREAMCNVSVCBASE_BYTESTREAMADDRESSPROVIDERSVC_H +#define FASERBYTESTREAMCNVSVCBASE_BYTESTREAMADDRESSPROVIDERSVC_H + +#include "AthenaKernel/IAddressProvider.h" +#include "AthenaBaseComps/AthService.h" +#include "GaudiKernel/ServiceHandle.h" + +#include <vector> +#include <string> +#include <map> +#include <set> + +class IClassIDSvc; + +template <class TYPE> class SvcFactory; + +/** @class FaserByteStreamAddressProviderSvc + @brief An concrete IAddressProvider +*/ +class FaserByteStreamAddressProviderSvc : public ::AthService, public virtual IAddressProvider { + /// Allow the factory class access to the constructor + friend class SvcFactory<FaserByteStreamAddressProviderSvc>; + +public: + FaserByteStreamAddressProviderSvc(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~FaserByteStreamAddressProviderSvc(); + + // Service initialize + virtual StatusCode initialize(); + virtual StatusCode finalize(); + + // IAddressProvider interface. + // preload the address + virtual StatusCode preLoadAddresses(StoreID::type id, tadList& tlist); + + /// update an existing transient Address + virtual StatusCode updateAddress(StoreID::type id, + SG::TransientAddress* tad, + const EventContext& ctx); + +private: + // type and name of the objects to create the address for. + Gaudi::Property<std::vector<std::string> > m_typeNames{this,"TypeNames",{},\ + "Type and Name of objects to create the address for","OrderedSet<std::string>"}; + + + ServiceHandle<IClassIDSvc> m_clidSvc; + + std::map<unsigned int, std::set<std::string> > m_clidKey; + + int m_storeID; +}; + +#endif diff --git a/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase.h b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase.h new file mode 100644 index 0000000000000000000000000000000000000000..6496bf485e2231a40a009ad0e383d9ef73a2612f --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERBYTESTREAMCNVSVCBASE_BYTESTREAMCNVSVCBASE_H +#define FASERBYTESTREAMCNVSVCBASE_BYTESTREAMCNVSVCBASE_H + +#include "GaudiKernel/IIncidentListener.h" +#include "AthenaBaseComps/AthCnvSvc.h" +#include "FaserByteStreamCnvSvcBase/IFaserByteStreamEventAccess.h" + +/** + @class FaserByteStreamCnvSvcBase + @brief base class for ByteStream conversion service. + + description + This class is used as a conversion service in online HLT + and it is the base class for offline bytestream conversion service. +*/ +class FaserByteStreamCnvSvcBase : public ::AthCnvSvc, + public virtual IIncidentListener, + public virtual IFaserByteStreamEventAccess { + +public: + /// Standard Service Constructor + FaserByteStreamCnvSvcBase(const std::string& name, ISvcLocator* pSvcLocator); + /// Destructor + + virtual ~FaserByteStreamCnvSvcBase(); + /// Required of all Gaudi Services + virtual StatusCode initialize() override; + + /// Required of all Gaudi services: see Gaudi documentation for details + virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override; + + /// Checks whether an IOpaqueAddress is a GenericAddress + virtual StatusCode updateServiceState(IOpaqueAddress* pAddress) override; + + /// Implementation of IByteStreamEventAccess: Get RawEvent + // virtual RawEventWrite* getRawEvent() override { return m_rawEventWrite; } + + /// Implementation of IIncidentListener: Handle for EndEvent incidence + virtual void handle(const Incident&) override; + +protected: // data + // RawEventWrite* m_rawEventWrite; + + std::vector<std::string> m_initCnvs; + std::vector<std::string> m_ROD2ROBmap; +}; + +#endif diff --git a/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserROBDataProviderSvc.h b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserROBDataProviderSvc.h new file mode 100644 index 0000000000000000000000000000000000000000..51c1e38230ee072ca3db9374e11c8b90e594fb49 --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/FaserROBDataProviderSvc.h @@ -0,0 +1,136 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERBYTESTREAMCNVSVCBASE_ROBDATAPROVIDERSVC_H +#define FASERBYTESTREAMCNVSVCBASE_ROBDATAPROVIDERSVC_H + +/** =============================================================== + * @class ROBDataProviderSvc.h + * @brief ROBDataProvider class for accessing ROBData + * + * Requirements: define a ROBData class in the scope + * provide a method + * void getROBData(const vector<uint>& ids, vector<ROBData*>& v) + * Implementation: Use an interal map to store all ROBs + * We can not assume any ROB/ROS relationship, no easy + * way to search. + * This implementation is used in offline + * + * Created: Sept 19, 2002 + * By: Hong Ma + * Modified: Aug. 18 2003 (common class for Online/Offline) + * By: Werner Wiedenmann + * Modified: Apr 21 2005 (remove dependency on data flow repository) + * By: Werner Wiedenmann + */ + +#include "FaserByteStreamCnvSvcBase/IFaserROBDataProviderSvc.h" +#include "AthenaBaseComps/AthService.h" +#include "AthenaKernel/SlotSpecificObj.h" + +#include <vector> +#include <map> + +namespace DAQFormats { + class EventFull; +} + +class FaserROBDataProviderSvc : public extends<AthService, IFaserROBDataProviderSvc> { + +public: + /// ROB Fragment class + //typedef OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF; + + /// Constructor + FaserROBDataProviderSvc(const std::string& name, ISvcLocator* svcloc); + /// Destructor + virtual ~FaserROBDataProviderSvc(); + + /// initialize the service + virtual StatusCode initialize() override; + + /// Gaudi queryInterface method. + // virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface); + + /// Add ROBFragments to cache for given ROB ids, ROB fragments may be retrieved with DataCollector + virtual void addROBData(const std::vector<uint32_t>& robIds, const std::string_view callerName="UNKNOWN") override; + + /// Add a given LVL1/LVL2 ROBFragment to cache + //virtual void setNextEvent(const std::vector<ROBF>& result) override; + + /// Add all ROBFragments of a RawEvent to cache + virtual void setNextEvent(const DAQFormats::EventFull* re) override; + + /// Retrieve ROBFragments for given ROB ids from cache + //virtual void getROBData(const std::vector<uint32_t>& robIds, std::vector<const ROBF*>& robFragments, const std::string_view callerName="UNKNOWN") override; + + /// Retrieve the whole event. + virtual const DAQFormats::EventFull* getEvent() override; + + /// Store the status for the event. + virtual void setEventStatus(uint32_t status) override; + + /// Retrieve the status for the event. + virtual uint32_t getEventStatus() override; + + + /// MT variants + virtual void addROBData(const EventContext& context, const std::vector<uint32_t>& robIds, const std::string_view callerName="UNKNOWN") override; + //virtual void setNextEvent(const EventContext& context, const std::vector<OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment>& result) override; + virtual void setNextEvent(const EventContext& context, const DAQFormats::EventFull* re) override; + //virtual void getROBData(const EventContext& context, const std::vector<uint32_t>& robIds, VROBFRAG& robFragments, + // const std::string_view callerName="UNKNOWN") override; + virtual const DAQFormats::EventFull* getEvent(const EventContext& context) override; + virtual void setEventStatus(const EventContext& context, uint32_t status) override; + virtual uint32_t getEventStatus(const EventContext& context) override; + +//virtual void processCachedROBs(const EventContext& context, +// const std::function< void(const ROBF* )>& fn ) const override; + + virtual bool isEventComplete(const EventContext& /*context*/) const override { return true; } + virtual int collectCompleteEventData(const EventContext& /*context*/, const std::string_view /*callerName*/ ) override { return 0; } + +protected: + /// vector of ROBFragment class + //typedef std::vector<ROBF*> VROBF; + + /// map for all the ROB fragments + //typedef std::map<uint32_t, const ROBF*, std::less<uint32_t> > ROBMAP; + + struct EventCache { + ~EventCache(); + const DAQFormats::EventFull* event = 0; + uint32_t eventStatus = 0; + uint32_t currentLvl1ID = 0; + //ROBMAP robmap; + + }; + SG::SlotSpecificObj<EventCache> m_eventsCache; + + /// Remaining attributes are for configuration + /// vector of Source ids and status words to be ignored for the ROB map + typedef SimpleProperty< std::vector< std::pair<int, int> > > ArrayPairIntProperty; + ArrayPairIntProperty m_filterRobWithStatus; // filter with full ROB SourceID + ArrayPairIntProperty m_filterSubDetWithStatus; // filter with Sub Det ID + + /// map of full ROB Source ids and status words to be ignored for the ROB map + //typedef std::map<uint32_t, std::vector<uint32_t> > FilterRobMap; + //FilterRobMap m_filterRobMap; + /// map of Sub Det Source ids and status words to be ignored for the ROB map + //typedef std::map<eformat::SubDetector, std::vector<uint32_t> > FilterSubDetMap; + //FilterSubDetMap m_filterSubDetMap; + /// method to filter ROBs with given Status code + //bool filterRobWithStatus(const ROBF* rob); + + /// Filter out empty ROB fragments which are send by the ROS + BooleanProperty m_filterEmptyROB; + bool m_maskL2EFModuleID = false; + +private: // data + +private: // + //static void robmapClear(ROBMAP& toclear); +}; + +#endif diff --git a/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/IFaserByteStreamEventAccess.h b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/IFaserByteStreamEventAccess.h new file mode 100644 index 0000000000000000000000000000000000000000..cfc5077f1842101557cec56f30060f4965a357de --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/IFaserByteStreamEventAccess.h @@ -0,0 +1,27 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERBYTESTREAMCNVSVCBASE_IBYTESTREAMEVENTACCESS_H +#define FASERBYTESTREAMCNVSVCBASE_IBYTESTREAMEVENTACCESS_H + +//#include "ByteStreamData/RawEvent.h" +#include "GaudiKernel/IInterface.h" + +/** @class IByteStreamEventAccess + * @brief interface for accessing raw data . + */ +static const InterfaceID +IID_IFaserByteStreamEventAccess("IFaserByteStreamEventAccess", 2 , 0); + +class IFaserByteStreamEventAccess: virtual public IInterface { + public: + /// Gaudi interface id + static const InterfaceID& interfaceID() { return IID_IFaserByteStreamEventAccess; } + + /// pure virtual method for accessing RawEventWrite + //virtual RawEventWrite* getRawEvent() = 0; + +}; + +#endif diff --git a/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/IFaserROBDataProviderSvc.h b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/IFaserROBDataProviderSvc.h new file mode 100644 index 0000000000000000000000000000000000000000..213c6b93d8906af80b809797e00ddf5fa1cd7c6e --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase/IFaserROBDataProviderSvc.h @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef IFASERROBDATAPROVIDERSVC_H +#define IFASERROBDATAPROVIDERSVC_H + +#include "GaudiKernel/IInterface.h" +#include "GaudiKernel/EventContext.h" + +#include <cstdint> +#include <vector> +#include <string> +#include <string_view> +#include <stdexcept> +#include <functional> + +namespace DAQFormats { + class EventFull; +} + +// Declaration of the interface ID ( interface id, major version, minor version) +//static const InterfaceID IID_IROBDataProviderSvc("IROBDataProviderSvc", 1 , 0); + +/** @class IFaserROBDataProviderSvc + @brief Interface class for managing ROB for both online and offline. +*/ +class IFaserROBDataProviderSvc : virtual public IInterface { + +public: + //typedef OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF; + //typedef std::vector<const ROBF*> VROBFRAG; + + /// Retrieve interface ID + // static const InterfaceID& interfaceID() { return IID_IFaserROBDataProviderSvc; } + DeclareInterfaceID(IFaserROBDataProviderSvc, 1, 1); + + /// Add ROBFragments to cache for given ROB ids, ROB fragments may be retrieved with DataCollector + virtual void addROBData(const std::vector<uint32_t>& robIds, const std::string_view callerName="UNKNOWN") = 0 ; + + /// Add a given LVL1/LVL2 ROBFragment to cache + //virtual void setNextEvent(const std::vector<ROBF>& result) = 0 ; + + + /// Add all ROBFragments of a RawEvent to cache + virtual void setNextEvent(const DAQFormats::EventFull* re) = 0 ; + + + /// Retrieve ROBFragments for given ROB ids from cache + //virtual void getROBData(const std::vector<uint32_t>& robIds, VROBFRAG& robFragments, const std::string_view callerName="UNKNOWN") = 0; + + + /// Retrieve the whole event. + virtual const DAQFormats::EventFull* getEvent() = 0; + + + /// Store the status for the event. + virtual void setEventStatus(uint32_t status) = 0; + + + /// Retrieve the status for the event. + virtual uint32_t getEventStatus() = 0; + + + // variants for MT, it has an implementation for now in order not to require change in all implementations yet, they will all become pure virtual methods + virtual void addROBData(const EventContext& /*context*/, const std::vector<uint32_t>& /*robIds*/, const std::string_view callerName="UNKNOWN") { + throw std::runtime_error( std::string(callerName)+ std::string(" is using unimplemented ") + __FUNCTION__ ) ; + } + //virtual void setNextEvent(const EventContext& /*context*/, const std::vector<ROBF>& /*result*/) { + // throw std::runtime_error( std::string("Unimplemented ") + __FUNCTION__ ); + //} + virtual void setNextEvent( const EventContext& /*context*/, const DAQFormats::EventFull* /*re*/) { + throw std::runtime_error(std::string("Unimplemented ") + __FUNCTION__ ); + } + //virtual void getROBData(const EventContext& /*context*/, const std::vector<uint32_t>& /*robIds*/, VROBFRAG& /*robFragments*/, + // const std::string_view callerName="UNKNOWN") { + //throw std::runtime_error( std::string(callerName)+ std::string(" is using unimplemented ") + __FUNCTION__ ) ; + //} + virtual const DAQFormats::EventFull* getEvent(const EventContext& /*context*/) { + throw std::runtime_error(std::string("Unimplemented ") + __FUNCTION__ ); + } + virtual void setEventStatus(const EventContext& /*context*/, uint32_t /*status*/) { + throw std::runtime_error(std::string("Unimplemented ") + __FUNCTION__ ); + } + virtual uint32_t getEventStatus(const EventContext& /*context*/) { + throw std::runtime_error(std::string("Unimplemented ") + __FUNCTION__ ); + return 0; + } + + /// @brief Interface to access cache of ROBs (it is a full event in case of offline) + /// In online implementation the cache will contain only a subset of ROBs. + /// This method allows read access to the cache. + /// @warning in case the cache is updated in the meantime the iteration is guaranteed to be safe + /// but may not give access to all the ROBs available n the very moment + /// Example of counting: size_t counter = 0; svc->processCahcedROBs(ctx, [&](const ROBF*){ counter ++; }) + /// Example of printout: svc->processCahcedROBs(ctx, [&](const ROBF* rob){ log() << MSG::DEBUG << "ROB " << rob->source_id() << endmsg; }) + // virtual void processCachedROBs(const EventContext& /*context*/, + // const std::function< void(const ROBF* )>& /*fn*/ ) const { + // throw std::runtime_error(std::string("Unimplemented ") + __FUNCTION__ ); + //} + + /// Check if complete event data are already in cache + virtual bool isEventComplete(const EventContext& /*context*/) const { + throw std::runtime_error(std::string("Unimplemented ") + __FUNCTION__ ); + } + + /// @brief Collect all data for an event from the ROS and put them into the cache + /// @return value: number of ROBs which were retrieved to complete the event + /// Optionally the name of the caller of this method can be specified for monitoring + virtual int collectCompleteEventData(const EventContext& /*context*/, const std::string_view callerName="UNKNOWN") { + throw std::runtime_error(std::string(callerName) + std::string(" is using unimplemented ") + __FUNCTION__ ); + return 0; + } + +}; + +#endif diff --git a/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamAddress.cxx b/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamAddress.cxx new file mode 100644 index 0000000000000000000000000000000000000000..96d9147af34e3c0a0d02f1954ccc3f5198c1d0be --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamAddress.cxx @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +//==================================================================== +//FaserByteStreamAddress implementation +//-------------------------------------------------------------------- +// +//Package : ByteStreamCnvSvcBase +// +// Description: BSCnvSvc address implementation +// +//Author : Hong Ma +// created : MAr 2, 2001 +// History : +// Revision: Sept 19, 2002 +// Store ROB IDs, to be used with ROBDataProviderSvc +//==================================================================== + +//own +#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" + +// Framework include files +#include "GaudiKernel/GenericAddress.h" + +/// Standard Constructor +FaserByteStreamAddress::FaserByteStreamAddress(const CLID& clid, + const std::string& fname , const std::string& cname, int p1, int p2) + : GenericAddress(storageType(), clid, fname, cname, p1, p2), m_eid(0,0) { +} + +FaserByteStreamAddress::FaserByteStreamAddress(const CLID& clid) + : GenericAddress(storageType(), clid, "", "") { +} + +/** Add ROBID + */ +void FaserByteStreamAddress::add( uint32_t robid) { + m_robIDs.push_back(robid); +} + +/** access the fragment pointer + */ +const std::vector<uint32_t>& FaserByteStreamAddress::getRobIDs() const { + return(m_robIDs); +} diff --git a/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamAddressProviderSvc.cxx b/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamAddressProviderSvc.cxx new file mode 100644 index 0000000000000000000000000000000000000000..75e999d2ae9f07755c35d2a975ba8aaf6d854501 --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamAddressProviderSvc.cxx @@ -0,0 +1,101 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +// Include files +#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddressProviderSvc.h" +#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +//#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" + +#include "StoreGate/StoreGate.h" +#include "SGTools/TransientAddress.h" +#include "GaudiKernel/ListItem.h" + +#include "AthenaKernel/IClassIDSvc.h" + +//#include "eformat/SourceIdentifier.h" + +/// Standard constructor +FaserByteStreamAddressProviderSvc::FaserByteStreamAddressProviderSvc(const std::string& name, ISvcLocator* pSvcLocator) : + ::AthService(name, pSvcLocator), + m_clidSvc("ClassIDSvc", name), + m_storeID(StoreID::EVENT_STORE) { + declareProperty("StoreID", m_storeID); +} +//________________________________________________________________________________ +FaserByteStreamAddressProviderSvc::~FaserByteStreamAddressProviderSvc() { +} +//________________________________________________________________________________ +StatusCode FaserByteStreamAddressProviderSvc::initialize() { + ATH_MSG_INFO("Initializing " << name() << " - package version " << PACKAGE_VERSION); + if (!::AthService::initialize().isSuccess()) { + ATH_MSG_FATAL("Cannot initialize AthService base class."); + return(StatusCode::FAILURE); + } + + // Retrieve ClassIDSvc + if (!m_clidSvc.retrieve().isSuccess()) { + ATH_MSG_FATAL("Cannot get ClassIDSvc."); + return(StatusCode::FAILURE); + } + if (m_storeID < 0 || m_storeID > StoreID::UNKNOWN) { + ATH_MSG_FATAL("Invalid StoreID " << m_storeID); + return(StatusCode::FAILURE); + } + ATH_MSG_INFO("initialized "); + ATH_MSG_INFO("-- Will fill Store with id = " << m_storeID); + return(StatusCode::SUCCESS); +} +//________________________________________________________________________________ +StatusCode FaserByteStreamAddressProviderSvc::finalize() { + // Release ClassIDSvc + if (!m_clidSvc.release().isSuccess()) { + ATH_MSG_WARNING("Cannot release ClassIDSvc."); + } + return(::AthService::finalize()); +} +//________________________________________________________________________________ +StatusCode FaserByteStreamAddressProviderSvc::preLoadAddresses(StoreID::type id, tadList& tlist) { + ATH_MSG_DEBUG("in preLoadAddress"); + if (id != m_storeID) { + ATH_MSG_DEBUG("StoreID = " << id << " does not match required id (" << m_storeID << ") skip"); + return(StatusCode::SUCCESS); + } + + for (std::vector<std::string>::const_iterator it = m_typeNames.begin(), it_e = m_typeNames.end(); + it != it_e; it++) { + ListItem item(*it); + const std::string& t = item.type(); + const std::string& nm = item.name(); + CLID classid; + if (!m_clidSvc->getIDOfTypeName(t, classid).isSuccess()) { + ATH_MSG_WARNING("Cannot create TAD for (type, name)" << " no CLID for " << t << " " << nm); + } else { + SG::TransientAddress* tad = new SG::TransientAddress(classid, nm); + tlist.push_back(tad); + ATH_MSG_DEBUG("Created TAD for (type, clid, name)" << t << " " << classid << " " << nm); + // save the clid and key. + m_clidKey[classid].insert(nm); + } + } + return(StatusCode::SUCCESS); +} +//________________________________________________________________________________ +StatusCode FaserByteStreamAddressProviderSvc::updateAddress(StoreID::type id, + SG::TransientAddress* tad, + const EventContext& ctx) { + if (id != m_storeID) { + return(StatusCode::FAILURE); + } + CLID clid = tad->clID(); + std::string nm = tad->name(); + std::map<CLID, std::set<std::string> >::const_iterator it = m_clidKey.find(clid); + if (it == m_clidKey.end() || (*it).second.count(nm) == 0) { + return(StatusCode::FAILURE); + } + ATH_MSG_DEBUG("Creating address for " << clid << " " << nm); + ByteStreamAddress* add = new ByteStreamAddress(clid, nm, ""); + add->setEventContext(ctx); + tad->setAddress(add); + return(StatusCode::SUCCESS); +} diff --git a/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamCnvSvcBase.cxx b/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamCnvSvcBase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..53b7470edd387c22c9403e8a1923e470ef77275b --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/src/FaserByteStreamCnvSvcBase.cxx @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase.h" +#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" + +#include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/GenericAddress.h" +#include "GaudiKernel/IConverter.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/IIncidentSvc.h" + +#include "AthenaKernel/IClassIDSvc.h" +#include "StoreGate/StoreGate.h" + +//______________________________________________________________________________ +FaserByteStreamCnvSvcBase::FaserByteStreamCnvSvcBase(const std::string& name, ISvcLocator* pSvcLocator) : + ::AthCnvSvc(name, pSvcLocator, ByteStreamAddress::storageType()) + // , m_rawEventWrite(0) +{ + declareProperty("InitCnvs", m_initCnvs); + // This property is used by Tile BS converter, not by this class. + declareProperty("ROD2ROBmap", m_ROD2ROBmap); +} +//______________________________________________________________________________ +/// Standard Destructor +FaserByteStreamCnvSvcBase::~FaserByteStreamCnvSvcBase() { +} +//______________________________________________________________________________ +/// Initialize the service. +StatusCode FaserByteStreamCnvSvcBase::initialize() { + if (!::AthCnvSvc::initialize().isSuccess()) { + ATH_MSG_FATAL("Cannot initialize AthCnvSvc base class."); + return(StatusCode::FAILURE); + } + + ServiceHandle<IIncidentSvc> incsvc("IncidentSvc", this->name()); + if (!incsvc.retrieve().isSuccess()) { + ATH_MSG_FATAL("Cannot get IncidentSvc."); + return(StatusCode::FAILURE); + } + incsvc->addListener(this, "BeginRun", 0, false, true); // true for singleshot + return(StatusCode::SUCCESS); +} +//_______________________________________________________________________ +StatusCode FaserByteStreamCnvSvcBase::queryInterface(const InterfaceID& riid, void** ppvInterface) { + if (IFaserByteStreamEventAccess::interfaceID().versionMatch(riid)) { + *ppvInterface = dynamic_cast<IFaserByteStreamEventAccess*>(this); + } else { + // Interface is not directly available: try out a base class + return(::AthCnvSvc::queryInterface(riid, ppvInterface)); + } + addRef(); + return(StatusCode::SUCCESS); +} +//______________________________________________________________________________ +StatusCode FaserByteStreamCnvSvcBase::updateServiceState(IOpaqueAddress* pAddress) { + if (pAddress != 0) { + GenericAddress* pAddr = dynamic_cast<GenericAddress*>(pAddress); + if (pAddr != 0) { + return(StatusCode::SUCCESS); + } + } + return(StatusCode::FAILURE); +} +//______________________________________________________________________________ +void FaserByteStreamCnvSvcBase::handle(const Incident& /*incident*/) { + ServiceHandle<IClassIDSvc> clidSvc("ClassIDSvc", name()); + if (!clidSvc.retrieve().isSuccess()) { + ATH_MSG_ERROR("Cannot get ClassIDSvc."); + return; + } + // Initialize the converters + for (std::vector<std::string>::const_iterator it = m_initCnvs.begin(), it_e = m_initCnvs.end(); + it != it_e; it++) { + ATH_MSG_DEBUG("Accessing Converter for " << *it); + CLID id; + if (!clidSvc->getIDOfTypeName(*it, id).isSuccess()) { + ATH_MSG_WARNING("Cannot get CLID for " << *it); + } else { + IConverter* cnv = converter(id); + if (cnv == 0) { + ATH_MSG_WARNING("Cannot get converter for " << *it); + } + } + } + return; +} diff --git a/Event/FaserByteStreamCnvSvcBase/src/FaserROBDataProviderSvc.cxx b/Event/FaserByteStreamCnvSvcBase/src/FaserROBDataProviderSvc.cxx new file mode 100644 index 0000000000000000000000000000000000000000..15edee9776b913368edb9b106cdfde7ec59b73e8 --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/src/FaserROBDataProviderSvc.cxx @@ -0,0 +1,482 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//=================================================================== +// Implementation of ROBDataProviderSvc +// Revision: November 2017 +// MT readiness +// Revision: July 11, 2002 +// Modified for eformat +// Revision: Aug 18, 2003 +// Modified to use ROBFragments directly and include methods +// for online +// Revision: Apr 21, 2005 +// Remove dependency on Level-2 Data Collector, create special +// version for online +// Revision: Oct 29, 2006 +// Increase MAX_ROBFRAGMENTS to 2048 to cover the special case +// when in a "localhost" partition the complete event is given +// to the Event Filter as one single ROS fragment (this case +// should not happen for normal running when several ROSes are +// used and the ROB fragments are grouped under different ROS +// fragments) +// Revision: Nov 10, 2008 +// Mask off the module ID from the ROB source identifier of the +// L2 and EF result when storing it in the ROB map. This is necessary +// when the L2/PT node ID is stored in the source identifier as +// module ID. With this modification the L2 and EF result can still be +// found as 0x7b0000 and 0x7c0000 +// Revision: Jan 12, 2009 +// Allow removal of individual ROBs and ROBs from given subdetectors +// from the internal ROB map according to a given status code. +// This may be necessary when corrupted and incomplete ROB fragments +// are forwarded to the algorithms and the converters are not yet +// prepared to handle the specific cases. +// The filtering can be configured with job options as: +// +// for individual ROBs as : +// ------------------------ +// ROBDataProviderSvc.filterRobWithStatus = [ (ROB SourceId, StatusCode to remove), +// (ROB SourceId 2, StatusCode to remove 2), ... ] +// and: +// ROBDataProviderSvc.filterRobWithStatus += [ (ROB SourceId n, StatusCode to remove n) ] +// +// Example: +// ROBDataProviderSvc.filterRobWithStatus = [ (0x42002a,0x0000000f), (0x42002e,0x00000008) ] +// ROBDataProviderSvc.filterRobWithStatus += [ (0x42002b,0x00000000) ] +// +// for all ROBs of a given sub detector as : +// ----------------------------------------- +// ROBDataProviderSvc.filterSubDetWithStatus = [ (Sub Det Id, StatusCode to remove), +// (Sub Det Id 2, StatusCode to remove 2), ... ] +// and: +// ROBDataProviderSvc.filterSubDetWithStatus += [ (Sub Det Id n, StatusCode to remove n) ] +// +// Example: +// ROBDataProviderSvc.filterSubDetWithStatus = [ (0x41,0x00000000), (0x42,0x00000000) ] +// ROBDataProviderSvc.filterSubDetWithStatus += [ (0x41,0xcb0002) ] +// +// For valid ROB Source Ids, Sub Det Ids and ROB Status elements see the event format +// document ATL-D-ES-0019 (EDMS) +// Revision: Jan 28, 2014 +// For Run 1 the module ID from the ROB source identifier of the +// L2 and EF result needed to be masked off before storing the ROB fragment +// in the ROB map. The module ID for these fragments contained an identifier +// of the machine on which they were produced. This produced as many different ROB IDs +// for these fragments as HLT processors were used. The module IDs were not useful +// for analysis and needed to be masked off from these fragments in the ROB map in order +// to allow the access to the L2 or the EF result with the generic identifiers +// 0x7b0000 and 0x7c0000. Also an event contained only one L2 and EF result. +// From Run 2 on (eformat version 5) the HLT processor identifier is not anymore +// stored in the module ID of the HLT result. Further there can be in one event several HLT result +// records with the source identifier 0x7c. The different HLT results are distinguished +// now with the module ID. A module ID 0 indicates a physiscs HLT result as before, while +// HLT results with module IDs different from zero are produced by data scouting chains. +// In Run 2 the module ID should be therefore not any more masked. +// The masking of the moduleID is switched on when a L2 result is found in the event or the +// event header contains L2 trigger info words. This means the data were produced with run 1 HLT system. +// +//=================================================================== + +// Include files. +#include "FaserByteStreamCnvSvcBase/FaserROBDataProviderSvc.h" +#include "EventFormats/DAQFormats.hpp" +//#include "eformat/Status.h" + +using DAQFormats::EventFull; + +// Constructor. +FaserROBDataProviderSvc::FaserROBDataProviderSvc(const std::string& name, ISvcLocator* svcloc) + : base_class(name, svcloc) { + + declareProperty("filterRobWithStatus", m_filterRobWithStatus); + declareProperty("filterSubDetWithStatus", m_filterSubDetWithStatus); + declareProperty("filterEmptyROB", m_filterEmptyROB = false); +} + +// Destructor. +FaserROBDataProviderSvc::~FaserROBDataProviderSvc() { + // the eventsCache take care of cleaaning itself +} + +// Initialization +StatusCode FaserROBDataProviderSvc::initialize() { + ATH_MSG_INFO("Initializing " << name() << " - package version " << PACKAGE_VERSION); + if (!::AthService::initialize().isSuccess()) { + ATH_MSG_FATAL("Cannot initialize AthService base class."); + return(StatusCode::FAILURE); + } + m_eventsCache = SG::SlotSpecificObj<EventCache>( SG::getNSlots() ); + + /* + for (unsigned int i = 0; i < m_filterRobWithStatus.value().size(); i++) { + eformat::helper::SourceIdentifier tmpsrc(m_filterRobWithStatus.value()[i].first); + if (tmpsrc.human_detector() != "UNKNOWN") { + m_filterRobMap[tmpsrc.code()].push_back(m_filterRobWithStatus.value()[i].second); + } + } + for (unsigned int i = 0; i < m_filterSubDetWithStatus.value().size(); i++) { + eformat::helper::SourceIdentifier tmpsrc((eformat::SubDetector)m_filterSubDetWithStatus.value()[i].first, 0); + if (tmpsrc.human_detector() != "UNKNOWN") { + m_filterSubDetMap[tmpsrc.subdetector_id()].push_back(m_filterSubDetWithStatus.value()[i].second); + } + } + ATH_MSG_INFO(" ---> Filter out empty ROB fragments = " << m_filterEmptyROB); + ATH_MSG_INFO(" ---> Filter out specific ROBs by Status Code: # ROBs = " << m_filterRobMap.size()); + for (FilterRobMap::const_iterator it = m_filterRobMap.begin(), itEnd = m_filterRobMap.end(); + it != itEnd; it++) { + eformat::helper::SourceIdentifier tmpsrc(it->first); + ATH_MSG_INFO(" RobId=0x" << MSG::hex << it->first << " -> in Sub Det = " << tmpsrc.human_detector()); + for (std::vector<uint32_t>::const_iterator it_status = (*it).second.begin(), it_statusEnd = (*it).second.end(); + it_status != it_statusEnd; it_status++) { + eformat::helper::Status tmpstatus(*it_status); + ATH_MSG_INFO(" Status Code=0x" + << MSG::hex << std::setfill( '0' ) << std::setw(8) << tmpstatus.code() + << " Generic Part=0x" << std::setw(4) << tmpstatus.generic() + << " Specific Part=0x" << std::setw(4) << tmpstatus.specific()); + } + } + + ATH_MSG_INFO(" ---> Filter out Sub Detector ROBs by Status Code: # Sub Detectors = " << m_filterSubDetMap.size()); + for (FilterSubDetMap::const_iterator it = m_filterSubDetMap.begin(), itEnd = m_filterSubDetMap.end(); + it != itEnd; it++) { + eformat::helper::SourceIdentifier tmpsrc(it->first, 0); + ATH_MSG_INFO(" SubDetId=0x" << MSG::hex << it->first << " -> " << tmpsrc.human_detector()); + for (std::vector<uint32_t>::const_iterator it_status = (*it).second.begin(), it_statusEnd = (*it).second.end(); + it_status != it_statusEnd; it_status++) { + eformat::helper::Status tmpstatus(*it_status); + ATH_MSG_INFO(" Status Code=0x" + << MSG::hex << std::setfill( '0' ) << std::setw(8) << tmpstatus.code() + << " Generic Part=0x" << std::setw(4) << tmpstatus.generic() + << " Specific Part=0x" << std::setw(4) << tmpstatus.specific()); + } + } + */ + return(StatusCode::SUCCESS); +} + +// /// Query interface +// StatusCode FaserROBDataProviderSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) { +// if (IFaserROBDataProviderSvc::interfaceID().versionMatch(riid)) { +// *ppvInterface = dynamic_cast<IFaserROBDataProviderSvc*>(this); +// } else { +// // Interface is not directly available: try out a base class +// return(::AthService::queryInterface(riid, ppvInterface)); +// } +// addRef(); +// return(StatusCode::SUCCESS); +// } + +/** + - in offline only check that given ROB ids are in the map, issue an + error if not +*/ + + + +void FaserROBDataProviderSvc::addROBData(const std::vector<uint32_t>& robIds, const std::string_view callerName) { + const EventContext context{ Gaudi::Hive::currentContext() }; + return addROBData( context, robIds, callerName ); +} + +void FaserROBDataProviderSvc::addROBData(const EventContext& context, const std::vector<uint32_t>& robIds, const std::string_view callerName) { + EventCache* cache = m_eventsCache.get( context ); + + // Copy missing ROB ids to vector with pthread allocator + ATH_MSG_DEBUG(" ---> Number of ROB Id s requested : " << robIds.size() << ", Caller Name = " << callerName); + // for offline running all requested ROBs should be found in cache + // if not issue error + for (std::vector<uint32_t>::const_iterator it = robIds.begin(), it_end = robIds.end(); it != it_end; it++) { + uint32_t id = (*it); + + // mask off the module ID for L2 and EF result for Run 1 data + /* + if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) && + (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_LVL2) ) { + id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code(); + // TB if it is inconsistent we should not continue like this? + if ( !m_maskL2EFModuleID ) { + ATH_MSG_ERROR("Inconsistent flag for masking L2/EF module IDs"); + m_maskL2EFModuleID=true; + } + } else if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) && + (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) && + ( m_maskL2EFModuleID ) ) { + id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code(); + } + */ + /* + ROBMAP& robmap( cache->robmap ); + ROBMAP::iterator map_it = robmap.find(id) ; + if (map_it != robmap.end()) { + ATH_MSG_DEBUG(" ---> Found ROB Id : 0x" << MSG::hex << (*map_it).second->source_id() + << MSG::dec << " in cache"); + } else { + ATH_MSG_DEBUG(" ---> ROB Id : 0x" << MSG::hex << id + << MSG::dec << " not found in cache for running mode OFFLINE (method addROBData),"); + ATH_MSG_DEBUG(" Lvl1 id = " << cache->currentLvl1ID); + } + */ + } + return; +} +/** - this is the online method to add the LVL1/LVL2 result + - this version of FaserROBDataProviderSvc does not support it + - this version is for offline use only +*/ +/* +void FaserROBDataProviderSvc::setNextEvent(const std::vector<ROBF>& result) { + const EventContext context{ Gaudi::Hive::currentContext() }; + return setNextEvent( context, result ); +} +*/ +/* +void FaserROBDataProviderSvc::setNextEvent(const EventContext& context, const std::vector<ROBF>& result) { + // clear the old map + // TB honestly, why do any action if this is FATAL mistake + // robmapClear( m_eventsCache.get(context)->robmap ); + + // This method should never be used by offline + ATH_MSG_FATAL(" +-----------------------------------------------------------------+ "); + ATH_MSG_FATAL(" | The method FaserROBDataProviderSvc::setNextEvent(const ROBF* result) | "); + ATH_MSG_FATAL(" | is not implemented for this version of FaserROBDataProviderSvc | "); + ATH_MSG_FATAL(" | Use the version from the HLT repository if you need it. | "); + ATH_MSG_FATAL(" +-----------------------------------------------------------------+ "); + ATH_MSG_FATAL(" ---> The " << result.size() << " ROB fragments in the call will not be used."); + return; +} +*/ + + + +/** - add a new Raw event + - rebuild the map +*/ +void FaserROBDataProviderSvc::setNextEvent(const EventFull* re) { + // obtain context and redirect to the real implementation + const EventContext context{ Gaudi::Hive::currentContext() }; + return setNextEvent( context, re ); +} + +void FaserROBDataProviderSvc::setNextEvent( const EventContext& context, const EventFull* re ) { + EventCache* cache = m_eventsCache.get( context ); + + cache->event = re; + // clear the old map + //robmapClear( cache->robmap ); + // set the LVL1 id + //cache->currentLvl1ID = re->lvl1_id(); + // set flag for masking L2/EF module ID, this is only necessary for the separate L2 and EF systems from Run 1 + //m_maskL2EFModuleID = (re->nlvl2_trigger_info() != 0); + + // get all the ROBFragments + /* + const size_t MAX_ROBFRAGMENTS = 2048; + OFFLINE_FRAGMENTS_NAMESPACE::PointerType robF[MAX_ROBFRAGMENTS]; + OFFLINE_FRAGMENTS_NAMESPACE::PointerType rePointer; + re->start(rePointer); + size_t robcount = re->children(robF, MAX_ROBFRAGMENTS); + if (robcount == MAX_ROBFRAGMENTS) { + ATH_MSG_ERROR("ROB buffer overflow"); + } + // loop over all ROBs + for (size_t irob = 0; irob < robcount; irob++) { + // add to the map + const ROBF* rob = new ROBF(robF[irob]); + uint32_t id = rob->source_id(); + // mask off the module ID for L2 and EF result for Run 1 data + if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) && + (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_LVL2) ) { + id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code(); + if (!m_maskL2EFModuleID) { + ATH_MSG_ERROR("Inconsistent flag for masking L2/EF module IDs"); + m_maskL2EFModuleID=true; + } + } else if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) && + (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) && + (m_maskL2EFModuleID) ) { + id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code(); + } + if ((rob->rod_ndata() == 0) && (m_filterEmptyROB)) { + ATH_MSG_DEBUG( " ---> Empty ROB Id = 0x" << MSG::hex << id << MSG::dec + << " removed for L1 Id = " << cache->currentLvl1ID); + delete rob; + } else if (filterRobWithStatus(rob)) { + if (rob->nstatus() > 0) { + const uint32_t* it_status; + rob->status(it_status); + eformat::helper::Status tmpstatus(*it_status); + ATH_MSG_DEBUG(" ---> ROB Id = 0x" << MSG::hex << id << std::setfill('0') + << " with Generic Status Code = 0x" << std::setw(4) << tmpstatus.generic() + << " and Specific Status Code = 0x" << std::setw(4) << tmpstatus.specific() << MSG::dec + << " removed for L1 Id = " << cache->currentLvl1ID); + } + delete rob; + } else { + + ROBMAP::const_iterator it = cache->robmap.find(id); + if (it != cache->robmap.end()) { + ATH_MSG_WARNING(" FaserROBDataProviderSvc:: Duplicate ROBID 0x" << MSG::hex << id + << " found. " << MSG::dec << " Overwriting the previous one "); + delete cache->robmap[id]; + cache->robmap[id] = rob; + } else { + cache->robmap[id] = rob; + } + + } + } +*/ + ATH_MSG_DEBUG(" ---> setNextEvent offline for " << name() ); + ATH_MSG_DEBUG(" current LVL1 id = " << cache->currentLvl1ID ); + //ATH_MSG_DEBUG(" size of ROB cache = " << cache->robmap.size() ); + return; +} +/** return ROBData for ROBID + */ +/* +void FaserROBDataProviderSvc::getROBData(const std::vector<uint32_t>& ids, std::vector<const ROBF*>& v, const std::string_view callerName) { + const EventContext context{ Gaudi::Hive::currentContext() }; + return getROBData( context, ids, v, callerName ); +} +*/ +/* +void FaserROBDataProviderSvc::getROBData(const EventContext& context, const std::vector<uint32_t>& ids, std::vector<const ROBF*>& v, + const std::string_view callerName) { + EventCache* cache = m_eventsCache.get( context ); + + for (std::vector<uint32_t>::const_iterator it = ids.begin(), it_end = ids.end(); it != it_end; it++) { + uint32_t id = (*it); + // mask off the module ID for L2 and EF result for Run 1 data + if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) && + (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_LVL2) ) { + id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code(); + if (!m_maskL2EFModuleID) { + ATH_MSG_ERROR("Inconsistent flag for masking L2/EF module IDs"); + m_maskL2EFModuleID=true; + } + } else if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) && + (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) && + (m_maskL2EFModuleID) ) { + id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code(); + } + ROBMAP::iterator map_it = cache->robmap.find(id); + if (map_it != cache->robmap.end()) { + v.push_back((*map_it).second); + } else { + ATH_MSG_DEBUG("Failed to find ROB for id 0x" << MSG::hex << id << MSG::dec << ", Caller Name = " << callerName); +#ifndef NDEBUG + int nrob = 0; + ATH_MSG_VERBOSE(" --- Dump of ROB cache ids --- total size = " << cache->robmap.size()); + for (ROBMAP::iterator cache_it = cache->robmap.begin(), cache_end = cache->robmap.end(); + cache_it != cache_end; cache_it++) { + ++nrob; + ATH_MSG_VERBOSE(" # = " << nrob << " id = 0x" << MSG::hex << (*cache_it).second->source_id() << MSG::dec); + } +#endif + } + } + return; +} +*/ + +/** - clear ROB map + */ +/* +void FaserROBDataProviderSvc::robmapClear( ROBMAP& toclear) { + for (ROBMAP::const_iterator it = toclear.begin(), itE = toclear.end(); it != itE; ++it) { + delete it->second; + } + toclear.clear(); +} +*/ + +/// Retrieve the whole event. +const EventFull* FaserROBDataProviderSvc::getEvent() { + const EventContext context{ Gaudi::Hive::currentContext() }; + return getEvent( context ); +} +const EventFull* FaserROBDataProviderSvc::getEvent( const EventContext& context ) { + + return m_eventsCache.get( context )->event; +} + + +/// Set the status for the event. +void FaserROBDataProviderSvc::setEventStatus(uint32_t status) { + const EventContext context{ Gaudi::Hive::currentContext() }; + setEventStatus( context, status ); +} + +void FaserROBDataProviderSvc::setEventStatus(const EventContext& context, uint32_t status) { + m_eventsCache.get(context)->eventStatus = status; +} +/// Retrieve the status for the event. +uint32_t FaserROBDataProviderSvc::getEventStatus() { + const EventContext context{ Gaudi::Hive::currentContext() }; + return getEventStatus( context ); +} + +uint32_t FaserROBDataProviderSvc::getEventStatus( const EventContext& context ) { + return m_eventsCache.get( context )->eventStatus; +} + +/* +void FaserROBDataProviderSvc::processCachedROBs(const EventContext& context, + const std::function< void(const ROBF* )>& fn ) const { + for ( const auto& el : m_eventsCache.get( context )->robmap ) { + fn( el.second ); + } +} +*/ + + +/** - filter ROB with Sub Detector Id and Status Code +*/ +/* +bool FaserROBDataProviderSvc::filterRobWithStatus(const ROBF* rob) { + // No filter criteria defined + if ((m_filterRobMap.size() == 0) && (m_filterSubDetMap.size() == 0)) { + return(false); + } + // There should be at least one status element if there was an error + // in case there are 0 status elements then there was no known error + // (see event format document ATL-D-ES-0019 (EDMS)) + if (rob->nstatus() == 0) { + return(false); + } + // The ROB has at least one status element, access it via an iterator + const uint32_t* rob_it_status; + rob->status(rob_it_status); + // Build the full ROB Sourceidentifier + eformat::helper::SourceIdentifier tmpsrc(rob->rob_source_id()); + // Check if there is a ROB specific filter rule defined for this ROB Id and match the status code + FilterRobMap::iterator map_it_rob = m_filterRobMap.find(tmpsrc.code()); + if (map_it_rob != m_filterRobMap.end()) { + for (std::vector<uint32_t>::const_iterator it_status = (*map_it_rob).second.begin(), + it_statusEnd = (*map_it_rob).second.end(); it_status != it_statusEnd; it_status++) { + if (*rob_it_status == *it_status) { + return(true); + } + } + } + // Check if there is a sub detector specific filter rule defined for this ROB Id and match the status code + FilterSubDetMap::iterator map_it_subdet = m_filterSubDetMap.find(tmpsrc.subdetector_id()); + if (map_it_subdet != m_filterSubDetMap.end()) { + for (std::vector<uint32_t>::const_iterator it_status = (*map_it_subdet).second.begin(), + it_statusEnd = (*map_it_subdet).second.end(); it_status != it_statusEnd; it_status++) { + if (*rob_it_status == *it_status) { + return(true); + } + } + } + return(false); +} +*/ + +FaserROBDataProviderSvc::EventCache::~EventCache() { + delete event; + //FaserROBDataProviderSvc::robmapClear( robmap ); +} + diff --git a/Event/FaserByteStreamCnvSvcBase/src/components/FaserByteStreamCnvSvcBase_entries.cxx b/Event/FaserByteStreamCnvSvcBase/src/components/FaserByteStreamCnvSvcBase_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a31a4f6b3fdeea4c712785cd7bf7915670f5f9a8 --- /dev/null +++ b/Event/FaserByteStreamCnvSvcBase/src/components/FaserByteStreamCnvSvcBase_entries.cxx @@ -0,0 +1,8 @@ +#include "FaserByteStreamCnvSvcBase/FaserByteStreamCnvSvcBase.h" +#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddressProviderSvc.h" +#include "FaserByteStreamCnvSvcBase/FaserROBDataProviderSvc.h" + +DECLARE_COMPONENT( FaserByteStreamCnvSvcBase ) +DECLARE_COMPONENT( FaserByteStreamAddressProviderSvc ) +DECLARE_COMPONENT( FaserROBDataProviderSvc ) +