diff --git a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/SCT_CalibAlgs/SCTCalibWriteTool.h b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/SCT_CalibAlgs/SCTCalibWriteTool.h index 112f7b3f505be0cb42ca88c3f5f5662471467588..a8fc81f48c3331734ede0b5bf64e126f3e786b05 100644 --- a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/SCT_CalibAlgs/SCTCalibWriteTool.h +++ b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/SCT_CalibAlgs/SCTCalibWriteTool.h @@ -37,6 +37,7 @@ #include <map> #include <set> #include <list> +#include <mutex> //forward declarations class IdentifierHash; @@ -177,6 +178,7 @@ class SCTCalibWriteTool : public AthAlgTool { static std::string s_LAFolderName; // cache for the Collections, access by foldername + mutable std::mutex m_mutex; mutable std::map<const std::string, const CondAttrListCollection*> m_attrListCollectionMap; CondAttrListCollection* m_attrListColl; CondAttrListCollection* m_attrListColl_deadStrip; @@ -223,9 +225,6 @@ class SCTCalibWriteTool : public AthAlgTool { bool m_BSErrRecorded; bool m_LARecorded; const SCT_ID* m_pHelper; - // FIXME: this caches only the last call of getList. - // creating a hash of _all_ calls may be faster, but wastes a lot of memory - mutable std::string m_currentDefectList; }; inline const InterfaceID & SCTCalibWriteTool::interfaceID() { diff --git a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCTCalibWriteTool.cxx b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCTCalibWriteTool.cxx index 8adefbf3fb055dbd628c4d5fb17e8bdb78320b99..3748c82e541342dc2dd7ec729ae6a6ae2d571752 100644 --- a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCTCalibWriteTool.cxx +++ b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCTCalibWriteTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /** @@ -59,6 +59,7 @@ SCTCalibWriteTool::SCTCalibWriteTool(const std::string& type, const std::string& AthAlgTool(type, name, parent), m_detStore(0), m_eventInfoKey(std::string("ByteStreamEventInfo")), + m_mutex(), m_attrListColl(0), m_attrListColl_deadStrip(0), m_attrListColl_deadChip(0), @@ -93,8 +94,7 @@ SCTCalibWriteTool::SCTCalibWriteTool(const std::string& type, const std::string& m_RawOccuRecorded(false), m_BSErrRecorded(false), m_LARecorded(false), - m_pHelper(0), - m_currentDefectList("") + m_pHelper(0) { declareProperty("WriteCondObjs", m_writeCondObjs); declareProperty("RegisterIOV", m_regIOV); @@ -514,6 +514,7 @@ SCTCalibWriteTool::createListLA(const Identifier& wafer_id,const SCT_ID* sctId,c const CondAttrListCollection* SCTCalibWriteTool::getAttrListCollectionByFolder(const string& foldername) const { + std::lock_guard<std::mutex> lock(m_mutex); // trying to find the pointer in the hashmap // if it exists, return it, otherwise put it in. const CondAttrListCollection* nullPtr(0); diff --git a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibEventInfo.h b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibEventInfo.h index d69448fdf7599636c0ad54a04bcc864db6772c2c..54d44636ff0c13775b257f0e72feba34629a52f6 100644 --- a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibEventInfo.h +++ b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibEventInfo.h @@ -10,12 +10,12 @@ #ifndef SCT_CalibEventInfo_h #define SCT_CalibEventInfo_h -//#include "AthenaBaseComps/AthService.h" //baseclass -//#include "GaudiKernel/ServiceHandle.h" //member + #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ToolHandle.h" //member #include "SCT_CalibAlgs/ISCT_CalibEvtInfo.h" +#include <atomic> #include <string> class StatusCode; @@ -74,10 +74,10 @@ class SCT_CalibEventInfo: public extends<AthAlgTool, ISCT_CalibEvtInfo> std::string m_source; // - mutable int m_runNumber; - mutable int m_lumiBlock; - mutable int m_timeStamp; - mutable int m_bunchCrossing; + mutable std::atomic_int m_runNumber; + mutable std::atomic_int m_lumiBlock; + mutable std::atomic_int m_timeStamp; + mutable std::atomic_int m_bunchCrossing; int m_counter; std::string toUtc(const int timestamp) const; }; diff --git a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibLbTool.h b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibLbTool.h index 55fbc61e72588c5cbd59ee88a2ea227226ea22c8..e3eee1990eb78cb2a9dab8926da017d1c07365c2 100644 --- a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibLbTool.h +++ b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibLbTool.h @@ -11,9 +11,6 @@ #ifndef SCT_CalibLbTool_h #define SCT_CalibLbTool_h -//STL includes -#include <string> - //Athena includes #include "AthenaBaseComps/AthAlgTool.h" #include "StoreGate/StoreGateSvc.h" @@ -28,6 +25,10 @@ //local includes #include "SCT_CalibAlgs/ISCT_CalibHistoTool.h" +//STL includes +#include <atomic> +#include <string> + //fwd declarations namespace InDetDD { @@ -72,7 +73,7 @@ class SCT_CalibLbTool : public extends<AthAlgTool, ISCT_CalibHistoTool> VecInt *m_sct_firstStrip; VecInt *m_sct_rdoGroupSize; - mutable int m_lumiBlock; + mutable std::atomic_int m_lumiBlock; //private use in this class int m_LbRange; diff --git a/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ByteStreamErrorsTool.cxx b/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ByteStreamErrorsTool.cxx index 139b1301d70ba6afe7c8a79da23ac9ba4a380b72..2e7f2c4666463e62e49744de7f212ed69e5a0862 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ByteStreamErrorsTool.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsTools/src/SCT_ByteStreamErrorsTool.cxx @@ -270,6 +270,7 @@ SCT_ByteStreamErrorsTool::getChip(const Identifier& stripId, const EventContext& void SCT_ByteStreamErrorsTool::resetSets(const EventContext& ctx) const { + // Used in fillData and m_mutex is already locked. for (int errType{0}; errType<SCT_ByteStreamErrors::NUM_ERROR_TYPES; errType++) { m_bsErrors[errType][ctx.slot()].clear(); @@ -293,6 +294,7 @@ SCT_ByteStreamErrorsTool::getErrorSet(int errorType, const EventContext& ctx) co ATH_MSG_ERROR("fillData in getErrorSet fails"); } + std::lock_guard<std::mutex> lock{m_mutex}; return &m_bsErrors[errorType][ctx.slot()]; } return nullptr; @@ -316,13 +318,13 @@ SCT_ByteStreamErrorsTool::fillData(const EventContext& ctx) const { EventContext::ContextID_t slot{ctx.slot()}; EventContext::ContextEvt_t evt{ctx.evt()}; + std::lock_guard<std::mutex> lock{m_mutex}; + if (slot<m_cache.size() and m_cache[slot]==evt) { // Cache isvalid return StatusCode::SUCCESS; } - std::lock_guard<std::mutex> lock{m_mutex}; - static const EventContext::ContextEvt_t invalidValue{EventContext::INVALID_CONTEXT_EVT}; if (slot>=m_cache.size()) { m_cache.resize(slot+1, invalidValue); // Store invalid values in order to go to the next IF statement. @@ -397,6 +399,8 @@ SCT_ByteStreamErrorsTool::fillData(const EventContext& ctx) const { void SCT_ByteStreamErrorsTool::addError(const IdentifierHash& id, int errorType, const EventContext& ctx) const { + // Used in fillData and m_mutex is already locked. + if (errorType>=0 and errorType<SCT_ByteStreamErrors::NUM_ERROR_TYPES) { m_bsErrors[errorType][ctx.slot()].insert(id); } @@ -479,6 +483,7 @@ const std::map<Identifier, unsigned int>& SCT_ByteStreamErrorsTool::getTempMaske ATH_MSG_ERROR("fillData in getTempMaskedChips fails"); } + std::lock_guard<std::mutex> lock{m_mutex}; return m_tempMaskedChips[ctx.slot()]; } @@ -488,5 +493,6 @@ const std::map<Identifier, unsigned int>& SCT_ByteStreamErrorsTool::getAbcdError ATH_MSG_ERROR("fillData in getAbcdErrorChips fails"); } + std::lock_guard<std::mutex> lock{m_mutex}; return m_abcdErrorChips[ctx.slot()]; } diff --git a/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_CablingTool.cxx b/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_CablingTool.cxx index 38c5c554382beb815cfb43f3b374ae8d34bb800b..4c012112c02819074ed691c74611fbb4176f3579 100644 --- a/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_CablingTool.cxx +++ b/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_CablingTool.cxx @@ -43,10 +43,7 @@ namespace { SCT_CablingTool::SCT_CablingTool(const std::string& type, const std::string& name, const IInterface* parent) : base_class(type, name, parent), m_idHelper{nullptr}, - m_usingDatabase{true}, - m_mutex{}, - m_cache{}, - m_condData{} + m_usingDatabase{true} { declareProperty("DataSource", m_cablingDataSource=defaultSource); } @@ -263,21 +260,6 @@ SCT_CablingTool::getHashesForRod(std::vector<IdentifierHash>& usersVector, const const SCT_CablingData* SCT_CablingTool::getData(const EventContext& ctx) const { - static const EventContext::ContextEvt_t invalidValue{EventContext::INVALID_CONTEXT_EVT}; - const EventContext::ContextID_t slot{ctx.slot()}; - const EventContext::ContextEvt_t evt{ctx.evt()}; - if (slot>=m_cache.size()) { - std::lock_guard<std::mutex> lock(m_mutex); - m_cache.resize(slot+1, invalidValue); // Store invalid values in order to go to the next IF statement. - } - if (m_cache[slot]!=evt) { - std::lock_guard<std::mutex> lock(m_mutex); - SG::ReadCondHandle<SCT_CablingData> condData{m_data}; - if (not condData.isValid()) { - ATH_MSG_ERROR("Failed to get " << m_data.key()); - } - m_condData.set(*condData); - m_cache[slot] = evt; - } - return m_condData.get(); + SG::ReadCondHandle<SCT_CablingData> condData{m_data, ctx}; + return condData.retrieve(); } diff --git a/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_CablingTool.h b/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_CablingTool.h index e6cdf40689268152704f8e4ddccdef75afa530e1..2caac3dba330b0481ace79452260773bb1bedc9e 100644 --- a/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_CablingTool.h +++ b/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_CablingTool.h @@ -20,11 +20,9 @@ #include "StoreGate/ReadCondHandleKey.h" // Gaudi includes -#include "GaudiKernel/ContextSpecificPtr.h" #include "GaudiKernel/EventContext.h" //STL includes -#include <mutex> #include <string> #include <vector> @@ -100,13 +98,6 @@ class SCT_CablingTool: public extends<AthAlgTool, ISCT_CablingTool> { const SCT_ID* m_idHelper; //!< helper for offlineId/hash conversions bool m_usingDatabase; - // Mutex to protect the contents. - mutable std::mutex m_mutex; - // Cache to store events for slots - mutable std::vector<EventContext::ContextEvt_t> m_cache; - // Pointer of SCT_CablingData - mutable Gaudi::Hive::ContextSpecificPtr<const SCT_CablingData> m_condData; - const SCT_CablingData* getData(const EventContext& ctx) const; }; diff --git a/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_FillCablingFromCoraCool.h b/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_FillCablingFromCoraCool.h index e3c753d36a8ead00c5f18381b3cd8a73ee36fa83..8aaa2464e2359d1a3dec836c226b088b238525ab 100644 --- a/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_FillCablingFromCoraCool.h +++ b/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_FillCablingFromCoraCool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef SCT_FillCablingFromCoraCool_H @@ -20,6 +20,7 @@ #include "AthenaPoolUtilities/CondAttrListVec.h" //STL includes +#include <atomic> #include <string> //fwd declarations @@ -79,7 +80,7 @@ private: bool insert(const IdentifierHash& hash, const SCT_OnlineId& onlineId, const SCT_SerialNumber& sn, SCT_CablingData& data) const; - mutable bool m_filled; + mutable std::atomic_bool m_filled; std::string m_source; };//end of class diff --git a/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_FillCablingFromText.h b/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_FillCablingFromText.h index 18d4702aeae5d536115202636052983e7494a3a1..7ce6254126d0d2475b24d10cebf6afd21bbe4483 100644 --- a/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_FillCablingFromText.h +++ b/InnerDetector/InDetDetDescr/SCT_Cabling/src/SCT_FillCablingFromText.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef SCT_FillCablingFromText_H @@ -18,6 +18,7 @@ #include "SCT_Cabling/ISCT_FillCabling.h" //STL includes +#include <atomic> #include <string> //fwd declarations @@ -72,7 +73,7 @@ class SCT_FillCablingFromText: public extends<AthAlgTool, ISCT_FillCabling> { bool insert(const IdentifierHash& hash, const SCT_OnlineId& onlineId, const SCT_SerialNumber& sn, SCT_CablingData& data) const; - mutable bool m_filled; + mutable std::atomic_bool m_filled; std::string m_source; };//end of class diff --git a/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.cxx b/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.cxx index e5a7317ffe496978fee0e8864d6485448521ed39..cdb3a5401f6c080d25d3ec07c2788ec466bbf189 100644 --- a/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.cxx +++ b/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.cxx @@ -30,6 +30,7 @@ using namespace InDetDD; // constructor SCT_FrontEnd::SCT_FrontEnd(const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type, name, parent), + m_mutex(), m_SCTdetMgr(nullptr), m_sct_id(nullptr) { declareInterface<ISCT_FrontEnd>(this); @@ -593,6 +594,8 @@ StatusCode SCT_FrontEnd::randomNoise(SiChargedDiodeCollection& collection, const // (this could be moved elsewhere later) apply threshold do clustering // ---------------------------------------------------------------------- void SCT_FrontEnd::process(SiChargedDiodeCollection& collection, CLHEP::HepRandomEngine * rndmEngine) const { + std::lock_guard<std::mutex> lock(m_mutex); + // get SCT module side design and check it const SCT_ModuleSideDesign *p_design = dynamic_cast<const SCT_ModuleSideDesign*>(&(collection.design())); diff --git a/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.h b/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.h index 73e510cb778a3c1b8802a2e5a4f0370b05b7f4d3..9e2e6c60060e004018e599599e41073fc8423ce6 100644 --- a/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.h +++ b/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.h @@ -36,6 +36,9 @@ // Gaudi #include "GaudiKernel/ToolHandle.h" +// STL +#include <mutex> + class ISCT_Amp; class SCT_ID; @@ -112,7 +115,8 @@ class SCT_FrontEnd : public AthAlgTool, virtual public ISCT_FrontEnd { short m_data_readout_mode; //!< To set the data read out mode bool m_useCalibData; //!< Flag to set the use of calibration data for noise, Gain,offset etc. mutable int m_strip_max; //!< For SLHC studies - + + mutable std::mutex m_mutex; mutable std::vector<float> m_Offset; //!< generate offset per channel mutable std::vector<float> m_GainFactor; //!< generate gain per channel (added to the gain per chip from calib data) mutable std::vector<float> m_NoiseFactor; //!< Kondo: 31/08/07 noise per channel (actually noise per chip from calib data) diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.cxx index 7b53401825cf5e3b2bdc271b616d3e19d8da59d9..0037d7fde3989f88c151e9b4e3cc66187cf35f47 100644 --- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.cxx +++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.cxx @@ -47,6 +47,8 @@ StatusCode SCTRawDataProviderTool::convert(std::vector<const ROBFragment*>& vecR StatusCode sc{StatusCode::SUCCESS}; + std::lock_guard<std::mutex> lock(m_mutex); + // loop over the ROB fragments std::set<uint32_t> tmpROBIDSet; @@ -79,9 +81,7 @@ StatusCode SCTRawDataProviderTool::convert(std::vector<const ROBFragment*>& vecR } } - m_mutex.lock(); m_robIDSet.insert(tmpROBIDSet.begin(), tmpROBIDSet.end()); - m_mutex.unlock(); if (sc == StatusCode::FAILURE) { ATH_MSG_ERROR("There was a problem with SCT ByteStream conversion"); diff --git a/InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack/InDetCompetingRIOsOnTrack/CompetingSCT_ClustersOnTrack.h b/InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack/InDetCompetingRIOsOnTrack/CompetingSCT_ClustersOnTrack.h index 6364b47fb98f5590a6f301e7fe339bbc9e36c239..45b1434dfa7812c1b06b796bd6d89062a0b04773 100755 --- a/InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack/InDetCompetingRIOsOnTrack/CompetingSCT_ClustersOnTrack.h +++ b/InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack/InDetCompetingRIOsOnTrack/CompetingSCT_ClustersOnTrack.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -14,7 +14,7 @@ #include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h" // cannot fwd-declare because of covariant method #include <iosfwd> -#include <mutex> +#include <atomic> class MsgStream; @@ -106,9 +106,7 @@ private: /** The global position */ - mutable const Amg::Vector3D* m_globalPosition; - /** Mutex to protect the global position */ - mutable std::mutex m_mutex; + mutable std::atomic<const Amg::Vector3D*> m_globalPosition; /** The vector of contained InDet::SCT_ClusterOnTrack objects */ std::vector<const InDet::SCT_ClusterOnTrack*>* m_containedChildRots; @@ -141,7 +139,6 @@ inline const InDet::SCT_ClusterOnTrack& CompetingSCT_ClustersOnTrack::rioOnTrack inline const Amg::Vector3D& CompetingSCT_ClustersOnTrack::globalPosition() const { if (m_globalPosition==nullptr) { - std::lock_guard<std::mutex> lock{m_mutex}; m_globalPosition = associatedSurface().localToGlobal(localParameters()); } return (*m_globalPosition); diff --git a/InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack/src/CompetingSCT_ClustersOnTrack.cxx b/InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack/src/CompetingSCT_ClustersOnTrack.cxx index 8c4eec43588220d45b2b2a1707034af18766eee8..ac3bdd91975da90dfdc5a9730fc9df3b8ed21b2a 100755 --- a/InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack/src/CompetingSCT_ClustersOnTrack.cxx +++ b/InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack/src/CompetingSCT_ClustersOnTrack.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -19,7 +19,6 @@ InDet::CompetingSCT_ClustersOnTrack::CompetingSCT_ClustersOnTrack(): Trk::CompetingRIOsOnTrack(), m_globalPosition(nullptr), - m_mutex(), m_containedChildRots(0) // {} @@ -28,7 +27,6 @@ InDet::CompetingSCT_ClustersOnTrack::CompetingSCT_ClustersOnTrack(): InDet::CompetingSCT_ClustersOnTrack::CompetingSCT_ClustersOnTrack(const InDet::CompetingSCT_ClustersOnTrack& compROT) : Trk::CompetingRIOsOnTrack(compROT), m_globalPosition(compROT.m_globalPosition ? new Amg::Vector3D(*compROT.m_globalPosition) : nullptr), - m_mutex(), m_containedChildRots(0) { m_containedChildRots = new std::vector< const InDet::SCT_ClusterOnTrack* >; std::vector< const InDet::SCT_ClusterOnTrack* >::const_iterator rotIter = compROT.m_containedChildRots->begin(); @@ -46,7 +44,6 @@ InDet::CompetingSCT_ClustersOnTrack::CompetingSCT_ClustersOnTrack( ): Trk::CompetingRIOsOnTrack(assgnProb), m_globalPosition(nullptr), -m_mutex(), m_containedChildRots(childrots) { // initialize local position and error matrix @@ -68,17 +65,15 @@ InDet::CompetingSCT_ClustersOnTrack& InDet::CompetingSCT_ClustersOnTrack::operat for (; rotIter!=compROT.m_containedChildRots->end(); ++rotIter) m_containedChildRots->push_back((*rotIter)->clone()); - std::lock_guard<std::mutex> lock{m_mutex}; m_globalPosition = compROT.m_globalPosition ? new Amg::Vector3D(*compROT.m_globalPosition) : nullptr; } return (*this); } InDet::CompetingSCT_ClustersOnTrack::~CompetingSCT_ClustersOnTrack() { - - delete m_globalPosition; clearChildRotVector(); delete m_containedChildRots; + delete m_globalPosition; } void InDet::CompetingSCT_ClustersOnTrack::clearChildRotVector() { diff --git a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SiClusterOnTrack.h b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SiClusterOnTrack.h index 06e529f8e12555187262e301853a50d4c70a0ad9..fc773dd6a15bfdf7007e4ec612c2aed0cb524d5f 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SiClusterOnTrack.h +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SiClusterOnTrack.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -12,6 +12,8 @@ #include "TrkRIO_OnTrack/RIO_OnTrack.h" #include "Identifier/IdentifierHash.h" +#include <atomic> + class SiClusterOnTrackCnv_p1; namespace Trk @@ -101,7 +103,7 @@ namespace InDet { /** The IdentifierHash - probably not used*/ IdentifierHash m_idDE; /** The global position */ - mutable const Amg::Vector3D* m_globalPosition; + mutable std::atomic<const Amg::Vector3D*> m_globalPosition; bool m_isbroad; }; diff --git a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/PixelClusterOnTrack.cxx b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/PixelClusterOnTrack.cxx index 7df70ae44052abe464a3ff02baa2001edc89cae6..156d7287743689f2bd1a5d6c150902ccb581c4d3 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/PixelClusterOnTrack.cxx +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/PixelClusterOnTrack.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// diff --git a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SCT_ClusterOnTrack.cxx b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SCT_ClusterOnTrack.cxx index ee25b4ddc466e16faea3a893ead0c18fd70605b5..d1bcf1e158baa2c3b9de13c512a21385eaf4ca48 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SCT_ClusterOnTrack.cxx +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SCT_ClusterOnTrack.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -89,7 +89,6 @@ void InDet::SCT_ClusterOnTrack::setValues(const Trk::TrkDetElementBase* detEl, c const Amg::Vector3D& InDet::SCT_ClusterOnTrack::globalPosition() const { - //checking whether the globalposition is available if(!m_globalPosition) { diff --git a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SiClusterOnTrack.cxx b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SiClusterOnTrack.cxx index 3da495870609f076ee9c4e811b09d6ac9f27959f..5aa45e5ddf1c5e383c7b12176e2715bcaf541819 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SiClusterOnTrack.cxx +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SiClusterOnTrack.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -47,7 +47,7 @@ InDet::SiClusterOnTrack::SiClusterOnTrack( const Trk::LocalParameters& locpars, // Destructor: InDet::SiClusterOnTrack::~SiClusterOnTrack() { - delete m_globalPosition; + delete m_globalPosition; } // Default constructor: @@ -84,15 +84,15 @@ InDet::SiClusterOnTrack& InDet::SiClusterOnTrack::operator=( const SiClusterOnTr const Amg::Vector3D& InDet::SiClusterOnTrack::globalPosition() const { - if (!m_globalPosition) m_globalPosition = associatedSurface().localToGlobal(localParameters()); - return (*m_globalPosition); + if (!m_globalPosition) m_globalPosition = associatedSurface().localToGlobal(localParameters()); + return (*m_globalPosition); } MsgStream& InDet::SiClusterOnTrack::dump( MsgStream& sl ) const { sl << "SiClusterOnTrack {" << endmsg; - Trk::RIO_OnTrack::dump(sl); + Trk::RIO_OnTrack::dump(sl); sl << "Global position (x,y,z) = ("; this->globalPosition(); @@ -112,7 +112,7 @@ std::ostream& InDet::SiClusterOnTrack::dump( std::ostream& sl ) const { sl << "SiClusterOnTrack {"<<std::endl; - Trk::RIO_OnTrack::dump(sl); + Trk::RIO_OnTrack::dump(sl); sl << "Global position (x,y,z) = ("; this->globalPosition();