diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/CMakeLists.txt b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/CMakeLists.txt index 3470f3657d5a00b0a93c62bdc495246106564e65..591ad7d1333af9c5280269189c05c9ceaef659f4 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/CMakeLists.txt +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/CMakeLists.txt @@ -18,4 +18,4 @@ atlas_add_component( TRT_RawDataByteStreamCnv src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} ${COOL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${CORAL_LIBRARIES} AthenaBaseComps AthenaKernel AthenaPoolUtilities ByteStreamCnvSvcBaseLib ByteStreamData CxxUtils GaudiKernel IRegionSelector Identifier InDetByteStreamErrors InDetIdentifier InDetRawData PathResolver StoreGateLib TRT_CablingLib TRT_RawDataByteStreamCnvLib TRT_ReadoutGeometry TrigSteeringEvent ) + LINK_LIBRARIES ${COOL_LIBRARIES} ${CORAL_LIBRARIES} AthenaBaseComps AthenaKernel AthenaPoolUtilities ByteStreamCnvSvcBaseLib ByteStreamCnvSvcLib ByteStreamData CxxUtils GaudiKernel IRegionSelector Identifier InDetByteStreamErrors InDetIdentifier InDetRawData PathResolver StoreGateLib TRT_CablingLib TRT_RawDataByteStreamCnvLib TRT_ReadoutGeometry TrigSteeringEvent ) diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRTRawContByteStreamTool.h b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRTRawContByteStreamTool.h index 21d25a7a177c2eb87d14c304498ae8281f339493..4c7e0d0c8d7559e05077725ef186f28f053a1660 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRTRawContByteStreamTool.h +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRTRawContByteStreamTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ITRT_RAWDATABYTESTREAMCNV_TRTRAWCONTRAWEVENTTOOL_H @@ -7,7 +7,6 @@ #include "AthenaBaseComps/AthAlgTool.h" -#include "ByteStreamData/RawEvent.h" #include "InDetRawData/TRT_RDO_Container.h" @@ -15,21 +14,13 @@ class ITRTRawContByteStreamTool: virtual public IAlgTool { public: - - static const InterfaceID& interfaceID( ) ; - + DeclareInterfaceID (ITRTRawContByteStreamTool, 1, 0); //! New convert method which makes use of the encoder class (as done for other detectors) - virtual StatusCode convert(TRT_RDO_Container* cont, RawEventWrite* re ) = 0; + virtual StatusCode convert(TRT_RDO_Container* cont) const = 0; }; -inline const InterfaceID& ITRTRawContByteStreamTool::interfaceID( ) -{ - static const InterfaceID IID ("ITRTRawContByteStreamTool", 1, 0); - return IID; -} - #endif diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRTRawDataProviderTool.h b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRTRawDataProviderTool.h index 012de8746a5657ba6bb13d374d944fa972737f16..076cc401037fb093714222fa58f5e127e95a5f2d 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRTRawDataProviderTool.h +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRTRawDataProviderTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ITRT_RAWDATABYTESTREAMCNV_TRTRAWDATAPROVIDERTOOL_H @@ -21,24 +21,15 @@ class ITRTRawDataProviderTool : virtual public IAlgTool { public: - - //! AlgTool InterfaceID - static const InterfaceID& interfaceID( ) ; - + DeclareInterfaceID (ITRTRawDataProviderTool, 1, 0); //! this is the main decoding method virtual StatusCode convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs, TRT_RDO_Container* rdoIdc, - TRT_BSErrContainer* bserr) = 0; + TRT_BSErrContainer* bserr) const = 0; }; -inline const InterfaceID& ITRTRawDataProviderTool::interfaceID( ) -{ - static const InterfaceID IID ("ITRTRawDataProviderTool", 1, 0); - return IID; -} - #endif diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRT_RodDecoder.h b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRT_RodDecoder.h index d2b9610566bcae4d5dca922f5c87a33eef8ac0be..7a976572722e5770af06b2c4582116d0aac887d0 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRT_RodDecoder.h +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/TRT_RawDataByteStreamCnv/ITRT_RodDecoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ITRT_RAWDATABYTESTREAMCNV_TRT_RODDECODER_H @@ -23,25 +23,15 @@ class ITRT_RodDecoder : virtual public IAlgTool { public: - - //! interfaceID - static const InterfaceID& interfaceID( ) ; - + DeclareInterfaceID( ITRT_RodDecoder, 1, 0 ); //! the method to fill the IDC virtual StatusCode fillCollection ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* robFrag, TRT_RDO_Container* rdoIdc, TRT_BSErrContainer* bsErr, - const std::vector<IdentifierHash>* vecHash = 0 ) = 0; + const std::vector<IdentifierHash>* vecHash = 0 ) const = 0; }; - -inline const InterfaceID& ITRT_RodDecoder::interfaceID( ) -{ - static const InterfaceID IID ("ITRT_RodDecoder", 1, 0); - return IID; -} - #endif diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamCnv.cxx b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamCnv.cxx index 76690246552ee259137b041773f0eea0cdc41fa1..fc7e392a66072475e79f407029b6dad598abe87d 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamCnv.cxx +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamCnv.cxx @@ -1,11 +1,11 @@ /* - 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 "TRTRawContByteStreamCnv.h" -#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" -#include "ByteStreamData/RawEvent.h" +#include "ByteStreamData/RawEvent.h" +#include "AthenaKernel/StorableConversions.h" #include "GaudiKernel/DataObject.h" #include "GaudiKernel/MsgStream.h" @@ -13,9 +13,8 @@ // constructor TRTRawContByteStreamCnv::TRTRawContByteStreamCnv(ISvcLocator* svcloc) : - Converter(storageType(), classID(),svcloc), - m_tool ("TRTRawContByteStreamTool"), // init tool handles - m_byteStreamEventAccess("ByteStreamCnvSvc","TRTRawContByteStreamCnv") // init service handle + AthConstConverter(storageType(), classID(),svcloc,"TRTRawContByteStreamCnv"), + m_tool ("TRTRawContByteStreamTool") // init tool handles {} // ------------------------------------------------------ @@ -24,27 +23,15 @@ TRTRawContByteStreamCnv::TRTRawContByteStreamCnv(ISvcLocator* svcloc) : StatusCode TRTRawContByteStreamCnv::initialize() { - StatusCode sc = Converter::initialize(); - if(StatusCode::SUCCESS!=sc) return sc; + ATH_CHECK( AthConstConverter::initialize() ); - MsgStream log(msgSvc(), "TRTRawContByteStreamCnv"); - log << MSG::DEBUG<< " initialize " <<endmsg; - - // Retrieve ByteStreamCnvSvc - if (m_byteStreamEventAccess.retrieve().isFailure()) { - log << MSG::FATAL << "Failed to retrieve service " << m_byteStreamEventAccess << endmsg; - return StatusCode::FAILURE; - } else - log << MSG::INFO << "Retrieved service " << m_byteStreamEventAccess << endmsg; + ATH_MSG_DEBUG( " initialize " ); // Retrieve byte stream tool - if (m_tool.retrieve().isFailure()) { - log << MSG::FATAL << "Failed to retrieve tool " << m_tool << endmsg; - return StatusCode::FAILURE; - } else - log << MSG::INFO << "Retrieved tool " << m_tool << endmsg; + ATH_CHECK( m_tool.retrieve() ); + ATH_MSG_INFO( "Retrieved tool " << m_tool ); - log << MSG::INFO << "Leaving TRTRawContByteStreamCnv::initialize()" << endmsg; + ATH_MSG_INFO( "Leaving TRTRawContByteStreamCnv::initialize()" ); return StatusCode::SUCCESS; } @@ -53,19 +40,13 @@ TRTRawContByteStreamCnv::initialize() // convert TRT Raw Data in the container into ByteStream StatusCode -TRTRawContByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr) +TRTRawContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const { - // message stream - MsgStream log(msgSvc(), "TRTRawContByteStreamCnv"); - - // get RawEvent pointer - RawEventWrite* re = m_byteStreamEventAccess->getRawEvent(); - // get IDC for TRT Raw Data TRT_RDO_Container* cont=0; - StoreGateSvc::fromStorable(pObj, cont); + SG::fromStorable(pObj, cont); if(!cont){ - log << MSG::ERROR << " Can not cast to TRTRawContainer " << endmsg ; + ATH_MSG_ERROR( " Can not cast to TRTRawContainer " ); return StatusCode::FAILURE; } @@ -74,12 +55,7 @@ TRTRawContByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr) pAddr = new ByteStreamAddress(classID(),nm,""); // now use the tool to do the conversion - StatusCode sc = m_tool->convert(cont, re ); - if(sc.isFailure()){ - log << MSG::ERROR - << " Could not convert rdo with TRTRawContByteStreamTool " << endmsg; - return StatusCode::FAILURE; - } + ATH_CHECK( m_tool->convert(cont) ); return StatusCode::SUCCESS ; } diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamCnv.h b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamCnv.h index a4e916183b2274c0f13d80adfbdab6495ba3e30f..58c6265b233a8a182f1375757c5ea345ea46f290 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamCnv.h +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamCnv.h @@ -1,16 +1,15 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef TRT_RAWDATABYTESTREAMCNV_TRTRAWCONTRAWEVENTCNV_H #define TRT_RAWDATABYTESTREAMCNV_TRTRAWCONTRAWEVENTCNV_H -#include "GaudiKernel/Converter.h" #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" #include "InDetRawData/InDetRawDataCLASS_DEF.h" -#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" #include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "AthenaBaseComps/AthConstConverter.h" #include "TRT_RawDataByteStreamCnv/ITRTRawContByteStreamTool.h" @@ -24,7 +23,7 @@ template <class TYPE> class CnvFactory; // the converter for writing BS from TRT Raw Data -class TRTRawContByteStreamCnv: public Converter { +class TRTRawContByteStreamCnv: public AthConstConverter { public: TRTRawContByteStreamCnv(ISvcLocator* svcloc); @@ -39,16 +38,15 @@ class TRTRawContByteStreamCnv: public Converter { virtual StatusCode initialize() override; //! create Obj is not used ! - virtual StatusCode createObj(IOpaqueAddress* /* pAddr */, DataObject*& /* pObj */) override + virtual StatusCode createObjConst(IOpaqueAddress* /* pAddr */, DataObject*& /* pObj */) const override { return StatusCode::FAILURE;} //! this creates the RawEvent fragments for the TRT - virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& pAddr) override; + virtual StatusCode createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const override; private: // for BS infrastructure ToolHandle<ITRTRawContByteStreamTool> m_tool; // ME: use tool handles - ServiceHandle<IByteStreamEventAccess> m_byteStreamEventAccess; // ME: use service handle }; #endif diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamTool.cxx b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamTool.cxx index fa484a2322281678382e6e415bf02707cf5571cc..9778d770740344bce189a81b6d82b22013eebec9 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamTool.cxx +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "TRTRawContByteStreamTool.h" @@ -21,7 +21,7 @@ TRTRawContByteStreamTool::TRTRawContByteStreamTool ( const std::string& type, const std::string& name,const IInterface* parent ) - : AthAlgTool(type,name,parent), + : base_class(type,name,parent), m_trt_CablingSvc ("TRT_CablingSvc", name ), m_trt_idHelper(nullptr) { @@ -45,31 +45,16 @@ TRTRawContByteStreamTool::~TRTRawContByteStreamTool() StatusCode TRTRawContByteStreamTool::initialize() { - StatusCode sc = AlgTool::initialize(); - if (sc.isFailure()) - { - ATH_MSG_FATAL( "Failed to init baseclass" ); - return StatusCode::FAILURE; - } - - // Retrieve id mapping - if (m_trt_CablingSvc.retrieve().isFailure()) - { - ATH_MSG_FATAL( "Failed to retrieve tool " << m_trt_CablingSvc ); - return StatusCode::FAILURE; - } else - ATH_MSG_INFO( "Retrieved tool " << m_trt_CablingSvc ); - - - // Get the TRT Helper - if (detStore()->retrieve(m_trt_idHelper, "TRT_ID").isFailure()) - { - ATH_MSG_FATAL( "Could not get TRT ID helper" ); - return StatusCode::FAILURE; - } + ATH_CHECK( AlgTool::initialize() ); + ATH_CHECK( m_trt_CablingSvc.retrieve() ); + ATH_MSG_INFO( "Retrieved tool " << m_trt_CablingSvc ); - return sc; + ATH_CHECK( detStore()->retrieve(m_trt_idHelper, "TRT_ID") ); + + ATH_CHECK( m_byteStreamCnvSvc.retrieve() ); + + return StatusCode::SUCCESS; } // ------------------------------------------------------------------------ @@ -78,10 +63,8 @@ TRTRawContByteStreamTool::initialize() StatusCode TRTRawContByteStreamTool::finalize() { - StatusCode sc = AlgTool::finalize(); - - - return sc; + ATH_CHECK( AlgTool::finalize() ); + return StatusCode::SUCCESS; } // ------------------------------------------------------------------------ @@ -89,15 +72,17 @@ TRTRawContByteStreamTool::finalize() // other detectors) StatusCode -TRTRawContByteStreamTool::convert(TRT_RDO_Container* cont, RawEventWrite* re ) +TRTRawContByteStreamTool::convert(TRT_RDO_Container* cont) const { StatusCode sc(StatusCode::SUCCESS); - m_fea.clear(); + FullEventAssembler<SrcIdMap>* fea = nullptr; + ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fea, + "TRTRawCont") ); FullEventAssembler<SrcIdMap>::RODDATA* theROD ; // set ROD Minor version - m_fea.setRodMinorVersion(m_RodBlockVersion); + fea->setRodMinorVersion(m_RodBlockVersion); ATH_MSG_DEBUG( " Setting Minor Version Number to "<<m_RodBlockVersion ); // a map for ROD ID onto Encoder @@ -157,7 +142,7 @@ TRTRawContByteStreamTool::convert(TRT_RDO_Container* cont, RawEventWrite* re ) theEncoder.set_trt_cabling (m_trt_CablingSvc); theEncoder.setRodMinorVersion(m_RodBlockVersion); // use encoder to get ROD fragment data - theROD = m_fea.getRodData((*it_map).first); // get ROD data address + theROD = fea->getRodData((*it_map).first); // get ROD data address if ( 1 == m_RodBlockVersion ) @@ -177,9 +162,6 @@ TRTRawContByteStreamTool::convert(TRT_RDO_Container* cont, RawEventWrite* re ) ATH_MSG_WARNING( "TRT ROD Encoder has RECOVERABLE error" ); - // Finally, fill full event - m_fea.fill( re, msg() ); - return sc; } diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamTool.h b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamTool.h index c2fe7518ad95465a3ef1fade28d8d311a1fa47d9..f4aff54a35f6e05effa30ff982a7a1e298c22c1c 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamTool.h +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawContByteStreamTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef TRT_RAWDATABYTESTREAMCNV_TRTRAWCONTRAWEVENTTOOL_H @@ -15,6 +15,7 @@ #include "ByteStreamCnvSvcBase/FullEventAssembler.h" #include "ByteStreamCnvSvcBase/SrcIdMap.h" +#include "ByteStreamCnvSvc/ByteStreamCnvSvc.h" class TRT_ID; @@ -29,7 +30,7 @@ class TRT_ID; StatusCode convert(CONTAINER* cont, RawEvent* re, MsgStream& log ); */ -class TRTRawContByteStreamTool: virtual public ITRTRawContByteStreamTool, public AthAlgTool +class TRTRawContByteStreamTool: public extends<AthAlgTool, ITRTRawContByteStreamTool> { public: @@ -47,18 +48,20 @@ class TRTRawContByteStreamTool: virtual public ITRTRawContByteStreamTool, public //! destructor virtual ~TRTRawContByteStreamTool() ; - virtual StatusCode initialize(); - virtual StatusCode finalize(); + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; //! New convert method which makes use of the encoder class (as done for other detectors) - StatusCode convert(TRT_RDO_Container* cont, RawEventWrite* re ); + virtual StatusCode convert(TRT_RDO_Container* cont) const override; private: - ServiceHandle<ITRT_CablingSvc> m_trt_CablingSvc; + ServiceHandle<ByteStreamCnvSvc> m_byteStreamCnvSvc + { this, "ByteStreamCnvSvc", "ByteStreamCnvSvc" }; + + ServiceHandle<ITRT_CablingSvc> m_trt_CablingSvc; const TRT_ID* m_trt_idHelper; unsigned short m_RodBlockVersion; - FullEventAssembler<SrcIdMap> m_fea; }; #endif diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawDataProviderTool.cxx b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawDataProviderTool.cxx index a8b820d2dacee9765b563f9b3316068be5612df7..45e120bcdfe0fd97b8d2c3c98a949cfd1772a00b 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawDataProviderTool.cxx +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawDataProviderTool.cxx @@ -24,7 +24,7 @@ using OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment; TRTRawDataProviderTool::TRTRawDataProviderTool ( const std::string& type, const std::string& name,const IInterface* parent ) - : AthAlgTool( type, name, parent ), + : base_class( type, name, parent ), m_decoder ("TRT_RodDecoder",this), m_storeInDetTimeColls(true), m_doEventCheck(true) @@ -32,8 +32,6 @@ TRTRawDataProviderTool::TRTRawDataProviderTool declareProperty ("Decoder", m_decoder); declareProperty ("StoreInDetTimeCollections", m_storeInDetTimeColls); declareProperty ("checkLVL1ID", m_doEventCheck); - - declareInterface< ITRTRawDataProviderTool >( this ); } // ------------------------------------------------------- @@ -48,21 +46,10 @@ TRTRawDataProviderTool::~TRTRawDataProviderTool() StatusCode TRTRawDataProviderTool::initialize() { - StatusCode sc = AlgTool::initialize(); - if (sc.isFailure()) - { - ATH_MSG_FATAL( "Failed to init baseclass" ); - return StatusCode::FAILURE; - } - - // Retrieve decoder - if (m_decoder.retrieve().isFailure()) { - ATH_MSG_FATAL( "Failed to retrieve tool " << m_decoder ); - return StatusCode::FAILURE; - } else - ATH_MSG_INFO( "Retrieved tool " << m_decoder ); - + ATH_CHECK( AlgTool::initialize() ); + ATH_CHECK( m_decoder.retrieve() ); + ATH_MSG_INFO( "Retrieved tool " << m_decoder ); //initialize write handles ATH_CHECK(m_lvl1idkey.initialize()); @@ -76,8 +63,8 @@ StatusCode TRTRawDataProviderTool::initialize() StatusCode TRTRawDataProviderTool::finalize() { - StatusCode sc = AlgTool::finalize(); - return sc; + ATH_CHECK( AlgTool::finalize() ); + return StatusCode::SUCCESS; } // ------------------------------------------------------- @@ -85,7 +72,7 @@ StatusCode TRTRawDataProviderTool::finalize() StatusCode TRTRawDataProviderTool::convert(const std::vector<const ROBFragment*>& vecRobs, TRT_RDO_Container* rdoIdc, - TRT_BSErrContainer* bserr) + TRT_BSErrContainer* bserr) const { static std::atomic_int DecodeErrCount = 0; diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawDataProviderTool.h b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawDataProviderTool.h index ff8fb2105241218700a684f1166eb054c0478c92..7f5bfdff43fd94eed54166cdd71536627ca54e62 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawDataProviderTool.h +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRTRawDataProviderTool.h @@ -24,15 +24,9 @@ class TRT_BSErrorContainer; -class TRTRawDataProviderTool : virtual public ITRTRawDataProviderTool, - public AthAlgTool +class TRTRawDataProviderTool : public extends<AthAlgTool, ITRTRawDataProviderTool> { - public: - - //! AlgTool InterfaceID - static const InterfaceID& interfaceID( ) ; - //! constructor TRTRawDataProviderTool( const std::string& type, const std::string& name, const IInterface* parent ) ; @@ -50,11 +44,9 @@ class TRTRawDataProviderTool : virtual public ITRTRawDataProviderTool, virtual StatusCode convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs, TRT_RDO_Container* rdoIdc, TRT_BSErrContainer* bsErrCont - ) override; + ) const override; private: - TRTRawDataProviderTool( ); //Not implemented - ToolHandle<ITRT_RodDecoder> m_decoder; // bookkeeping if we have decoded a ROB already diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRT_RodDecoder.cxx b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRT_RodDecoder.cxx index a89fb9bac5140a06e752844bfcfb2f97cb72d4b1..57be868cfb65c5b3d55f575e7dff9362471bb36a 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRT_RodDecoder.cxx +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRT_RodDecoder.cxx @@ -43,7 +43,7 @@ using OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment; TRT_RodDecoder::TRT_RodDecoder ( const std::string& type, const std::string& name,const IInterface* parent ) - : AthAlgTool ( type,name,parent ), + : base_class ( type,name,parent ), m_CablingSvc ( "TRT_CablingSvc", name ), // m_bsErrSvc ( "TRT_ByteStream_ConditionsSvc", name ), m_recordBSErrors ( true ), @@ -74,13 +74,6 @@ TRT_RodDecoder::TRT_RodDecoder declareProperty ( "LoadCompressTableDB", m_loadCompressTableDB ); declareProperty ( "ForceRodVersion", m_forceRodVersion ); declareProperty ( "LoadCompressTableVersions", m_LoadCompressTableVersions ); - - for (int i=0; i<256; i++) - m_compressTableLoaded[i] = false; - - - declareInterface<ITRT_RodDecoder>( this ); - } /* ---------------------------------------------------------- @@ -99,45 +92,31 @@ TRT_RodDecoder::~TRT_RodDecoder() StatusCode TRT_RodDecoder::initialize() { ATH_MSG_DEBUG( " initialize " ); - StatusCode sc; - sc = AlgTool::initialize(); - if (sc.isFailure()) - { - ATH_MSG_FATAL( "Failed to init baseclass" ); - return StatusCode::FAILURE; + ATH_CHECK( AlgTool::initialize() ); + + m_CompressionTables.resize (m_maxCompressionVersion+1); + for (std::atomic<EventContext::ContextEvt_t>& evt : m_lastPrint) { + evt = EventContext::INVALID_CONTEXT_EVT; } /* * Retrieve id mapping */ - if ( m_CablingSvc.retrieve().isFailure() ) - { - ATH_MSG_FATAL( "Failed to retrieve tool " << m_CablingSvc ); - return StatusCode::FAILURE; - } else - ATH_MSG_INFO( "Retrieved tool " << m_CablingSvc ); + ATH_CHECK ( m_CablingSvc.retrieve() ); + ATH_MSG_INFO( "Retrieved tool " << m_CablingSvc ); /* * get detector manager */ - const InDetDD::TRT_DetectorManager* indet_mgr; - sc = detStore()->retrieve(indet_mgr,"TRT"); - if (sc.isFailure()) - { - ATH_MSG_FATAL( "Cannot retrieve TRT_DetectorManager!" ); - return StatusCode::FAILURE; - } + const InDetDD::TRT_DetectorManager* indet_mgr; + ATH_CHECK( detStore()->retrieve(indet_mgr,"TRT") ); // get the helper - if (detStore()->retrieve(m_trt_id, "TRT_ID").isFailure()) - { - ATH_MSG_FATAL( "Could not get TRT ID helper" ); - return StatusCode::FAILURE; - } + ATH_CHECK( detStore()->retrieve(m_trt_id, "TRT_ID") ); m_straw_layer_context = m_trt_id->straw_layer_context(); @@ -200,7 +179,7 @@ StatusCode TRT_RodDecoder::initialize() ATH_MSG_INFO( "Reading Compress Table: " << compressTableFile ); - sc = ReadCompressTableFile( compressTableFile ); + ATH_CHECK( ReadCompressTableFile( compressTableFile ) ); } } } @@ -215,7 +194,7 @@ StatusCode TRT_RodDecoder::initialize() ATH_MSG_WARNING( "****************************" ); } - return sc; + return StatusCode::SUCCESS; } @@ -226,8 +205,6 @@ StatusCode TRT_RodDecoder::initialize() StatusCode TRT_RodDecoder::finalize() { ATH_MSG_VERBOSE( "in TRT_RodDecoder::finalize" ); - for(auto &pair : m_CompressionTables) delete pair.second; - m_CompressionTables.clear(); ATH_MSG_INFO( "Number of TRT RDOs created: " << m_Nrdos ); return StatusCode::SUCCESS; @@ -250,10 +227,8 @@ StatusCode TRT_RodDecoder::fillCollection ( const ROBFragment* robFrag, TRT_RDO_Container* rdoIdc, TRT_BSErrContainer* bsErr, - const std::vector<IdentifierHash>* vecHash ) + const std::vector<IdentifierHash>* vecHash ) const { - - std::lock_guard<std::mutex> lock(m_cacheMutex); // update compression tables StatusCode sc; if(m_loadCompressTableDB) sc = update(); @@ -286,23 +261,16 @@ TRT_RodDecoder::fillCollection ( const ROBFragment* robFrag, /* - * This is a hack to only print once per event. It will work the - * vast majority of the time, but it may miss an occasional event. + * This is a hack to only print once per event. */ const EventContext& ctx{Gaudi::Hive::currentContext()}; - CacheEntry* ent{m_cache.get(ctx)}; - if (ent->m_evt!=ctx.evt()) { // New event in this slot - ent->reset(); - ent->m_evt = ctx.evt(); - } - - if ( (ent->Last_print_L1ID != robFrag->rod_lvl1_id()) || - (ent->Last_print_BCID != robFrag->rod_bc_id()) ) - { - ent->Last_print_L1ID = robFrag->rod_lvl1_id(); - ent->Last_print_BCID = robFrag->rod_bc_id(); - + std::atomic<EventContext::ContextEvt_t>* evt = m_lastPrint.get(); + EventContext::ContextEvt_t lastEvt = *evt; + while (lastEvt != ctx.evt() && !evt->compare_exchange_strong (lastEvt, ctx.evt())) + ; + if (lastEvt != ctx.evt()) { // New event in this slot + *evt = ctx.evt(); ATH_MSG_INFO( "Non-Zero ROB status word for ROB " << MSG::hex << robFrag->rob_source_id() @@ -320,9 +288,9 @@ TRT_RodDecoder::fillCollection ( const ROBFragment* robFrag, // get version to decide which method to use to decode ! if ( 3 < RodBlockVersion && m_maxCompressionVersion >= RodBlockVersion ) // Full Compression { - if ( m_compressTableLoaded[RodBlockVersion] ) + if ( m_CompressionTables[RodBlockVersion] ) sc = int_fillFullCompress( robFrag, rdoIdc, - m_CompressionTables[RodBlockVersion], + *m_CompressionTables[RodBlockVersion], vecHash ); else { @@ -532,7 +500,7 @@ TRT_RodDecoder::fillCollection ( const ROBFragment* robFrag, StatusCode TRT_RodDecoder::int_fillExpanded( const ROBFragment* robFrag, TRT_RDO_Container* rdoIdc, - const std::vector<IdentifierHash>* vecHash ) + const std::vector<IdentifierHash>* vecHash ) const { // get the ROBid uint32_t robid = robFrag->rod_source_id(); @@ -711,7 +679,7 @@ TRT_RodDecoder::int_fillExpanded( const ROBFragment* robFrag, StatusCode TRT_RodDecoder::int_fillMinimalCompress( const ROBFragment *robFrag, TRT_RDO_Container* rdoIdc, - const std::vector<IdentifierHash>* vecHash) + const std::vector<IdentifierHash>* vecHash) const { uint32_t robid = robFrag->rod_source_id(); @@ -943,8 +911,8 @@ TRT_RodDecoder::int_fillMinimalCompress( const ROBFragment *robFrag, StatusCode TRT_RodDecoder::int_fillFullCompress( const ROBFragment *robFrag, TRT_RDO_Container* rdoIdc, - t_CompressTable* Ctable, - const std::vector<IdentifierHash>* vecHash) + const t_CompressTable& Ctable, + const std::vector<IdentifierHash>* vecHash) const { int phase; for ( phase=0; phase<2; phase++ ) @@ -1010,9 +978,9 @@ TRT_RodDecoder::int_fillFullCompress( const ROBFragment *robFrag, l = 1; //ATH_MSG_INFO( "l, firstcode, v " << l << " " - // << MSG::hex << Ctable->m_firstcode[l] << " " << v << MSG::dec ); + // << MSG::hex << Ctable.m_firstcode[l] << " " << v << MSG::dec ); - while ( v < Ctable->m_firstcode[l] ) + while ( v < Ctable.m_firstcode[l] ) { v = 2 * v + ((vint[in_ptr] >> bit) & 0x1); @@ -1027,17 +995,17 @@ TRT_RodDecoder::int_fillFullCompress( const ROBFragment *robFrag, l++; //ATH_MSG_INFO( "l, firstcode, v " << l << " " - // << MSG::hex << Ctable->m_firstcode[l] << " " << v << MSG::dec ); + // << MSG::hex << Ctable.m_firstcode[l] << " " << v << MSG::dec ); } - int idx = Ctable->m_lengths_integral[l] + (v - Ctable->m_firstcode[l]); + int idx = Ctable.m_lengths_integral[l] + (v - Ctable.m_firstcode[l]); //ATH_MSG_INFO ( "lengths_int, idx, syms " << - // Ctable->m_lengths_integral[l] << " " << idx << " " << MSG::hex << - // idx << " " << Ctable->m_syms[idx] << MSG::dec ); + // Ctable.m_lengths_integral[l] << " " << idx << " " << MSG::hex << + // idx << " " << Ctable.m_syms[idx] << MSG::dec ); - if ( idx <= Ctable->m_Nsymbols ) - word = Ctable->m_syms[idx]; + if ( idx <= Ctable.m_Nsymbols ) + word = Ctable.m_syms[idx]; else { if ( m_err_count_int_fillFullCompress < 100 ) @@ -1233,7 +1201,7 @@ TableFilename #ifdef TRT_READCOMPTABLE_FILE - t_CompressTable *Ctable = new t_CompressTable; + auto t_CompressTable Ctable = std::make_unique<t_CompressTable>(); ATH_MSG_INFO( "Reading Compress Table File: " << TableFilename ); @@ -1244,9 +1212,6 @@ TableFilename { ATH_MSG_FATAL( "Could not open Compression Table File " << TableFilename ); - - delete Ctable; - return StatusCode::FAILURE; } @@ -1298,8 +1263,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1342,8 +1305,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1374,8 +1335,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1408,8 +1367,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } } @@ -1425,8 +1382,6 @@ TableFilename if ( lengths ) delete[] lengths; - delete Ctable; - return StatusCode::FAILURE; } @@ -1460,8 +1415,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1500,8 +1453,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1540,8 +1491,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1558,8 +1507,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1592,8 +1539,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1615,8 +1560,6 @@ TableFilename if( codewords ) delete[] codewords; - delete Ctable; - return StatusCode::FAILURE; } @@ -1676,24 +1619,19 @@ TableFilename ATH_MSG_WARNING( "Invalid Compression Table Version: " << Ctable->m_TableVersion ); - delete Ctable; - return StatusCode::FAILURE; } - if ( m_compressTableLoaded[Ctable->m_TableVersion] ) + if ( m_CompressionTables[Ctable->m_TableVersion] ) { ATH_MSG_WARNING( "Table " << Ctable->m_TableVersion << " already loaded! Not overwriting" ); - delete Ctable; } else { - m_CompressionTables[Ctable->m_TableVersion] = Ctable; ATH_MSG_INFO( "Loaded Compress Table Version: " << Ctable->m_TableVersion ); - - m_compressTableLoaded[Ctable->m_TableVersion] = true; + m_CompressionTables[Ctable->m_TableVersion].store (std::move(Ctable)) } @@ -1709,8 +1647,8 @@ TableFilename * Read Compression Table from DB on IOV change */ StatusCode -TRT_RodDecoder::update() { - +TRT_RodDecoder::update() const +{ /* * function to update compression table when condDB data changes: */ @@ -1729,37 +1667,34 @@ TRT_RodDecoder::update() { while ( catrIt != last_catr ) { - t_CompressTable *Ctable = new t_CompressTable; - const coral::AttributeList& atrlist = catrIt->second; - Ctable->m_TableVersion = (atrlist)["Version"].data<cool::Int32>(); - + int TableVersion = (atrlist)["Version"].data<cool::Int32>(); - if ( Ctable->m_TableVersion > m_maxCompressionVersion ) + if ( TableVersion > m_maxCompressionVersion ) { ATH_MSG_WARNING( "Invalid Compression Table Version: " << - Ctable->m_TableVersion ); + TableVersion ); - delete Ctable; ++catrIt; continue; } - if ( m_compressTableLoaded[Ctable->m_TableVersion] ) + if ( m_CompressionTables[TableVersion] ) { - ATH_MSG_DEBUG( "Table " << Ctable->m_TableVersion + ATH_MSG_DEBUG( "Table " << TableVersion << " already loaded! Not overwriting" ); - delete Ctable; ++catrIt; continue; } + auto Ctable = std::make_unique<t_CompressTable>(); + Ctable->m_TableVersion = TableVersion; Ctable->m_Nsymbols = (atrlist)["Nsymbols"].data<cool::Int32>(); ATH_MSG_DEBUG( "Nsymbols = " << Ctable->m_Nsymbols ); @@ -1775,8 +1710,6 @@ TRT_RodDecoder::update() { << (Ctable->m_Nsymbols * sizeof(unsigned int)) << " )" ); - delete Ctable; - return StatusCode::FAILURE; } @@ -1808,13 +1741,6 @@ TRT_RodDecoder::update() { } - m_CompressionTables[Ctable->m_TableVersion] = Ctable; - ATH_MSG_INFO( "Loaded Compress Table Version: " << - Ctable->m_TableVersion ); - - m_compressTableLoaded[Ctable->m_TableVersion] = true; - - #ifdef NOTDEF if ( 0 ) { @@ -1843,6 +1769,11 @@ TRT_RodDecoder::update() { } #endif /* NOTDEF */ + ATH_MSG_INFO( "Loaded Compress Table Version: " << + Ctable->m_TableVersion ); + m_CompressionTables[Ctable->m_TableVersion].set (std::move(Ctable)); + + ++catrIt; } diff --git a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRT_RodDecoder.h b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRT_RodDecoder.h index d0b7b9bfc648f54445421689120ee1d6adf1e519..c32714ca7fb7ffa4b37189b081878283639ff038 100644 --- a/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRT_RodDecoder.h +++ b/InnerDetector/InDetEventCnv/TRT_RawDataByteStreamCnv/src/TRT_RodDecoder.h @@ -32,6 +32,7 @@ #include "GaudiKernel/ICondSvc.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "StoreGate/ReadCondHandleKey.h" +#include "CxxUtils/CachedUniquePtr.h" #include "CoralBase/Attribute.h" @@ -51,20 +52,13 @@ */ #include <atomic> #include <map> -#include <mutex> #include <vector> // the tool to decode a ROB frament -class TRT_RodDecoder : virtual public ITRT_RodDecoder, - public AthAlgTool +class TRT_RodDecoder : public extends<AthAlgTool, ITRT_RodDecoder> { - public: - - //! AlgTool InterfaceID - static const InterfaceID& interfaceID( ) ; - //! constructor TRT_RodDecoder(const std::string& type, const std::string& name, const IInterface* parent ) ; @@ -79,7 +73,7 @@ public: virtual StatusCode fillCollection ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* robFrag, TRT_RDO_Container* rdoIdc, TRT_BSErrContainer* bserr, - const std::vector<IdentifierHash>* vecHash = 0) override; + const std::vector<IdentifierHash>* vecHash = 0) const override; private: @@ -104,7 +98,6 @@ public: bool m_loadCompressTableDB; std::vector<int> m_LoadCompressTableVersions; const int m_maxCompressionVersion; - bool m_compressTableLoaded[256]; int m_forceRodVersion; const TRT_ID* m_trt_id; @@ -132,11 +125,9 @@ public: int m_Nsymbols; } t_CompressTable; - // t_CompressTable m_CTable; - // t_CompressTable *m_CompressionTables[16]; - std::map<const int, t_CompressTable *>m_CompressionTables; + std::vector<CxxUtils::CachedUniquePtr<t_CompressTable> > m_CompressionTables; - uint32_t m_Nrdos; // Number of RDOs created + mutable std::atomic<uint32_t> m_Nrdos; // Number of RDOs created mutable std::atomic<int> m_err_count_fillCollection{0}; mutable std::atomic<int> m_err_count_int_fillMinimalCompress{0}; @@ -144,39 +135,28 @@ public: // This replaces the IOVCALLBACK SG::ReadCondHandleKey<CondAttrListCollection> m_CompressKey{this,"keyName","/TRT/Onl/ROD/Compress","in-key"}; - mutable std::mutex m_cacheMutex; - StatusCode update(); + StatusCode update() const; //! private methods private: StatusCode int_fillExpanded ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* robFrag, TRT_RDO_Container* rodIdc, - const std::vector<IdentifierHash>* vecHash = 0); + const std::vector<IdentifierHash>* vecHash = 0) const; StatusCode int_fillMinimalCompress ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* robFrag, TRT_RDO_Container* rdoIdo, - const std::vector<IdentifierHash>* vecHash = 0); + const std::vector<IdentifierHash>* vecHash = 0) const; StatusCode int_fillFullCompress ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* robFrag, TRT_RDO_Container* rdoIdo, - t_CompressTable* Ctable, - const std::vector<IdentifierHash>* vecHash = 0); + const t_CompressTable& Ctable, + const std::vector<IdentifierHash>* vecHash = 0) const; StatusCode ReadCompressTableFile( std::string TableFilename ); StatusCode ReadCompressTableDB( std::string Tag ); - // Struct for event cache - struct CacheEntry { - EventContext::ContextEvt_t m_evt{EventContext::INVALID_CONTEXT_EVT}; - uint32_t Last_print_L1ID = 0xffffffff; - uint32_t Last_print_BCID = 0xffffffff; - void reset() { - Last_print_L1ID = 0xffffffff; - Last_print_BCID = 0xffffffff; - } - }; - mutable SG::SlotSpecificObj<CacheEntry> m_cache ATLAS_THREAD_SAFE; // Guarded by m_cacheMutex + mutable SG::SlotSpecificObj<std::atomic<EventContext::ContextEvt_t> > m_lastPrint ATLAS_THREAD_SAFE; };