diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/MuonSTGC_CnvTools/ATLAS_CHECK_THREAD_SAFETY b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/MuonSTGC_CnvTools/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..b7145fa6fabbab22888c3fe58964df4de4e3d50a --- /dev/null +++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/MuonSTGC_CnvTools/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx index c249d49651457e7013b75e3c8ca33fbc45fa1047..b6b509d138b69817d30178a751e57f3e18a99d97 100644 --- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx @@ -5,7 +5,6 @@ #include "../STGC_RDO_Decoder.h" DECLARE_COMPONENT( Muon::sTgcRdoToPrepDataTool ) -DECLARE_COMPONENT( Muon::sTgcRdoToPrepDataToolCore ) DECLARE_COMPONENT( Muon::sTgcRdoToPrepDataToolMT ) DECLARE_COMPONENT( Muon::STGC_RawDataProviderTool ) DECLARE_COMPONENT( Muon::STGC_RDO_Decoder ) diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.cxx b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.cxx index fab1e0957ad765e5cbe24aa956723b7c2dab6061..3ecf3b4989a13c3791a0c1341b244e0cf17b7c7e 100644 --- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.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 */ /////////////////////////////////////////////////////////////////// @@ -27,22 +27,19 @@ StatusCode Muon::sTgcRdoToPrepDataTool::initialize() return StatusCode::SUCCESS; } -Muon::sTgcRdoToPrepDataToolCore::SetupSTGC_PrepDataContainerStatus Muon::sTgcRdoToPrepDataTool::setupSTGC_PrepDataContainer() +Muon::sTgcPrepDataContainer* Muon::sTgcRdoToPrepDataTool::setupSTGC_PrepDataContainer() const { if(!evtStore()->contains<Muon::sTgcPrepDataContainer>(m_stgcPrepDataContainerKey.key())){ - m_fullEventDone=false; - SG::WriteHandle< Muon::sTgcPrepDataContainer > handle(m_stgcPrepDataContainerKey); StatusCode status = handle.record(std::make_unique<Muon::sTgcPrepDataContainer>(m_idHelperSvc->stgcIdHelper().module_hash_max())); if (status.isFailure() || !handle.isValid() ) { ATH_MSG_FATAL("Could not record container of STGC PrepData Container at " << m_stgcPrepDataContainerKey.key()); - return FAILED; + return nullptr; } m_stgcPrepDataContainer = handle.ptr(); - return ADDED; } - return ALREADYCONTAINED; + return m_stgcPrepDataContainer; } diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.h b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.h index 20efd765bad9cebe55544c994a3d15e4a8d8ffa8..177450d26bfa5c31a0ca4532533761d5eaa10395 100644 --- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.h +++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.h @@ -6,6 +6,7 @@ #define MUONTGC_CNVTOOLS_STGCRDOTOPREPDATATOOL #include "sTgcRdoToPrepDataToolCore.h" +#include "CxxUtils/checker_macros.h" namespace Muon { @@ -13,7 +14,7 @@ namespace Muon * This is the algorithm that convert STGC Raw data To STGC PRD as a tool. */ - class sTgcRdoToPrepDataTool : virtual public sTgcRdoToPrepDataToolCore + class ATLAS_NOT_THREAD_SAFE sTgcRdoToPrepDataTool : virtual public sTgcRdoToPrepDataToolCore { public: /** Constructor */ @@ -26,7 +27,10 @@ namespace Muon virtual StatusCode initialize() override; protected: - virtual SetupSTGC_PrepDataContainerStatus setupSTGC_PrepDataContainer() override; + virtual Muon::sTgcPrepDataContainer* setupSTGC_PrepDataContainer() const override; + + private: + mutable Muon::sTgcPrepDataContainer* m_stgcPrepDataContainer = nullptr; }; } // end of namespace diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.cxx b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.cxx index e4dd433516c93ffbce23291c1f98fb50219e0b51..86b35a3f8035fe37a9bd7c5fcbe784e9483a5123 100644 --- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.cxx @@ -12,9 +12,7 @@ using namespace Trk; using namespace Muon; Muon::sTgcRdoToPrepDataToolCore::sTgcRdoToPrepDataToolCore(const std::string& t, const std::string& n, const IInterface* p) : - AthAlgTool(t,n,p), - m_fullEventDone(false), - m_stgcPrepDataContainer(0) + AthAlgTool(t,n,p) { declareInterface<Muon::IMuonRdoToPrepDataTool>(this); @@ -38,7 +36,8 @@ StatusCode Muon::sTgcRdoToPrepDataToolCore::initialize() return StatusCode::SUCCESS; } -StatusCode Muon::sTgcRdoToPrepDataToolCore::processCollection(const STGC_RawDataCollection *rdoColl, std::vector<IdentifierHash>& idWithDataVect) +StatusCode Muon::sTgcRdoToPrepDataToolCore::processCollection(Muon::sTgcPrepDataContainer* stgcPrepDataContainer, + const STGC_RawDataCollection *rdoColl, std::vector<IdentifierHash>& idWithDataVect) const { const IdentifierHash hash = rdoColl->identifyHash(); @@ -48,7 +47,7 @@ StatusCode Muon::sTgcRdoToPrepDataToolCore::processCollection(const STGC_RawData sTgcPrepDataCollection* prdColl = nullptr; // check if the collection already exists, otherwise add it - if ( m_stgcPrepDataContainer->indexFindPtr(hash) != nullptr ) { + if ( stgcPrepDataContainer->indexFindPtr(hash) != nullptr ) { ATH_MSG_DEBUG("In processCollection: collection already contained in the MM PrepData container"); return StatusCode::FAILURE; @@ -68,7 +67,7 @@ StatusCode Muon::sTgcRdoToPrepDataToolCore::processCollection(const STGC_RawData prdColl->setIdentifier(moduleId); } - if (StatusCode::SUCCESS != m_stgcPrepDataContainer->addCollection(prdColl, hash)) { + if (StatusCode::SUCCESS != stgcPrepDataContainer->addCollection(prdColl, hash)) { ATH_MSG_DEBUG("In processCollection - Couldn't record in the Container MM Collection with hashID = " << (int)hash ); return StatusCode::FAILURE; @@ -270,28 +269,7 @@ StatusCode Muon::sTgcRdoToPrepDataToolCore::processCollection(const STGC_RawData } -Muon::sTgcRdoToPrepDataToolCore::SetupSTGC_PrepDataContainerStatus Muon::sTgcRdoToPrepDataToolCore::setupSTGC_PrepDataContainer() -{ - - if(!evtStore()->contains<Muon::sTgcPrepDataContainer>(m_stgcPrepDataContainerKey.key())){ - m_fullEventDone=false; - - SG::WriteHandle< Muon::sTgcPrepDataContainer > handle(m_stgcPrepDataContainerKey); - StatusCode status = handle.record(std::make_unique<Muon::sTgcPrepDataContainer>(m_idHelperSvc->stgcIdHelper().module_hash_max())); - - if (status.isFailure() || !handle.isValid() ) { - ATH_MSG_FATAL("Could not record container of STGC PrepData Container at " << m_stgcPrepDataContainerKey.key()); - return FAILED; - } - m_stgcPrepDataContainer = handle.ptr(); - return ADDED; - - } - return ALREADYCONTAINED; -} - - -const STGC_RawDataContainer* Muon::sTgcRdoToPrepDataToolCore::getRdoContainer() { +const STGC_RawDataContainer* Muon::sTgcRdoToPrepDataToolCore::getRdoContainer() const { auto rdoContainerHandle = SG::makeHandle(m_rdoContainerKey); if(rdoContainerHandle.isValid()) { @@ -304,7 +282,8 @@ const STGC_RawDataContainer* Muon::sTgcRdoToPrepDataToolCore::getRdoContainer() } -void Muon::sTgcRdoToPrepDataToolCore::processRDOContainer( std::vector<IdentifierHash>& idWithDataVect ) +void Muon::sTgcRdoToPrepDataToolCore::processRDOContainer( Muon::sTgcPrepDataContainer* stgcPrepDataContainer, + std::vector<IdentifierHash>& idWithDataVect ) const { @@ -321,7 +300,7 @@ void Muon::sTgcRdoToPrepDataToolCore::processRDOContainer( std::vector<Identifie if (rdoColl->empty()) continue; ATH_MSG_DEBUG("New RDO collection with " << rdoColl->size() << "STGC Hits"); - if(processCollection(rdoColl, idWithDataVect).isFailure()) { + if(processCollection(stgcPrepDataContainer, rdoColl, idWithDataVect).isFailure()) { ATH_MSG_DEBUG("processCsm returns a bad StatusCode - keep going for new data collections in this event"); } } @@ -333,28 +312,21 @@ void Muon::sTgcRdoToPrepDataToolCore::processRDOContainer( std::vector<Identifie // methods for ROB-based decoding StatusCode Muon::sTgcRdoToPrepDataToolCore::decode( std::vector<IdentifierHash>& idVect, - std::vector<IdentifierHash>& idWithDataVect ) + std::vector<IdentifierHash>& idWithDataVect ) { ATH_MSG_DEBUG("Size of the input hash id vector: " << idVect.size()); // clear the output vector of selected data idWithDataVect.clear(); - - SetupSTGC_PrepDataContainerStatus containerRecordStatus = setupSTGC_PrepDataContainer(); - if ( containerRecordStatus == FAILED ) { - return StatusCode::FAILURE; - } - - processRDOContainer(idWithDataVect); + Muon::sTgcPrepDataContainer* stgcPrepDataContainer = setupSTGC_PrepDataContainer(); - // check if the full event has already been decoded - if ( m_fullEventDone ) { - ATH_MSG_DEBUG ("Full event dcoded, nothing to do"); - return StatusCode::SUCCESS; + if ( stgcPrepDataContainer == nullptr ) { + return StatusCode::FAILURE; } + processRDOContainer(stgcPrepDataContainer, idWithDataVect); return StatusCode::SUCCESS; } diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.h b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.h index 76a7d6ca668b7953ea31695df98072f5fbaf68d9..d7f66ca3c351e114e93f1f8d5daf6e3d9beaeb79 100644 --- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.h +++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.h @@ -49,8 +49,9 @@ namespace Muon StatusCode decode(const std::vector<uint32_t>& robIds) override; - StatusCode processCollection(const STGC_RawDataCollection *rdoColl, - std::vector<IdentifierHash>& idWithDataVect); + StatusCode processCollection(Muon::sTgcPrepDataContainer* stgcPrepDataContainer, + const STGC_RawDataCollection *rdoColl, + std::vector<IdentifierHash>& idWithDataVect) const; virtual void printPrepData() override; virtual void printInputRdo() override; @@ -60,25 +61,19 @@ namespace Muon protected: - enum SetupSTGC_PrepDataContainerStatus { - FAILED = 0, ADDED, ALREADYCONTAINED - }; + virtual Muon::sTgcPrepDataContainer* setupSTGC_PrepDataContainer() const = 0; - virtual SetupSTGC_PrepDataContainerStatus setupSTGC_PrepDataContainer(); + const STGC_RawDataContainer* getRdoContainer() const; - const STGC_RawDataContainer* getRdoContainer(); - - void processRDOContainer(std::vector<IdentifierHash>& idWithDataVect); + void processRDOContainer(Muon::sTgcPrepDataContainer* stgcPrepDataContainer, + std::vector<IdentifierHash>& idWithDataVect) const; SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_muDetMgrKey {this, "DetectorManagerKey", "MuonDetectorManager", "Key of input MuonDetectorManager condition data"}; ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - bool m_fullEventDone; - /** TgcPrepRawData container key for current BC */ std::string m_outputCollectionLocation; - Muon::sTgcPrepDataContainer* m_stgcPrepDataContainer; SG::ReadHandleKey<STGC_RawDataContainer> m_rdoContainerKey;//"TGCRDO" SG::WriteHandleKey<sTgcPrepDataContainer> m_stgcPrepDataContainerKey; bool m_merge; // merge Prds diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolMT.cxx b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolMT.cxx index 56181c8d941a59aaa3bf1dabeda1e36f6120c3a7..1c2e4303b119c0370f7e871c384c4bee1003ae94 100644 --- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolMT.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolMT.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 */ /////////////////////////////////////////////////////////////////// @@ -27,22 +27,21 @@ StatusCode Muon::sTgcRdoToPrepDataToolMT::initialize() return StatusCode::SUCCESS; } -Muon::sTgcRdoToPrepDataToolCore::SetupSTGC_PrepDataContainerStatus Muon::sTgcRdoToPrepDataToolMT::setupSTGC_PrepDataContainer() +Muon::sTgcPrepDataContainer* Muon::sTgcRdoToPrepDataToolMT::setupSTGC_PrepDataContainer() const { if(!evtStore()->contains<Muon::sTgcPrepDataContainer>(m_stgcPrepDataContainerKey.key())){ - m_fullEventDone=false; - SG::WriteHandle< Muon::sTgcPrepDataContainer > handle(m_stgcPrepDataContainerKey); StatusCode status = handle.record(std::make_unique<Muon::sTgcPrepDataContainer>(m_idHelperSvc->stgcIdHelper().module_hash_max())); if (status.isFailure() || !handle.isValid() ) { ATH_MSG_FATAL("Could not record container of STGC PrepData Container at " << m_stgcPrepDataContainerKey.key()); - return FAILED; + return nullptr; } - m_stgcPrepDataContainer = handle.ptr(); - return ADDED; - + return handle.ptr(); } - return ALREADYCONTAINED; + + ATH_MSG_FATAL("STGC PrepData Container " << m_stgcPrepDataContainerKey.key() + << " already exists"); + return nullptr; } diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolMT.h b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolMT.h index 002f58410bfa16e544c7c92630a97598d7101663..60546e861b1e25b7093e95b9907397d7b161d488 100644 --- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolMT.h +++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolMT.h @@ -26,7 +26,7 @@ namespace Muon virtual StatusCode initialize() override; protected: - virtual SetupSTGC_PrepDataContainerStatus setupSTGC_PrepDataContainer() override; + virtual Muon::sTgcPrepDataContainer* setupSTGC_PrepDataContainer() const override; }; } // end of namespace