diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/CMakeLists.txt b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/CMakeLists.txt index 95bdc59774155f0f59433ab3852dbff84af03969..e94a65f344dc0de7584f5b744603659387af72be 100644 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/CMakeLists.txt +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/CMakeLists.txt @@ -18,7 +18,6 @@ atlas_depends_on_subdirs( PUBLIC Tracking/TrkEvent/TrkSpacePoint Tracking/TrkEvent/VxVertex PRIVATE - Control/CxxUtils DetectorDescription/AtlasDetDescr Event/xAOD/xAODEventInfo InnerDetector/InDetConditions/InDetBeamSpotService @@ -33,10 +32,10 @@ atlas_add_library( SiSpacePointFormationLib PUBLIC_HEADERS SiSpacePointFormation INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel InDetReadoutGeometry InDetPrepRawData TrkSpacePoint VxVertex SiSpacePointToolLib - PRIVATE_LINK_LIBRARIES CxxUtils AtlasDetDescr xAODEventInfo InDetIdentifier ) + PRIVATE_LINK_LIBRARIES AtlasDetDescr xAODEventInfo InDetIdentifier ) atlas_add_component( SiSpacePointFormation src/components/*.cxx INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel InDetReadoutGeometry InDetPrepRawData SiSpacePointToolLib TrkSpacePoint VxVertex CxxUtils AtlasDetDescr xAODEventInfo InDetIdentifier SiSpacePointFormationLib ) + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel InDetReadoutGeometry InDetPrepRawData SiSpacePointToolLib TrkSpacePoint VxVertex AtlasDetDescr xAODEventInfo InDetIdentifier SiSpacePointFormationLib ) diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiElementProperties.h b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiElementProperties.h index d3e687ce1c36df7916bea0865150d51eb2cbb8ec..e0b2fb1b8a35068b7a818b7ee68c6f5c5af03ff6 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiElementProperties.h +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiElementProperties.h @@ -34,7 +34,7 @@ public: ~SiElementProperties(); - std::vector<IdentifierHash>* neighbours (void); + const std::vector<IdentifierHash>* neighbours (void); float halfWidth (void); private: @@ -49,7 +49,7 @@ private: //-------------------------------------------------------------------------- -inline std::vector<IdentifierHash>* +inline const std::vector<IdentifierHash>* SiElementProperties::neighbours() { return &m_neighbours; diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiElementPropertiesTable.h b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiElementPropertiesTable.h index 45b253d50e3af48ec608c0deeacaf40d8134f434..cb6c9d2ef5676a002f665a14d3dfb94d083f0d0c 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiElementPropertiesTable.h +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiElementPropertiesTable.h @@ -22,7 +22,7 @@ class SiDetectorElementCollection; namespace InDet { -class SiElementPropertiesTable +class SiElementPropertiesTable final { public: @@ -31,26 +31,23 @@ public: float epsilonWidth); ~SiElementPropertiesTable(); - std::vector<IdentifierHash>* neighbours(const IdentifierHash& waferID); - float halfWidth(IdentifierHash hashID); + const std::vector<IdentifierHash>* neighbours(const IdentifierHash& waferID) const; + float halfWidth(IdentifierHash hashID) const; private: std::vector<SiElementProperties*> m_properties; - const InDetDD::SiDetectorElementCollection& m_elements; - int m_maxSCT; - std::vector<SiElementProperties*>::const_iterator m_propertiesBegin; }; -inline std::vector<IdentifierHash>* -SiElementPropertiesTable::neighbours(const IdentifierHash& waferID) +inline const std::vector<IdentifierHash>* +SiElementPropertiesTable::neighbours(const IdentifierHash& waferID) const { return (m_properties[(unsigned int)waferID])->neighbours(); } inline float -SiElementPropertiesTable::halfWidth(IdentifierHash waferID) +SiElementPropertiesTable::halfWidth(IdentifierHash waferID) const { return (m_properties[(unsigned int)waferID])->halfWidth(); } diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiTrackerSpacePointFinder.h b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiTrackerSpacePointFinder.h index f261e55e1892881e1e21642881d226087cfb45a2..c0f66f966945eebaa97230e7edb49dee05e90861 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiTrackerSpacePointFinder.h +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiTrackerSpacePointFinder.h @@ -46,7 +46,7 @@ #ifndef SiSpacePointFormation_SI_POINT_FINDER_H #define SiSpacePointFormation_SI_POINT_FINDER_H -#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" #include "AthContainers/DataVector.h" @@ -60,7 +60,7 @@ #include "InDetPrepRawData/SiClusterContainer.h" #include "InDetPrepRawData/PixelClusterContainer.h" #include "InDetPrepRawData/SCT_ClusterContainer.h" - +#include "TrkSpacePoint/SpacePointContainer.h" #include "GeoPrimitives/GeoPrimitives.h" class Event; @@ -82,7 +82,15 @@ namespace InDet { class SiElementPropertiesTable; - class SiTrackerSpacePointFinder:public AthAlgorithm { + class SiTrackerSpacePointFinder:public AthReentrantAlgorithm { + + struct SPFCache{//This is a temporary object to aid reentrant coding + Amg::Vector3D vertex; + const EventContext& ctx; + const SCT_ClusterContainer* SCTCContainer; + SPFCache(const EventContext& inctx) : ctx(inctx), SCTCContainer(nullptr) { } + }; + public: SiTrackerSpacePointFinder(const std::string& name, @@ -90,11 +98,11 @@ namespace InDet { ~SiTrackerSpacePointFinder(); - StatusCode initialize(); + StatusCode initialize() override; - StatusCode execute(); + StatusCode execute_r (const EventContext& ctx) const override; - StatusCode finalize(); + StatusCode finalize() override; private: // methods @@ -106,25 +114,20 @@ namespace InDet { void addSCT_SpacePoints (const SCT_ClusterCollection* next, - SpacePointCollection* spacepointCollection, SpacePointOverlapCollection* spacepointOverlapCollection); + SpacePointCollection* spacepointCollection, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; void checkForSCT_Points (const SCT_ClusterCollection* clusters1, - const IdentifierHash& id2, double minDiff, double maxDiff, - SpacePointCollection* spacepointCollection, bool overlapColl, SpacePointOverlapCollection* spacepointOverlapCollection); + const IdentifierHash id2, double minDiff, double maxDiff, + SpacePointCollection* spacepointCollection, bool overlapColl, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; void checkForSCT_Points (const SCT_ClusterCollection* clusters1, - const IdentifierHash& id2, double min1, double max1, - double min2, double max2, SpacePointOverlapCollection* spacepointOverlapCollection); + const IdentifierHash id2, double min1, double max1, + double min2, double max2, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; // data members -// std::string m_SCT_ClustersName; -// std::string m_PixelsClustersName; -// std::string m_spacePointsSCTName; -// std::string m_spacePointsPixelName; -// std::string m_spacePointsOverlapName; SG::ReadHandleKey<SCT_ClusterContainer> m_Sct_clcontainerKey; SG::ReadHandleKey<PixelClusterContainer> m_Pixel_clcontainerKey; bool m_selectPixels; @@ -147,20 +150,22 @@ namespace InDet { float m_xVertex; float m_yVertex; float m_zVertex; - Amg::Vector3D m_vertex; ServiceHandle<IBeamCondSvc> m_iBeamCondSvc; - int m_numberOfEvents; + mutable std::atomic<int> m_numberOfEvents; + mutable std::atomic<int> m_numberOfPixel; + mutable std::atomic<int> m_numberOfSCT; const InDetDD::SCT_DetectorManager* m_manager; // const InDetDD::PixelDetectorManager* m_managerPixel; // unused const SCT_ID* m_idHelper; const PixelID* m_idHelperPixel; - SiElementPropertiesTable* m_properties; + static const SiElementPropertiesTable* s_properties; SG::WriteHandleKey<SpacePointContainer> m_SpacePointContainer_SCTKey; SG::WriteHandleKey<SpacePointContainer> m_SpacePointContainerPixelKey; SG::WriteHandleKey<SpacePointOverlapCollection> m_spacepointoverlapCollectionKey; - + SG::UpdateHandleKey<SpacePointCache> m_SpacePointCache_SCTKey; + SG::UpdateHandleKey<SpacePointCache> m_SpacePointCache_PixKey; ToolHandle< SiSpacePointMakerTool > m_SiSpacePointMakerTool; }; diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTable.cxx b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTable.cxx index ed176f3cb05acc1b439a0cc631a7d7da6b7692b8..54c4223afeb1798e70d44177a3fb7524b73ea0e1 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTable.cxx +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiElementPropertiesTable.cxx @@ -19,24 +19,23 @@ namespace InDet{ SiElementPropertiesTable::SiElementPropertiesTable(const SCT_ID& idHelper, const InDetDD::SiDetectorElementCollection& elements, float epsilonWidth) - : m_elements(elements){ - m_maxSCT = idHelper.wafer_hash_max(); - m_properties.reserve(m_maxSCT); - for (int i = 0; i < m_maxSCT; ++i){ + { + size_t maxSCT = idHelper.wafer_hash_max(); + m_properties.assign(maxSCT, nullptr); + for (size_t i = 0; i < maxSCT; ++i){ IdentifierHash hash(i); - const InDetDD::SiDetectorElement* element = m_elements[hash]; + const InDetDD::SiDetectorElement* element = elements[hash]; if (element != 0){ SiElementProperties* props = new SiElementProperties(hash, idHelper,*element,epsilonWidth); m_properties[i] = props; - }else{ - m_properties[i] = 0; } } } //-------------------------------------------------------------------------- SiElementPropertiesTable::~SiElementPropertiesTable(){ - for (int i=0; i < m_maxSCT; ++i){ + size_t maxSCT = m_properties.size(); + for (size_t i=0; i < maxSCT; ++i){ delete m_properties[i];m_properties[i] =0; } } diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx index b16375ddf6b4ef345702be7ed6df21e4ebdf8952..894c5c1cdb644b413b96d4ebdd8bdb8ff62ec743 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx @@ -22,7 +22,6 @@ ATLAS Collaboration // Space point Classes, #include "TrkSpacePoint/SpacePoint.h" #include "TrkSpacePoint/SpacePointCollection.h" -#include "TrkSpacePoint/SpacePointContainer.h" #include "TrkSpacePoint/SpacePointOverlapCollection.h" #include "TrkSpacePoint/SpacePointCLASS_DEF.h" #include "InDetIdentifier/PixelID.h" @@ -34,20 +33,15 @@ ATLAS Collaboration #include "xAODEventInfo/EventInfo.h" #include "InDetBeamSpotService/IBeamCondSvc.h" +namespace InDet { -#include "CxxUtils/make_unique.h" +const SiElementPropertiesTable* SiTrackerSpacePointFinder::s_properties = nullptr; -namespace InDet { //------------------------------------------------------------------------ SiTrackerSpacePointFinder::SiTrackerSpacePointFinder(const std::string& name, ISvcLocator* pSvcLocator) - : AthAlgorithm(name, pSvcLocator), - //m_SCT_ClustersName("SCT_Clusters"), - //m_PixelsClustersName("PixelClusters"), - //m_spacePointsSCTName("SCT_SpacePoints"), - //m_spacePointsPixelName("PixelSpacePoints"), - //m_spacePointsOverlapName("OverlapSpacePoints"), + : AthReentrantAlgorithm(name, pSvcLocator), m_Sct_clcontainerKey("SCT_Clusters"), m_Pixel_clcontainerKey("PixelClusters"), m_selectPixels(true), @@ -64,14 +58,15 @@ namespace InDet { m_yVertex(0.), m_zVertex(0.), m_iBeamCondSvc("BeamCondSvc",name), - m_numberOfEvents(0), + m_numberOfEvents(0), m_numberOfPixel(0), m_numberOfSCT(0), m_manager(0), m_idHelper(nullptr), m_idHelperPixel(nullptr), - m_properties(nullptr), m_SpacePointContainer_SCTKey("SCT_SpacePoints"), m_SpacePointContainerPixelKey("PixelSpacePoints"), m_spacepointoverlapCollectionKey("OverlapSpacePoints"), + m_SpacePointCache_SCTKey(""), + m_SpacePointCache_PixKey(""), m_SiSpacePointMakerTool("InDet::SiSpacePointMakerTool", this) { //Use the same space point name both for internal use (for graphics) end @@ -99,6 +94,10 @@ namespace InDet { declareProperty("VertexX", m_xVertex); declareProperty("VertexY", m_yVertex); declareProperty("VertexZ", m_zVertex); + + declareProperty("SpacePointCacheSCT", m_SpacePointCache_SCTKey); + declareProperty("SpacePointCachePix", m_SpacePointCache_PixKey); + } //-------------------------------------------------------------------------- SiTrackerSpacePointFinder::~SiTrackerSpacePointFinder() @@ -115,25 +114,25 @@ StatusCode SiTrackerSpacePointFinder::initialize() ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); return StatusCode::FAILURE; } - ATH_CHECK( m_Sct_clcontainerKey.initialize() ); + ATH_CHECK( m_Sct_clcontainerKey.initialize(m_selectSCTs) ); if (m_selectPixels && m_Pixel_clcontainerKey.key().empty()){ ATH_MSG_FATAL( "Pixels selected and no name set for Pixel clusters"); return StatusCode::FAILURE; } - ATH_CHECK( m_Pixel_clcontainerKey.initialize() ); + ATH_CHECK( m_Pixel_clcontainerKey.initialize(m_selectPixels) ); if (m_SpacePointContainer_SCTKey.key().empty()){ ATH_MSG_FATAL( "No name set for SCT space points"); return StatusCode::FAILURE; } - ATH_CHECK( m_SpacePointContainer_SCTKey.initialize() ); + ATH_CHECK( m_SpacePointContainer_SCTKey.initialize(m_selectSCTs) ); if (m_SpacePointContainerPixelKey.key().empty()){ ATH_MSG_FATAL( "No name set for Pixels space points"); return StatusCode::FAILURE; } - ATH_CHECK( m_SpacePointContainerPixelKey.initialize() ); + ATH_CHECK( m_SpacePointContainerPixelKey.initialize(m_selectPixels) ); if (m_spacepointoverlapCollectionKey.key().empty()){ ATH_MSG_FATAL( "No name set for overlap space points"); @@ -144,8 +143,6 @@ StatusCode SiTrackerSpacePointFinder::initialize() // create containers (requires the Identifier Helpers) if (m_selectPixels){ ATH_CHECK(detStore()->retrieve(m_idHelperPixel,"PixelID")); - //m_SpacePointContainerPixel = new SpacePointContainer(m_idHelperPixel->wafer_hash_max()); - } if (m_selectSCTs) { @@ -156,8 +153,11 @@ StatusCode SiTrackerSpacePointFinder::initialize() // Make a table of neighbours and widths of side 1 SCT wafers //ADAM - removed const cast to test without - const InDetDD::SiDetectorElementCollection* elements =(m_manager->getDetectorElementCollection()); - m_properties = new SiElementPropertiesTable(*m_idHelper, *elements, m_epsWidth); + //Using const static to save memory in cases of multiple instances of this algorithm. + if(s_properties==nullptr){ + const InDetDD::SiDetectorElementCollection* elements =(m_manager->getDetectorElementCollection()); + s_properties = new SiElementPropertiesTable(*m_idHelper, *elements, m_epsWidth); + } } ATH_CHECK(m_SiSpacePointMakerTool.retrieve()); @@ -169,51 +169,61 @@ StatusCode SiTrackerSpacePointFinder::initialize() <<" , "<< m_yVertex << " , " << m_yVertex<< " ) " ); } } + + ATH_CHECK(m_SpacePointCache_SCTKey.initialize(!m_SpacePointCache_SCTKey.key().empty())); + ATH_CHECK(m_SpacePointCache_PixKey.initialize(!m_SpacePointCache_PixKey.key().empty())); + ATH_MSG_INFO( "SiTrackerSpacePointFinder::initialized for package version " << PACKAGE_VERSION ); return StatusCode::SUCCESS; } //------------------------------------------------------------------------- -StatusCode SiTrackerSpacePointFinder::execute() +StatusCode SiTrackerSpacePointFinder::execute_r (const EventContext& ctx) const { -#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT - const EventContext& ctx = getContext(); -#else - const EventContext& ctx = *getContext(); -#endif + ++m_numberOfEvents; + SPFCache r_cache(ctx); if (! m_overrideBS){ - m_vertex = m_iBeamCondSvc->beamVtx().position(); + r_cache.vertex = m_iBeamCondSvc->beamVtx().position(); } else { - m_vertex = Amg::Vector3D(m_xVertex,m_yVertex,m_zVertex); + r_cache.vertex = Amg::Vector3D(m_xVertex,m_yVertex,m_zVertex); } // register the IdentifiableContainer into StoreGate SG::WriteHandle<SpacePointContainer> spacePointContainerPixel; if (m_selectPixels){ - spacePointContainerPixel = SG::WriteHandle<SpacePointContainer>( m_SpacePointContainerPixelKey, ctx ); - ATH_CHECK( spacePointContainerPixel.record( CxxUtils::make_unique<SpacePointContainer>(m_idHelperPixel->wafer_hash_max()) ) ); - - ATH_MSG_DEBUG( "Container '" << spacePointContainerPixel.name() << "' initialised and recorded in StoreGate" ); + if(m_SpacePointCache_PixKey.key().empty()){ + ATH_CHECK( spacePointContainerPixel.record( std::make_unique<SpacePointContainer>(m_idHelperPixel->wafer_hash_max()) ) ); + ATH_MSG_DEBUG("Created SpacePointContainer " << m_SpacePointContainerPixelKey.key() << " N= " << m_idHelperPixel->wafer_hash_max()); + }else{ + SG::UpdateHandle<SpacePointCache> updateH( m_SpacePointCache_PixKey, ctx ); + ATH_CHECK(updateH.isValid()); + ATH_CHECK( spacePointContainerPixel.record( std::make_unique<SpacePointContainer>(updateH.ptr()) ) ); + ATH_MSG_DEBUG("Created SpacePointContainer " << m_SpacePointContainerPixelKey.key() << " from cache " << m_SpacePointCache_PixKey.key()); + } } SG::WriteHandle<SpacePointContainer> spacePointContainer_SCT; if (m_selectSCTs){ spacePointContainer_SCT = SG::WriteHandle<SpacePointContainer>( m_SpacePointContainer_SCTKey, ctx ); - ATH_CHECK( spacePointContainer_SCT.record( CxxUtils::make_unique<SpacePointContainer>(m_idHelper->wafer_hash_max()) ) ); - - //m_SpacePointContainer_SCT->addRef(); - ATH_MSG_DEBUG( "Container '" << spacePointContainer_SCT.name() << "' initialised and recorded in StoreGate" ); + if(m_SpacePointCache_SCTKey.key().empty()){ + ATH_CHECK( spacePointContainer_SCT.record( std::make_unique<SpacePointContainer>(m_idHelper->wafer_hash_max()) ) ); + ATH_MSG_DEBUG("Created SpacePointContainer " << m_SpacePointContainer_SCTKey.key() << " N= " << m_idHelper->wafer_hash_max()); + }else{ + SG::UpdateHandle<SpacePointCache> updateH( m_SpacePointCache_SCTKey, ctx ); + ATH_CHECK(updateH.isValid()); + ATH_CHECK( spacePointContainer_SCT.record( std::make_unique<SpacePointContainer>(updateH.ptr()) ) ); + ATH_MSG_DEBUG("Created SpacePointContainer " << m_SpacePointContainer_SCTKey.key() << " from cache " << m_SpacePointCache_SCTKey.key()); + } } SG::WriteHandle<SpacePointOverlapCollection> spacepointoverlapCollection( m_spacepointoverlapCollectionKey, ctx ); - ATH_CHECK( spacepointoverlapCollection.record( CxxUtils::make_unique<SpacePointOverlapCollection>() ) ); + ATH_CHECK( spacepointoverlapCollection.record( std::make_unique<SpacePointOverlapCollection>() ) ); - //m_spacepointoverlapCollection->addRef(); ATH_MSG_DEBUG( "Container '" << spacepointoverlapCollection.name() << "' initialised" ); if (m_selectSCTs){ @@ -224,6 +234,9 @@ StatusCode SiTrackerSpacePointFinder::execute() msg(MSG:: FATAL) << "Could not find the data object "<< sct_clcontainer.name() << " !" << endmsg; return StatusCode::RECOVERABLE; } + + r_cache.SCTCContainer = sct_clcontainer.cptr(); + ATH_MSG_DEBUG( "SCT Cluster container found: " << sct_clcontainer->size() << " collections" ); // Get hold of all clusters and iterate through them. // Pixel clusters will be converted immediately to pixel space points. @@ -237,28 +250,31 @@ StatusCode SiTrackerSpacePointFinder::execute() const SCT_ClusterCollection *colNext=&(**it); // Create SpacePointCollection IdentifierHash idHash = colNext->identifyHash(); + if(spacePointContainer_SCT->tryFetch(idHash)){ + ATH_MSG_DEBUG("SCT Hash " << idHash << " is already in cache"); + continue; //Skip if already present in cache + } + Identifier elementID = colNext->identify(); - SpacePointCollection* spacepointCollection = new SpacePointCollection(idHash); + auto spacepointCollection = std::make_unique<SpacePointCollection>(idHash); spacepointCollection->setIdentifier(elementID); if ( colNext->size() != 0){ - addSCT_SpacePoints(colNext,spacepointCollection,spacepointoverlapCollection.ptr()); + addSCT_SpacePoints(colNext,spacepointCollection.get(),spacepointoverlapCollection.ptr(), r_cache); } else { ATH_MSG_DEBUG( "Empty SCT cluster collection" ); } - - if (spacepointCollection->size() == 0){ + size_t size = spacepointCollection->size(); + if (size == 0){ ATH_MSG_VERBOSE( "SiTrackerSpacePointFinder algorithm found no space points" ); - // -me- clean up memory - delete (spacepointCollection); } else { - StatusCode sc= spacePointContainer_SCT->addCollection( spacepointCollection, - spacepointCollection->identifyHash() ); + //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 ); if (sc.isFailure()){ ATH_MSG_ERROR( "Failed to add SpacePoints to container" ); return StatusCode::RECOVERABLE; } - ATH_MSG_VERBOSE( spacepointCollection->size()<< " SpacePoints successfully added to Container !" ); + ATH_MSG_VERBOSE( size << " SpacePoints successfully added to Container !" ); } } } @@ -282,38 +298,39 @@ StatusCode SiTrackerSpacePointFinder::execute() for (; colNext != lastCol; ++colNext) { ATH_MSG_VERBOSE( "Collection num " << numColl++ ); + IdentifierHash idHash = (*colNext)->identifyHash(); + if(spacePointContainerPixel->tryFetch(idHash)){ + ATH_MSG_DEBUG("pixel Hash " << idHash << " is already in cache"); + continue; + } // Create SpacePointCollection Identifier elementID = (*colNext)->identify(); - IdentifierHash idHash = (*colNext)->identifyHash(); - SpacePointCollection* spacepointCollection = new SpacePointCollection(idHash); + auto spacepointCollection = std::make_unique< SpacePointCollection >(idHash); spacepointCollection->setIdentifier(elementID); if ((*colNext)->size() != 0) { - m_SiSpacePointMakerTool->fillPixelSpacePointCollection(*colNext,spacepointCollection); + m_SiSpacePointMakerTool->fillPixelSpacePointCollection(*colNext,spacepointCollection.get()); } else { ATH_MSG_DEBUG( "Empty pixel cluster collection" ); } - - if (spacepointCollection->size() == 0) + size_t size = spacepointCollection->size(); + if (size == 0) { ATH_MSG_DEBUG( "SiTrackerSpacePointFinder algorithm found no space points" ); - // -me- clean up memory - delete (spacepointCollection); } else { - StatusCode sc= spacePointContainerPixel->addCollection( spacepointCollection, - spacepointCollection->identifyHash() ); + StatusCode sc = spacePointContainerPixel->addOrDelete( std::move(spacepointCollection), idHash ); if (sc.isFailure()) { ATH_MSG_ERROR( "Failed to add SpacePoints to container" ); return StatusCode::RECOVERABLE; } - ATH_MSG_VERBOSE( spacepointCollection->size() + ATH_MSG_VERBOSE( size << " SpacePoints successfully added to Container !" ); } } @@ -329,7 +346,8 @@ StatusCode SiTrackerSpacePointFinder::execute() { ATH_MSG_DEBUG( spacepointoverlapCollection->size() <<" overlap space points registered." ); } - + m_numberOfPixel += spacePointContainerPixel->numberOfCollections(); + m_numberOfSCT += spacePointContainer_SCT->numberOfCollections(); return StatusCode::SUCCESS; } @@ -338,9 +356,11 @@ StatusCode SiTrackerSpacePointFinder::finalize() { ATH_MSG_INFO( "SiTrackerSpacePointFinder::finalize()" ); ATH_MSG_INFO( m_numberOfEvents << " events processed" ); - - delete m_properties; - + ATH_MSG_INFO( m_numberOfPixel << " pixel collections processed" ); + ATH_MSG_INFO( m_numberOfSCT << " sct collections processed" ); + if(s_properties){ + delete s_properties; s_properties = nullptr; + } return StatusCode::SUCCESS; } @@ -348,7 +368,7 @@ StatusCode SiTrackerSpacePointFinder::finalize() void SiTrackerSpacePointFinder:: addSCT_SpacePoints(const SCT_ClusterCollection* next, - SpacePointCollection* spacepointCollection, SpacePointOverlapCollection* spacepointOverlapCollection) + SpacePointCollection* spacepointCollection, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const { // Do nothing unless this is a side 1 detector (strips of const phi). @@ -366,8 +386,8 @@ addSCT_SpacePoints(const SCT_ClusterCollection* next, // "check1" is used for opposite and eta overlaps. // check2 for phi overlaps - std::vector<IdentifierHash>* - others(m_properties->neighbours(thisHash)); + const std::vector<IdentifierHash>* + others(s_properties->neighbours(thisHash)); if (others==0 || others->empty() ) return; std::vector<IdentifierHash>::const_iterator otherHash = others->begin(); @@ -375,7 +395,7 @@ addSCT_SpacePoints(const SCT_ClusterCollection* next, // check opposite wafer checkForSCT_Points(next, *otherHash, -m_overlapLimitOpposite, +m_overlapLimitOpposite, - spacepointCollection,overlapColl,spacepointOverlapCollection); + spacepointCollection,overlapColl,spacepointOverlapCollection, r_cache); if (! m_overlap) return; @@ -383,17 +403,17 @@ addSCT_SpacePoints(const SCT_ClusterCollection* next, overlapColl = true; ++otherHash; if (otherHash == others->end() ) return; - float hwidth(m_properties->halfWidth(thisHash)); + float hwidth(s_properties->halfWidth(thisHash)); // half-width of wafer checkForSCT_Points(next, *otherHash, -hwidth, -hwidth+m_overlapLimitPhi, - +hwidth-m_overlapLimitPhi, +hwidth,spacepointOverlapCollection); + +hwidth-m_overlapLimitPhi, +hwidth,spacepointOverlapCollection, r_cache); ++otherHash; if (otherHash == others->end() ) return; checkForSCT_Points(next, *otherHash, +hwidth-m_overlapLimitPhi, +hwidth, - -hwidth, -hwidth+m_overlapLimitPhi,spacepointOverlapCollection); + -hwidth, -hwidth+m_overlapLimitPhi,spacepointOverlapCollection, r_cache); // if barrel, check the eta overlaps too. // In this case, action depends on whether layer is even or odd @@ -412,24 +432,24 @@ addSCT_SpacePoints(const SCT_ClusterCollection* next, { checkForSCT_Points(next, *otherHash, +m_overlapLimitEtaMin, +m_overlapLimitEtaMax, - spacepointCollection,overlapColl,spacepointOverlapCollection); + spacepointCollection,overlapColl,spacepointOverlapCollection, r_cache); ++otherHash; if (otherHash == others->end() ) return; checkForSCT_Points(next, *otherHash, -m_overlapLimitEtaMax, -m_overlapLimitEtaMin, - spacepointCollection,overlapColl,spacepointOverlapCollection); + spacepointCollection,overlapColl,spacepointOverlapCollection, r_cache); }else{ checkForSCT_Points(next, *otherHash, -m_overlapLimitEtaMax, -m_overlapLimitEtaMin, - spacepointCollection,overlapColl,spacepointOverlapCollection); + spacepointCollection,overlapColl,spacepointOverlapCollection, r_cache); ++otherHash; if (otherHash == others->end() ) return; checkForSCT_Points(next, *otherHash, +m_overlapLimitEtaMin, +m_overlapLimitEtaMax, - spacepointCollection,overlapColl,spacepointOverlapCollection); + spacepointCollection,overlapColl,spacepointOverlapCollection, r_cache); } } } @@ -439,56 +459,40 @@ addSCT_SpacePoints(const SCT_ClusterCollection* next, void SiTrackerSpacePointFinder:: checkForSCT_Points(const SCT_ClusterCollection* clusters1, - const IdentifierHash& id2, double min, double max, - SpacePointCollection* spacepointCollection, bool overlapColl, SpacePointOverlapCollection* spacepointOverlapCollection) + const IdentifierHash id2, double min, double max, + SpacePointCollection* spacepointCollection, bool overlapColl, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const { -#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT - const EventContext& ctx = getContext(); -#else - const EventContext& ctx = *getContext(); -#endif + // Get the cluster collections for these two detectors. // Require that (xPhi2 - xPhi1) lie in the range specified. // Used for opposite and eta modules - SG::ReadHandle<SCT_ClusterContainer> sct_clcontainer( m_Sct_clcontainerKey, ctx ); - SCT_ClusterContainer::const_iterator - it(sct_clcontainer->indexFind(id2)); - if (it==sct_clcontainer->end()) return; - - const SCT_ClusterCollection * clusters2 = *it; + //indexFindPtr is faster in the MT implementation + const SCT_ClusterCollection * clusters2 = r_cache.SCTCContainer->indexFindPtr(id2); + if (clusters2==nullptr) return; if (!overlapColl) { - m_SiSpacePointMakerTool->fillSCT_SpacePointCollection(clusters1, clusters2, min, max, m_allClusters, m_vertex, m_manager, spacepointCollection); + m_SiSpacePointMakerTool->fillSCT_SpacePointCollection(clusters1, clusters2, min, max, m_allClusters, r_cache.vertex, m_manager, spacepointCollection); } else { - m_SiSpacePointMakerTool->fillSCT_SpacePointEtaOverlapCollection(clusters1, clusters2, min, max, m_allClusters, m_vertex, m_manager, spacepointOverlapCollection); + m_SiSpacePointMakerTool->fillSCT_SpacePointEtaOverlapCollection(clusters1, clusters2, min, max, m_allClusters, r_cache.vertex, m_manager, spacepointOverlapCollection); } } //-------------------------------------------------------------------------- void SiTrackerSpacePointFinder:: checkForSCT_Points(const SCT_ClusterCollection* clusters1, - const IdentifierHash& id2, - double min1, double max1, double min2, double max2, SpacePointOverlapCollection* spacepointOverlapCollection) + const IdentifierHash id2, + double min1, double max1, double min2, double max2, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const { -#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT - const EventContext& ctx = getContext(); -#else - const EventContext& ctx = *getContext(); -#endif // get the cluster collections for these two detectors. Clus1 must lie // within min1 and max1 and clus between min2 and max2. Used for phi // overlaps. + const SCT_ClusterCollection * clusters2 (r_cache.SCTCContainer->indexFindPtr(id2)); + if (clusters2==nullptr) return; - SG::ReadHandle<SCT_ClusterContainer> sct_clcontainer( m_Sct_clcontainerKey, ctx ); - SCT_ClusterContainer::const_iterator - it(sct_clcontainer->indexFind(id2)); - if (it==sct_clcontainer->end()) return; - const SCT_ClusterCollection * clusters2 (&(**it)); - - m_SiSpacePointMakerTool->fillSCT_SpacePointPhiOverlapCollection(clusters1, clusters2, min1, max1, min2, max2, m_allClusters, m_vertex, m_manager, spacepointOverlapCollection); + m_SiSpacePointMakerTool->fillSCT_SpacePointPhiOverlapCollection(clusters1, clusters2, min1, max1, min2, max2, m_allClusters, r_cache.vertex, m_manager, spacepointOverlapCollection); } } //namespace diff --git a/InnerDetector/InDetRecTools/SiSpacePointTool/SiSpacePointTool/SiSpacePointMakerTool.h b/InnerDetector/InDetRecTools/SiSpacePointTool/SiSpacePointTool/SiSpacePointMakerTool.h old mode 100755 new mode 100644 index 44c0e3dd346d3eb7e27fb847bed86e9f4056e86e..6925944b410a2666a1f47beb2ab6fdcd4b66c50a --- a/InnerDetector/InDetRecTools/SiSpacePointTool/SiSpacePointTool/SiSpacePointMakerTool.h +++ b/InnerDetector/InDetRecTools/SiSpacePointTool/SiSpacePointTool/SiSpacePointMakerTool.h @@ -47,38 +47,36 @@ namespace InDet{ // Convert clusters to space points Trk::SpacePoint* makeSCT_SpacePoint(const InDet::SiCluster& cluster1, const InDet::SiCluster& cluster2, const Amg::Vector3D& vertexVec, - const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2); + const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2, double stripLengthGapTolerance) const; void fillSCT_SpacePointCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool allClusters, const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, - SpacePointCollection* spacepointCollection); + SpacePointCollection* spacepointCollection) const; void fillPixelSpacePointCollection(const InDet::PixelClusterCollection* clusters, - SpacePointCollection* spacepointCollection); + SpacePointCollection* spacepointCollection) const; void fillSCT_SpacePointEtaOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool allClusters, const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, - SpacePointOverlapCollection* spacepointOverlapCollection); + SpacePointOverlapCollection* spacepointOverlapCollection) const; void fillSCT_SpacePointPhiOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min1, double max1, double min2, double max2, bool allClusters, const Amg::Vector3D& vertexVec , const InDetDD::SCT_DetectorManager *SCT_Manager, - SpacePointOverlapCollection* spacepointOverlapCollection); + SpacePointOverlapCollection* spacepointOverlapCollection) const; private: double m_stripLengthTolerance; double m_SCTgapParameter; - double m_stripLengthGapTolerance; // option to use closest approach of SCT strips as position for SpacePoint bool m_usePerpProj; - std::vector<Trk::SpacePoint*> m_tmpSpacePoints; const SCT_ID* m_idHelper; - double offset(const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2); + double offset(const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2, double&) const; }; } diff --git a/InnerDetector/InDetRecTools/SiSpacePointTool/src/SiSpacePointMakerTool.cxx b/InnerDetector/InDetRecTools/SiSpacePointTool/src/SiSpacePointMakerTool.cxx old mode 100755 new mode 100644 index 04de2661a3b6f634b3bc58c40aeb60d4aeae11e5..954035b0f0ceb41769037a889e1ca838cd860f64 --- a/InnerDetector/InDetRecTools/SiSpacePointTool/src/SiSpacePointMakerTool.cxx +++ b/InnerDetector/InDetRecTools/SiSpacePointTool/src/SiSpacePointMakerTool.cxx @@ -59,7 +59,7 @@ StatusCode SiSpacePointMakerTool::finalize() { //-------------------------------------------------------------------------- Trk::SpacePoint* SiSpacePointMakerTool::makeSCT_SpacePoint(const InDet::SiCluster& cluster1, const InDet::SiCluster& cluster2, const Amg::Vector3D& vertexVec, - const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2){ + const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2, double stripLengthGapTolerance) const { // -ME fixme- const InDetDD::SCT_DetectorManager *m_manager, const SCT_ID* m_idHelper) { // Find intersection of a line through a cluster on one sct detector and @@ -136,10 +136,10 @@ Trk::SpacePoint* SiSpacePointMakerTool::makeSCT_SpacePoint(const InDet::SiCluste if (fabs( m ) > limit) ok = false; else if (fabs((n=-(t.dot(qs)/r.dot(qs)))) > limit) ok = false; - if(!ok && m_stripLengthGapTolerance !=0.) { + if(!ok && stripLengthGapTolerance !=0.) { double qm = q.mag() ; - double limitn = limit+(m_stripLengthGapTolerance/qm); + double limitn = limit+(stripLengthGapTolerance/qm); if(fabs(m) <= limitn) { @@ -180,9 +180,9 @@ Trk::SpacePoint* SiSpacePointMakerTool::makeSCT_SpacePoint(const InDet::SiCluste //-------------------------------------------------------------------------- void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool m_allClusters, - const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, SpacePointCollection* spacepointCollection){ + const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, SpacePointCollection* spacepointCollection) const { - m_stripLengthGapTolerance = 0.; + double stripLengthGapTolerance = 0.; // Try all combinations of clusters for space points InDet::SCT_ClusterCollection::const_iterator @@ -201,10 +201,8 @@ void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_Cluste return; } - //Avoid over or under allocation by first putting spacepoints in - //m_tmpSpacePoints and then copying them to the spacepointCollection - //at the end. - m_tmpSpacePoints.clear(); + //tmpSpacePoints changed to local variable to enable rentrancy + std::vector<Trk::SpacePoint*> tmpSpacePoints; for (; clusters1Next!=clusters1Finish; ++clusters1Next){ Amg::Vector2D locpos = (*clusters1Next)->localPosition(); @@ -222,7 +220,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_Cluste break; } - if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2); min-=dm; max+=dm; } + if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2, stripLengthGapTolerance); min-=dm; max+=dm; } for (; clusters2Next != clusters2Finish; ++clusters2Next){ Amg::Vector2D locpos = (*clusters2Next)->localPosition(); @@ -231,23 +229,22 @@ void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_Cluste if ((min <= diff && diff <= max)||m_allClusters){ Trk::SpacePoint* sp = - makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2); + makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance); if (sp) { - m_tmpSpacePoints.push_back(sp); + tmpSpacePoints.push_back(sp); } } } } - spacepointCollection->reserve(spacepointCollection->size() + m_tmpSpacePoints.size()); - std::vector<Trk::SpacePoint*>::const_iterator it(m_tmpSpacePoints.begin()),itE(m_tmpSpacePoints.end()); + spacepointCollection->reserve(spacepointCollection->size() + tmpSpacePoints.size()); + std::vector<Trk::SpacePoint*>::const_iterator it(tmpSpacePoints.begin()),itE(tmpSpacePoints.end()); for (;it!=itE;++it) spacepointCollection->push_back(*it); - m_tmpSpacePoints.clear(); } //-------------------------------------------------------------------------- -void SiSpacePointMakerTool::fillPixelSpacePointCollection(const InDet::PixelClusterCollection* clusters, SpacePointCollection* spacepointCollection){ +void SiSpacePointMakerTool::fillPixelSpacePointCollection(const InDet::PixelClusterCollection* clusters, SpacePointCollection* spacepointCollection) const { IdentifierHash idHash = clusters->identifyHash(); InDet::PixelClusterCollection::const_iterator clusStart = clusters->begin(); InDet::PixelClusterCollection::const_iterator clusFinish = clusters->end(); @@ -268,9 +265,9 @@ void SiSpacePointMakerTool::fillPixelSpacePointCollection(const InDet::PixelClus void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool m_allClusters, const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, - SpacePointOverlapCollection* m_spacepointoverlapCollection){ + SpacePointOverlapCollection* m_spacepointoverlapCollection) const { - m_stripLengthGapTolerance = 0.; + double stripLengthGapTolerance = 0.; // Require that (xPhi2 - xPhi1) lie in the range specified. // Used eta modules @@ -304,7 +301,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet:: msg(MSG::ERROR) << "Bad cluster identifier " << m_idHelper->show_to_string((*clusters2Next)->identify()) <<endmsg; break; } - if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2); min-=dm; max+=dm; } + if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2, stripLengthGapTolerance); min-=dm; max+=dm; } for (; clusters2Next != clusters2Finish; ++clusters2Next){ Amg::Vector2D locpos = (*clusters2Next)->localPosition(); @@ -313,7 +310,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet:: if ((min <= diff && diff <= max)||m_allClusters){ Trk::SpacePoint* sp = - makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2); + makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance); if (sp) { m_spacepointoverlapCollection->push_back(sp); } @@ -328,9 +325,9 @@ void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet:: void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min1, double max1, double min2, double max2, bool m_allClusters, const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, - SpacePointOverlapCollection* m_spacepointoverlapCollection){ + SpacePointOverlapCollection* m_spacepointoverlapCollection) const { - m_stripLengthGapTolerance = 0.; if(m_SCTgapParameter!=0.) {min1-=20.; max1+=20.;} + double stripLengthGapTolerance = 0.; if(m_SCTgapParameter!=0.) {min1-=20.; max1+=20.;} // Clus1 must lie // within min1 and max1 and clus between min2 and max2. Used for phi @@ -366,7 +363,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet:: break; } - if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2); min2-=dm; max2+=dm; } + if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2, stripLengthGapTolerance); min2-=dm; max2+=dm; } for (; clusters2Next != clusters2Finish; ++clusters2Next) { @@ -375,7 +372,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet:: double xPhi2 = InDetDD::SiLocalPosition(localPos.y(),localPos.x(),0).xPhi(); if ((min2<= xPhi2 && xPhi2 <= max2)||m_allClusters){ Trk::SpacePoint* sp - (makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2)); + (makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance)); if (sp) { m_spacepointoverlapCollection->push_back(sp); } @@ -392,7 +389,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet:: /////////////////////////////////////////////////////////////////// double SiSpacePointMakerTool::offset - (const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2) + (const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2, double &stripLengthGapTolerance) const { const Amg::Transform3D& T1 = element1->transform(); const Amg::Transform3D& T2 = element2->transform(); @@ -406,7 +403,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet:: if(fabs(T1(2,2)) > .7) d*=(r/fabs(T1(2,3))); // endcap d = d*R/Z - m_stripLengthGapTolerance = d; + stripLengthGapTolerance = d; return dm; } diff --git a/InnerDetector/InDetTrigRecAlgs/SiTrigSpacePointFormation/src/SCT_TrigSpacePointTool.cxx b/InnerDetector/InDetTrigRecAlgs/SiTrigSpacePointFormation/src/SCT_TrigSpacePointTool.cxx index 0118d61f7133af44b84b62f700f33b6facfd57df..c19950f49478a6cc90be7be2b710b37ca3a093d0 100755 --- a/InnerDetector/InDetTrigRecAlgs/SiTrigSpacePointFormation/src/SCT_TrigSpacePointTool.cxx +++ b/InnerDetector/InDetTrigRecAlgs/SiTrigSpacePointFormation/src/SCT_TrigSpacePointTool.cxx @@ -173,7 +173,7 @@ addSCT_SpacePoints(const SCT_ClusterCollection* clusCollection, IdentifierHash thisHash = m_idHelper->wafer_hash(thisID); - std::vector<IdentifierHash>* + const std::vector<IdentifierHash>* others(m_properties->neighbours(thisHash)); if (others==0 || others->empty() ) return; std::vector<IdentifierHash>::const_iterator otherHash = others->begin(); diff --git a/Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePointContainer.h b/Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePointContainer.h index f38529f93affb5e986dd423b8deba2dfbfccc9c1..3d3adb90a1bc6c9c5c398e82065f0fa65099b5a6 100755 --- a/Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePointContainer.h +++ b/Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePointContainer.h @@ -22,6 +22,9 @@ #include "TrkSpacePoint/SpacePointCollection.h" //#include "TrkSpacePoint/SpacePointCLASS_DEF.h" + +typedef EventContainers::IdentifiableCache< SpacePointCollection > SpacePointCache; + class SpacePointContainer : public IdentifiableContainer<SpacePointCollection>{ @@ -33,6 +36,8 @@ public: // Constructor with parameters: SpacePointContainer(unsigned int max); + SpacePointContainer(SpacePointCache*); + // Destructor: virtual ~SpacePointContainer(); @@ -84,4 +89,8 @@ private: #include "CLIDSvc/CLASS_DEF.h" CLASS_DEF(SpacePointContainer,1273119430,1) + +CLASS_DEF( SpacePointCache , 198940329 , 1 ) + + #endif // TRKSPACEPOINT_SPACEPOINTCONTAINER_H diff --git a/Tracking/TrkEvent/TrkSpacePoint/src/SpacePointContainer.cxx b/Tracking/TrkEvent/TrkSpacePoint/src/SpacePointContainer.cxx index 19499502f59dcdd0c82bc7adc1e26e130178f23a..9df3bee771d8b90b1842916f625ae4784a10c960 100755 --- a/Tracking/TrkEvent/TrkSpacePoint/src/SpacePointContainer.cxx +++ b/Tracking/TrkEvent/TrkSpacePoint/src/SpacePointContainer.cxx @@ -19,6 +19,12 @@ SpacePointContainer::SpacePointContainer(unsigned int max) : { } +// Constructor with parameters: +SpacePointContainer::SpacePointContainer(SpacePointCache *cache) : + IdentifiableContainer<SpacePointCollection>(cache) +{ +} + // Destructor: SpacePointContainer::~SpacePointContainer() {