From 808a3b0ad4b2aa24d004984ebd6eb365b16aae27 Mon Sep 17 00:00:00 2001 From: abarton <Adam.Edward.Barton@cern.ch> Date: Fri, 27 Jul 2018 10:03:41 +0100 Subject: [PATCH] Use lock methods in cases used in Trigger MT prototypes Former-commit-id: b4c34cfc0043d8ec661ad72b933a676ffb892298 --- .../src/PixelClusterization.cxx | 15 ++++++--------- .../src/SCT_Clusterization.cxx | 18 +++++++++--------- .../src/TRT_RIO_Maker.cxx | 12 ++++++------ .../src/SiTrackerSpacePointFinder.cxx | 11 ++++++----- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/PixelClusterization.cxx b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/PixelClusterization.cxx index 25492537d3d..cf43539eb27 100644 --- a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/PixelClusterization.cxx +++ b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/PixelClusterization.cxx @@ -143,8 +143,8 @@ namespace InDet{ for(; rdoCollections!=rdoCollectionsEnd; ++rdoCollections){ const COLLECTION* RDO_Collection(*rdoCollections); if (!RDO_Collection || RDO_Collection->empty()) continue; - if( clusterContainer->tryFetch( rdoCollections.hashId() )) continue; - + PixelClusterContainer::IDC_WriteHandle lock = clusterContainer->getWriteHandle(rdoCollections.hashId()); + if( lock.alreadyPresent() ) continue; // Use one of the specific clustering AlgTools to make clusters std::unique_ptr<PixelClusterCollection> clusterCollection (m_clusteringTool->clusterize(*RDO_Collection, *m_manager, *m_idHelper)); @@ -152,8 +152,7 @@ namespace InDet{ m_gangedAmbiguitiesFinder->execute(clusterCollection.get(),*m_manager,*ambiguitiesMap); - IdentifierHash hash = clusterCollection->identifyHash(); - ATH_CHECK(clusterContainer->addOrDelete( std::move(clusterCollection), hash )); + ATH_CHECK(lock.addOrDelete( std::move(clusterCollection) )); }else{ ATH_MSG_DEBUG("No PixelClusterCollection to write"); } @@ -175,12 +174,11 @@ namespace InDet{ ATH_MSG_VERBOSE( "REGTEST: Pixel : Roi contains " << listOfPixIds.size() << " det. Elements" ); for (unsigned int i=0; i < listOfPixIds.size(); i++) { - - if( clusterContainer->tryFetch( listOfPixIds[i] )) continue; - const InDetRawDataCollection<PixelRDORawData>* RDO_Collection (rdoContainer->indexFindPtr(listOfPixIds[i])); if (!RDO_Collection) continue; + PixelClusterContainer::IDC_WriteHandle lock = clusterContainer->getWriteHandle(listOfPixIds[i]); + if( lock.alreadyPresent() ) continue; // Use one of the specific clustering AlgTools to make clusters std::unique_ptr<PixelClusterCollection> clusterCollection (m_clusteringTool->clusterize(*RDO_Collection, *m_manager, *m_idHelper)); @@ -188,8 +186,7 @@ namespace InDet{ ATH_MSG_VERBOSE( "REGTEST: Pixel : clusterCollection contains " << clusterCollection->size() << " clusters" ); m_gangedAmbiguitiesFinder->execute(clusterCollection.get(),*m_manager,*ambiguitiesMap); - IdentifierHash hash = clusterCollection->identifyHash(); - ATH_CHECK(clusterContainer->addOrDelete( std::move(clusterCollection), hash )); + ATH_CHECK(lock.addOrDelete( std::move(clusterCollection) )); }else{ ATH_MSG_DEBUG("No PixelClusterCollection to write"); diff --git a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/SCT_Clusterization.cxx b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/SCT_Clusterization.cxx index df2622ef852..5761c69ab62 100644 --- a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/SCT_Clusterization.cxx +++ b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/SCT_Clusterization.cxx @@ -152,7 +152,9 @@ namespace InDet{ for(; rdoCollections != rdoCollectionsEnd; ++rdoCollections){ const InDetRawDataCollection<SCT_RDORawData>* rd(*rdoCollections); ATH_MSG_DEBUG("RDO collection size=" << rd->size() << ", Hash=" << rd->identifyHash()); - if( clusterContainer->tryFetch( rdoCollections.hashId() )){ + SCT_ClusterContainer::IDC_WriteHandle lock = clusterContainer->getWriteHandle(rdoCollections.hashId()); + + if( lock.alreadyPresent() ){ ATH_MSG_DEBUG("Item already in cache , Hash=" << rd->identifyHash()); continue; } @@ -172,7 +174,7 @@ namespace InDet{ if (not clusterCollection->empty()) { const IdentifierHash hash(clusterCollection->identifyHash()); //Using get because I'm unsure of move semantec status - ATH_CHECK(clusterContainer->addOrDelete(std::move(clusterCollection), hash)); + ATH_CHECK(lock.addOrDelete(std::move(clusterCollection))); ATH_MSG_DEBUG("Clusters with key '" << hash << "' added to Container\n"); } else { ATH_MSG_DEBUG("Don't write empty collections\n"); @@ -196,23 +198,21 @@ namespace InDet{ ATH_MSG_VERBOSE( "REGTEST: SCT : Roi contains " << listOfSCTIds.size() << " det. Elements" ); for (size_t i=0; i < listOfSCTIds.size(); i++) { + const InDetRawDataCollection<SCT_RDORawData>* RDO_Collection (rdoContainer->indexFindPtr(listOfSCTIds[i])); + if (!RDO_Collection) continue; - if( clusterContainer->tryFetch( listOfSCTIds[i] )){ + SCT_ClusterContainer::IDC_WriteHandle lock = clusterContainer->getWriteHandle(listOfSCTIds[i]); + if( lock.alreadyPresent() ){ ATH_MSG_DEBUG("Item already in cache , Hash=" << listOfSCTIds[i]); continue; } - - const InDetRawDataCollection<SCT_RDORawData>* RDO_Collection (rdoContainer->indexFindPtr(listOfSCTIds[i])); - - if (!RDO_Collection) continue; - // Use one of the specific clustering AlgTools to make clusters std::unique_ptr<SCT_ClusterCollection> clusterCollection (m_clusteringTool->clusterize(*RDO_Collection, *m_manager, *m_idHelper)); if (clusterCollection && !clusterCollection->empty()){ ATH_MSG_VERBOSE( "REGTEST: SCT : clusterCollection contains " << clusterCollection->size() << " clusters" ); const IdentifierHash hash(clusterCollection->identifyHash()); - ATH_CHECK(clusterContainer->addOrDelete( std::move(clusterCollection), hash )); + ATH_CHECK(lock.addOrDelete( std::move(clusterCollection) )); }else{ ATH_MSG_DEBUG("No SCTClusterCollection to write"); } diff --git a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/TRT_RIO_Maker.cxx b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/TRT_RIO_Maker.cxx index ba9fe3f065d..46564456c09 100644 --- a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/TRT_RIO_Maker.cxx +++ b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/TRT_RIO_Maker.cxx @@ -93,12 +93,12 @@ namespace InDet { for(const auto& rdoCollections : *rdoContainer) { const InDetRawDataCollection<TRT_RDORawData>* currentCollection(rdoCollections); - if( rioContainer->tryFetch( currentCollection->identifyHash() )) continue; + InDet::TRT_DriftCircleContainer::IDC_WriteHandle lock = rioContainer->getWriteHandle(currentCollection->identifyHash()); + if( lock.alreadyPresent() ) continue; std::unique_ptr<TRT_DriftCircleCollection> p_rio(m_driftcircle_tool->convert(m_mode_rio_production, currentCollection , m_trtBadChannels)); if(p_rio && !p_rio->empty()) { - IdentifierHash hash = p_rio->identifyHash(); - ATH_CHECK(rioContainer->addOrDelete(std::move(p_rio), hash)); + ATH_CHECK(lock.addOrDelete(std::move(p_rio))); } } }else{ @@ -115,7 +115,8 @@ namespace InDet { << listOfTRTIds.size() << " det. Elements" ); #endif for(auto &id : listOfTRTIds){ - if( rioContainer->tryFetch( id )) continue; + InDet::TRT_DriftCircleContainer::IDC_WriteHandle lock = rioContainer->getWriteHandle(id); + if( lock.alreadyPresent() ) continue; const InDetRawDataCollection<TRT_RDORawData>* RDO_Collection (rdoContainer->indexFindPtr(id)); if (!RDO_Collection) continue; // Use one of the specific clustering AlgTools to make clusters @@ -126,8 +127,7 @@ namespace InDet { ATH_MSG_VERBOSE( "REGTEST: TRT : DriftCircleCollection contains " << p_rio->size() << " clusters" ); #endif - IdentifierHash hash = p_rio->identifyHash(); - ATH_CHECK(rioContainer->addOrDelete(std::move(p_rio), hash)); + ATH_CHECK(lock.addOrDelete(std::move(p_rio))); } } diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx index 7c855cb211c..58ffadd63ce 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx @@ -255,7 +255,8 @@ StatusCode SiTrackerSpacePointFinder::execute_r (const EventContext& ctx) const const SCT_ClusterCollection *colNext=&(**it); // Create SpacePointCollection IdentifierHash idHash = colNext->identifyHash(); - if(spacePointContainer_SCT->tryFetch(idHash)){ + SpacePointContainer::IDC_WriteHandle lock = spacePointContainer_SCT->getWriteHandle(idHash); + if(lock.alreadyPresent()){ ATH_MSG_DEBUG("SCT Hash " << idHash << " is already in cache"); ++sctCacheCount; continue; //Skip if already present in cache @@ -275,7 +276,7 @@ StatusCode SiTrackerSpacePointFinder::execute_r (const EventContext& ctx) const ATH_MSG_VERBOSE( "SiTrackerSpacePointFinder algorithm found no space points" ); } else { //In a MT environment the cache maybe filled by another thread in which case this will delete the duplicate - StatusCode sc= spacePointContainer_SCT->addOrDelete( std::move(spacepointCollection), idHash ); + StatusCode sc= lock.addOrDelete( std::move(spacepointCollection) ); if (sc.isFailure()){ ATH_MSG_ERROR( "Failed to add SpacePoints to container" ); return StatusCode::RECOVERABLE; @@ -305,8 +306,8 @@ StatusCode SiTrackerSpacePointFinder::execute_r (const EventContext& ctx) const { ATH_MSG_VERBOSE( "Collection num " << numColl++ ); IdentifierHash idHash = (*colNext)->identifyHash(); - - if(spacePointContainerPixel->tryFetch(idHash)){ + SpacePointContainer::IDC_WriteHandle lock = spacePointContainerPixel->getWriteHandle(idHash); + if(lock.alreadyPresent()){ ATH_MSG_DEBUG("pixel Hash " << idHash << " is already in cache"); ++pixCacheCount; continue; @@ -331,7 +332,7 @@ StatusCode SiTrackerSpacePointFinder::execute_r (const EventContext& ctx) const } else { - StatusCode sc = spacePointContainerPixel->addOrDelete( std::move(spacepointCollection), idHash ); + StatusCode sc = lock.addOrDelete( std::move(spacepointCollection) ); if (sc.isFailure()) { ATH_MSG_ERROR( "Failed to add SpacePoints to container" ); -- GitLab