From 697c4634e0f8e467cc2eb176a135faa45b7d2338 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Thu, 29 Oct 2020 21:33:45 -0400 Subject: [PATCH] SCT_RawDataByteStreamCnv: Use AthConstConverter. Use AthConstConverter base class. Further thread-safety cleanups and fixes. --- .../SCT_RawDataByteStreamCnv/CMakeLists.txt | 2 +- .../ISCTRawContByteStreamTool.h | 5 ++-- .../src/SCTRawContByteStreamCnv.cxx | 24 ++++++++----------- .../src/SCTRawContByteStreamCnv.h | 12 ++++------ .../src/SCTRawContByteStreamTool.cxx | 18 +++++++------- .../src/SCTRawContByteStreamTool.h | 18 +++++--------- 6 files changed, 32 insertions(+), 47 deletions(-) diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/CMakeLists.txt b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/CMakeLists.txt index 4d460a46a82..d083dfad182 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/CMakeLists.txt +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/CMakeLists.txt @@ -10,7 +10,7 @@ atlas_add_library( SCT_RawDataByteStreamCnvLib SCT_RawDataByteStreamCnv/*.h INTERFACE PUBLIC_HEADERS SCT_RawDataByteStreamCnv - LINK_LIBRARIES GaudiKernel InDetRawData ByteStreamCnvSvcBaseLib ByteStreamData InDetByteStreamErrors ) + LINK_LIBRARIES GaudiKernel InDetRawData ByteStreamCnvSvcBaseLib ByteStreamCnvSvcLib ByteStreamData InDetByteStreamErrors ) # Component(s) in the package: atlas_add_component( SCT_RawDataByteStreamCnv diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCTRawContByteStreamTool.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCTRawContByteStreamTool.h index 73d44d8a030..136ddf252cb 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCTRawContByteStreamTool.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCTRawContByteStreamTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** @@ -36,8 +36,7 @@ class ISCTRawContByteStreamTool : virtual public IAlgTool virtual ~ISCTRawContByteStreamTool() = default; /** Convert method */ - virtual StatusCode convert(const SCT_RDO_Container* sctRDOCont, - RawEventWrite* rawEvtWritecont, MsgStream& log) const = 0; + virtual StatusCode convert(const SCT_RDO_Container* sctRDOCont) const = 0; }; #endif // SCT_RAWDATABYTESTREAMCNV_ISCTRAWCONTBYTESTREAMTOOL_H diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.cxx index 6ef10c97447..5ddeec0540a 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.cxx +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "SCTRawContByteStreamCnv.h" @@ -18,10 +18,9 @@ // Constructor SCTRawContByteStreamCnv::SCTRawContByteStreamCnv(ISvcLocator* svcLoc) : - Converter(storageType(), classID(), svcLoc), + AthConstConverter(storageType(), classID(), svcLoc, "SCTRawContByteStreamCnv"), m_rawContByteStreamTool{"SCTRawContByteStreamTool"}, - m_byteStreamEventAccess{"ByteStreamCnvSvc", "SCTRawContByteStreamCnv"}, - m_log{msgSvc(), "SCTRawContByteStreamCnv"} + m_byteStreamEventAccess{"ByteStreamCnvSvc", "SCTRawContByteStreamCnv"} { } @@ -29,32 +28,29 @@ SCTRawContByteStreamCnv::SCTRawContByteStreamCnv(ISvcLocator* svcLoc) : StatusCode SCTRawContByteStreamCnv::initialize() { - ATH_CHECK(Converter::initialize()); - m_log << MSG::DEBUG<< " initialize " << endmsg; + ATH_CHECK(AthConstConverter::initialize()); + ATH_MSG_DEBUG( " initialize " ); // Retrieve ByteStreamCnvSvc ATH_CHECK(m_byteStreamEventAccess.retrieve()); - m_log << MSG::INFO << "Retrieved service " << m_byteStreamEventAccess << endmsg; + ATH_MSG_INFO( "Retrieved service " << m_byteStreamEventAccess ); // Retrieve byte stream tool ATH_CHECK(m_rawContByteStreamTool.retrieve()); - m_log << MSG::INFO << "Retrieved tool " << m_rawContByteStreamTool << endmsg; + ATH_MSG_INFO( "Retrieved tool " << m_rawContByteStreamTool ); return StatusCode::SUCCESS; } // Method to create RawEvent fragments -StatusCode SCTRawContByteStreamCnv::createRep(DataObject* pDataObject, IOpaqueAddress*& pOpaqueAddress) +StatusCode SCTRawContByteStreamCnv::createRepConst(DataObject* pDataObject, IOpaqueAddress*& pOpaqueAddress) const { - // Get RawEvent pointer - RawEventWrite* rawEvtWrite{m_byteStreamEventAccess->getRawEvent()}; - // Get IDC for SCT Raw Data SCT_RDO_Container* sctRDOCont{nullptr}; StoreGateSvc::fromStorable(pDataObject, sctRDOCont); if (sctRDOCont == nullptr) { - m_log << MSG::ERROR << " Can not cast to SCTRawContainer " << endmsg; + ATH_MSG_ERROR( " Can not cast to SCTRawContainer " ); return StatusCode::FAILURE; } @@ -63,7 +59,7 @@ StatusCode SCTRawContByteStreamCnv::createRep(DataObject* pDataObject, IOpaqueAd pOpaqueAddress = new ByteStreamAddress(classID(), dataObjectName, ""); // Use the tool to do the conversion - ATH_CHECK(m_rawContByteStreamTool->convert(sctRDOCont, rawEvtWrite, m_log)); + ATH_CHECK(m_rawContByteStreamTool->convert(sctRDOCont) ); return StatusCode::SUCCESS; } diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.h index a0961a4df39..3887138049d 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.h @@ -10,13 +10,12 @@ #include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" #include "ByteStreamCnvSvcBase/ByteStreamAddress.h" #include "InDetRawData/InDetRawDataCLASS_DEF.h" +#include "AthenaBaseComps/AthConstConverter.h" -#include "GaudiKernel/Converter.h" #include "GaudiKernel/ServiceHandle.h" class DataObject; class ISCTRawContByteStreamTool; -class MsgStream; /** * @class SCTRawContByteStreamCnv @@ -28,7 +27,7 @@ class MsgStream; * we use a tool (SCTRawContByteStreamTool) which in turn uses the lightweight * SCT_RodEncoder class, to do the actual converting. */ -class SCTRawContByteStreamCnv : public Converter +class SCTRawContByteStreamCnv : public AthConstConverter { public: @@ -49,7 +48,7 @@ class SCTRawContByteStreamCnv : public Converter static const CLID& classID() { return ClassID_traits<SCT_RDO_Container>::ID(); } /** createObj method (not used!) */ - virtual StatusCode createObj(IOpaqueAddress*, DataObject*&) override { return StatusCode::FAILURE; } + virtual StatusCode createObjConst(IOpaqueAddress*, DataObject*&) const override { return StatusCode::FAILURE; } /** * @brief Method to convert SCT Raw Data into ByteStream @@ -62,7 +61,7 @@ class SCTRawContByteStreamCnv : public Converter * @param pDataObject Pointer to data object. * @param pOpaqueAddress Opaque address to object. */ - virtual StatusCode createRep(DataObject* pDataObject, IOpaqueAddress*& pOpaqueAddress) override; + virtual StatusCode createRepConst(DataObject* pDataObject, IOpaqueAddress*& pOpaqueAddress) const override; private: @@ -71,9 +70,6 @@ class SCTRawContByteStreamCnv : public Converter /** Interface for accessing raw data */ ServiceHandle<IByteStreamEventAccess> m_byteStreamEventAccess; - - /** Object used to transmit messages and log errors */ - MsgStream m_log; }; #endif // SCT_RAWDATABYTESTREAMCNV_SCTRAWCONTBYTESTREAMCNV_H diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.cxx index ed2a6fcbf71..225f6858101 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.cxx +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "SCTRawContByteStreamTool.h" @@ -25,6 +25,8 @@ SCTRawContByteStreamTool::SCTRawContByteStreamTool(const std::string& type, cons StatusCode SCTRawContByteStreamTool::initialize() { + ATH_CHECK( m_byteStreamCnvSvc.retrieve() ); + // Retrieve ID mapping ATH_CHECK(m_cabling.retrieve()); ATH_MSG_INFO("Retrieved service " << m_cabling); @@ -44,16 +46,15 @@ StatusCode SCTRawContByteStreamTool::finalize() // Convert method -StatusCode SCTRawContByteStreamTool::convert(const SCT_RDO_Container* sctRDOCont, - RawEventWrite* rawEvtWrite, MsgStream& log) const +StatusCode SCTRawContByteStreamTool::convert(const SCT_RDO_Container* sctRDOCont) const { - std::lock_guard<std::mutex> lock{m_mutex}; - - m_fullEventAssembler.clear(); + FullEventAssembler<SrcIdMap>* fullEventAssembler = nullptr; + ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fullEventAssembler, + "SCTRawCont") ); FullEventAssembler<SrcIdMap>::RODDATA* rod; // Set ROD Minor version - m_fullEventAssembler.setRodMinorVersion(m_rodBlockVersion); + fullEventAssembler->setRodMinorVersion(m_rodBlockVersion); ATH_MSG_DEBUG(" Setting Minor Version Number to " << m_rodBlockVersion); // Mapping between ROD IDs and the hits in that ROD @@ -97,10 +98,9 @@ StatusCode SCTRawContByteStreamTool::convert(const SCT_RDO_Container* sctRDOCont // Now encode data for each ROD in turn for (auto rodToRDOs : rdoMap) { - rod = m_fullEventAssembler.getRodData(rodToRDOs.first); // Get ROD data address + rod = fullEventAssembler->getRodData(rodToRDOs.first); // Get ROD data address m_encoder->fillROD(*rod, rodToRDOs.first, rodToRDOs.second); // Encode ROD data } - m_fullEventAssembler.fill(rawEvtWrite, log); return StatusCode::SUCCESS; } diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h index b267ea6ae38..338c99062ec 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h @@ -11,10 +11,11 @@ #include "SCT_RawDataByteStreamCnv/ISCTRawContByteStreamTool.h" #include "ByteStreamCnvSvcBase/FullEventAssembler.h" +#include "ByteStreamCnvSvc/ByteStreamCnvSvc.h" #include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ServiceHandle.h" -#include <mutex> class ISCT_RodEncoder; class ISCT_CablingTool; @@ -56,13 +57,12 @@ class SCTRawContByteStreamTool : public extends<AthAlgTool, ISCTRawContByteStrea * using RodEncoder to fill data for each ROD in turn. * * @param sctRDOCont SCT RDO Container of Raw Data Collections. - * @param rawEvtWrite Data type for writing raw event. - * @param log Object used to transmit messages and log errors. * */ - virtual StatusCode convert(const SCT_RDO_Container* sctRDOCont, - RawEventWrite* rawEvtWrite, MsgStream& log) const override; + virtual StatusCode convert(const SCT_RDO_Container* sctRDOCont) const override; - private: + private: + ServiceHandle<ByteStreamCnvSvc> m_byteStreamCnvSvc + { this, "ByteStreamCnvSvc", "ByteStreamCnvSvc" }; /** Algorithm Tool to decode ROB bytestream data into RDO. */ ToolHandle<ISCT_RodEncoder> m_encoder{this, "Encoder", "SCT_RodEncoder", "SCT ROD Encoder for RDO to BS conversion"}; @@ -75,12 +75,6 @@ class SCTRawContByteStreamTool : public extends<AthAlgTool, ISCTRawContByteStrea const SCT_ID* m_sctIDHelper{nullptr}; UnsignedShortProperty m_rodBlockVersion{this, "RodBlockVersion", 0}; - - /** Conversion between Lower level Source ID to higher level source ID, used to assemble - fragments from ROD fragments to assemble full ATLAS raw events. */ - mutable FullEventAssembler<SrcIdMap> m_fullEventAssembler ATLAS_THREAD_SAFE; - - mutable std::mutex m_mutex{}; }; #endif // SCT_RAWDATABYTESTREAMCNV_SCTRAWCONTBYTESTREAMTOOL_H -- GitLab