From 29aa05e46ad238cf133dfba075bb552fbc9d1ea3 Mon Sep 17 00:00:00 2001 From: Adam Edward Barton <adam.edward.barton@cern.ch> Date: Fri, 4 Mar 2016 15:46:31 +0100 Subject: [PATCH] Tag SiSpacePointFormation-01-00-08 (SiSpacePointFormation-01-00-08) * Tagged as SiSpacePointFormation-01-00-08 2016-01-21 Adam Barton * Ported to dataHandle framework * Removed Const cast, seemed unnecessary? --- .../SiSpacePointFormation/CMakeLists.txt | 41 ----- .../SiTrackerSpacePointFinder.h | 26 +-- .../SiSpacePointFormation/cmt/requirements | 1 + .../src/SiTrackerSpacePointFinder.cxx | 171 +++++++++++------- 4 files changed, 118 insertions(+), 121 deletions(-) delete mode 100644 InnerDetector/InDetRecAlgs/SiSpacePointFormation/CMakeLists.txt diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/CMakeLists.txt b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/CMakeLists.txt deleted file mode 100644 index 58078890b80..00000000000 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -################################################################################ -# Package: SiSpacePointFormation -################################################################################ - -# Declare the package name: -atlas_subdir( SiSpacePointFormation ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - Control/DataModel - DetectorDescription/GeoPrimitives - DetectorDescription/Identifier - GaudiKernel - InnerDetector/InDetDetDescr/InDetReadoutGeometry - InnerDetector/InDetRecEvent/InDetPrepRawData - InnerDetector/InDetRecTools/SiSpacePointTool - Tracking/TrkEvent/TrkSpacePoint - Tracking/TrkEvent/VxVertex - PRIVATE - DetectorDescription/AtlasDetDescr - Event/xAOD/xAODEventInfo - InnerDetector/InDetConditions/InDetBeamSpotService - InnerDetector/InDetDetDescr/InDetIdentifier ) - -# External dependencies: -find_package( Eigen ) - -# Component(s) in the package: -atlas_add_library( SiSpacePointFormationLib - src/*.cxx - PUBLIC_HEADERS SiSpacePointFormation - INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps DataModel GeoPrimitives Identifier GaudiKernel InDetReadoutGeometry InDetPrepRawData TrkSpacePoint VxVertex SiSpacePointToolLib - PRIVATE_LINK_LIBRARIES AtlasDetDescr xAODEventInfo InDetIdentifier ) - -atlas_add_component( SiSpacePointFormation - src/components/*.cxx - INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps DataModel GeoPrimitives Identifier GaudiKernel InDetReadoutGeometry InDetPrepRawData SiSpacePointToolLib TrkSpacePoint VxVertex AtlasDetDescr xAODEventInfo InDetIdentifier SiSpacePointFormationLib ) - diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiTrackerSpacePointFinder.h b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiTrackerSpacePointFinder.h index 8ba3a2ec841..d71da8e36c5 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiTrackerSpacePointFinder.h +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/SiSpacePointFormation/SiTrackerSpacePointFinder.h @@ -99,6 +99,11 @@ namespace InDet { private: // methods + SiTrackerSpacePointFinder() = delete; + SiTrackerSpacePointFinder(const SiTrackerSpacePointFinder&) =delete; + SiTrackerSpacePointFinder &operator=(const SiTrackerSpacePointFinder&) = delete; + + void addSCT_SpacePoints (const SCT_ClusterCollection* next, SpacePointCollection* spacepointCollection); @@ -113,16 +118,15 @@ namespace InDet { const IdentifierHash& id2, double min1, double max1, double min2, double max2); - std::string intString(int n); // data members - std::string m_SCT_ClustersName; - std::string m_PixelsClustersName; - std::string m_spacePointsSCTName; - std::string m_spacePointsPixelName; - std::string m_spacePointsOverlapName; - const SCT_ClusterContainer* m_Sct_clcontainer; - const PixelClusterContainer* m_Pixel_clcontainer; +// std::string m_SCT_ClustersName; +// std::string m_PixelsClustersName; +// std::string m_spacePointsSCTName; +// std::string m_spacePointsPixelName; +// std::string m_spacePointsOverlapName; + SG::ReadHandle<SCT_ClusterContainer> m_Sct_clcontainer; + SG::ReadHandle<PixelClusterContainer> m_Pixel_clcontainer; bool m_selectPixels; bool m_selectSCTs; bool m_overlap; // process all overlapping SCT pairs if true. @@ -154,9 +158,9 @@ namespace InDet { const PixelID* m_idHelperPixel; SiElementPropertiesTable* m_properties; - SpacePointContainer* m_SpacePointContainer_SCT; - SpacePointContainer* m_SpacePointContainerPixel; - SpacePointOverlapCollection* m_spacepointoverlapCollection; + SG::WriteHandle<SpacePointContainer> m_SpacePointContainer_SCT; + SG::WriteHandle<SpacePointContainer> m_SpacePointContainerPixel; + SG::WriteHandle<SpacePointOverlapCollection> m_spacepointoverlapCollection; ToolHandle< SiSpacePointMakerTool > m_SiSpacePointMakerTool; }; diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/cmt/requirements b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/cmt/requirements index 8e8f592a947..a532a53b194 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/cmt/requirements +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/cmt/requirements @@ -19,6 +19,7 @@ use GeoPrimitives GeoPrimitives-* DetectorDescription private +use CxxUtils CxxUtils-* Control use AtlasDetDescr AtlasDetDescr-* DetectorDescription use xAODEventInfo xAODEventInfo-* Event/xAOD use InDetBeamSpotService InDetBeamSpotService-* InnerDetector/InDetConditions diff --git a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx index 2fb33daef89..7d8749a1bfb 100755 --- a/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx +++ b/InnerDetector/InDetRecAlgs/SiSpacePointFormation/src/SiTrackerSpacePointFinder.cxx @@ -35,19 +35,22 @@ ATLAS Collaboration #include "InDetBeamSpotService/IBeamCondSvc.h" #include "GaudiKernel/PropertyMgr.h" + +#include "CxxUtils/make_unique.h" + 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"), - m_Sct_clcontainer(nullptr), - m_Pixel_clcontainer(nullptr), +// m_SCT_ClustersName ("SCT_Clusters"), +// m_PixelsClustersName ("PixelClusters"), +// m_spacePointsSCTName ("SCT_SpacePoints"), +// m_spacePointsPixelName ("PixelSpacePoints"), +// m_spacePointsOverlapName("OverlapSpacePoints"), + m_Sct_clcontainer("SCT_Clusters"), + m_Pixel_clcontainer("PixelClusters"), m_selectPixels (true), m_selectSCTs( true), m_overlap (true), // process overlaps of SCT wafers. @@ -68,19 +71,22 @@ SiTrackerSpacePointFinder::SiTrackerSpacePointFinder(const std::string& name, m_idHelper (nullptr), m_idHelperPixel (nullptr), m_properties (nullptr), - m_SpacePointContainer_SCT (nullptr), - m_SpacePointContainerPixel (nullptr), - m_spacepointoverlapCollection (nullptr), + m_SpacePointContainer_SCT ("SCT_SpacePoints"), + m_SpacePointContainerPixel ("PixelSpacePoints"), + m_spacepointoverlapCollection ("OverlapSpacePoints"), m_SiSpacePointMakerTool ("InDet::SiSpacePointMakerTool") { //Use the same space point name both for internal use (for graphics) end // for storing in TDS. If a name is the empty string, do not retrieve // those clusters. - declareProperty("SCT_ClustersName", m_SCT_ClustersName); - declareProperty("PixelsClustersName", m_PixelsClustersName); - declareProperty("SpacePointsSCTName", m_spacePointsSCTName); - declareProperty("SpacePointsPixelName", m_spacePointsPixelName); - declareProperty("SpacePointsOverlapName", m_spacePointsOverlapName); + declareProperty("SCT_ClustersName", m_Sct_clcontainer, "SCT clContainer" ) ; + declareProperty("PixelsClustersName", m_Pixel_clcontainer, "Pixel clContainer"); + + declareProperty("SpacePointsSCTName", m_SpacePointContainer_SCT, "SpacePoint SCT container"); + declareProperty("SpacePointsPixelName", m_SpacePointContainerPixel, "SpacePoint Pixel container"); + declareProperty("SpacePointsOverlapName", m_spacepointoverlapCollection, "Space Point Overlap collection" ); + + declareProperty("SiSpacePointMakerTool", m_SiSpacePointMakerTool); declareProperty("BeamPositionSvc", m_iBeamCondSvc); declareProperty("ProcessPixels", m_selectPixels); @@ -108,20 +114,20 @@ StatusCode SiTrackerSpacePointFinder::initialize() // Check that clusters, space points and ids have names - if (m_selectSCTs && m_SCT_ClustersName ==""){ + if (m_selectSCTs && m_Sct_clcontainer.name().empty()){ ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); return StatusCode::FAILURE; } - if (m_spacePointsSCTName ==""){ + if (m_SpacePointContainer_SCT.name().empty()){ ATH_MSG_FATAL( "No name set for SCT space points"); return StatusCode::FAILURE; } - if (m_spacePointsPixelName ==""){ + if (m_SpacePointContainerPixel.name().empty()){ ATH_MSG_FATAL( "No name set for Pixels space points"); return StatusCode::FAILURE; } - if (m_spacePointsOverlapName ==""){ + if (m_spacepointoverlapCollection.name().empty()){ ATH_MSG_FATAL( "No name set for overlap space points"); return StatusCode::FAILURE; } @@ -129,21 +135,20 @@ 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()); - // prevent SG from deleting object: - m_SpacePointContainerPixel->addRef(); +// m_SpacePointContainerPixel = new SpacePointContainer(m_idHelperPixel->wafer_hash_max()); + } if (m_selectSCTs){ ATH_CHECK(detStore()->retrieve(m_idHelper,"SCT_ID")); - m_SpacePointContainer_SCT = new SpacePointContainer(m_idHelper->wafer_hash_max()); - m_SpacePointContainer_SCT->addRef(); + // also need the SCT Manager to get the detectorElementCollection ATH_CHECK(detStore()->retrieve(m_manager,"SCT")); // Make a table of neighbours and widths of side 1 SCT wafers - InDetDD::SiDetectorElementCollection* elements =const_cast<InDetDD::SiDetectorElementCollection*>(m_manager->getDetectorElementCollection()); + //ADAM - removed const cast to test without + const InDetDD::SiDetectorElementCollection* elements =(m_manager->getDetectorElementCollection()); m_properties = new SiElementPropertiesTable(*m_idHelper, *elements, m_epsWidth); } @@ -164,6 +169,7 @@ StatusCode SiTrackerSpacePointFinder::initialize() StatusCode SiTrackerSpacePointFinder::execute() { +/* if (msgLvl(MSG::DEBUG)){ ATH_MSG_DEBUG( "SiTrackerSpacePointFinder::execute()" ); // Put out info about event. @@ -173,29 +179,39 @@ StatusCode SiTrackerSpacePointFinder::execute() ATH_MSG_ERROR( "Could not get event" ); return StatusCode::RECOVERABLE; } - ATH_MSG_DEBUG( "Event number event_" + intString(eventInfo->eventNumber()) ); + ATH_MSG_DEBUG( "Event number event_" + std::to_string(eventInfo->eventNumber()) ); } +*/ ++m_numberOfEvents; if (! m_overrideBS){ m_vertex = m_iBeamCondSvc->beamVtx().position(); } else { - m_vertex = Amg::Vector3D(m_xVertex,m_yVertex,m_zVertex); + m_vertex = Amg::Vector3D(m_xVertex,m_yVertex,m_zVertex); } // register the IdentifiableContainer into StoreGate if (m_selectPixels){ - m_SpacePointContainerPixel->cleanup(); - StatusCode sc = evtStore()->record(m_SpacePointContainerPixel,m_spacePointsPixelName,false); - if (sc.isFailure()){ - ATH_MSG_ERROR( "Container '" << m_spacePointsPixelName - << "' could not be recorded in StoreGate !" ); - return StatusCode::RECOVERABLE; - } - ATH_MSG_DEBUG( "Container '" << m_spacePointsPixelName << "' recorded in StoreGate" ); +// m_SpacePointContainerPixel->cleanup(); +// StatusCode sc = evtStore()->record(m_SpacePointContainerPixel,m_spacePointsPixelName,false); +// if (sc.isFailure()){ +// ATH_MSG_ERROR( "Container '" << m_spacePointsPixelName +// << "' could not be recorded in StoreGate !" ); +// return StatusCode::RECOVERABLE; +// } + m_SpacePointContainerPixel = CxxUtils::make_unique<SpacePointContainer>(m_idHelperPixel->wafer_hash_max()); + if (! m_SpacePointContainerPixel.isValid() ){ + msg(MSG:: FATAL) << "SpacePointContainer " << m_SpacePointContainerPixel.name() << "could not be initialised !"<< endreq; + return StatusCode::FAILURE; + } + // prevent SG from deleting object: +// m_SpacePointContainerPixel->addRef(); + + ATH_MSG_DEBUG( "Container '" << m_SpacePointContainerPixel.name() << "' initialised and recorded in StoreGate" ); } if (m_selectSCTs){ +/* m_SpacePointContainer_SCT->cleanup(); StatusCode sc = evtStore()->record(m_SpacePointContainer_SCT,m_spacePointsSCTName,false); if (sc.isFailure()){ @@ -203,23 +219,38 @@ StatusCode SiTrackerSpacePointFinder::execute() << "' could not be recorded in StoreGate !" ); return StatusCode::RECOVERABLE; } - ATH_MSG_DEBUG( "Container '" << m_spacePointsSCTName << "' recorded in StoreGate" ); +*/ + m_SpacePointContainer_SCT = CxxUtils::make_unique<SpacePointContainer>(m_idHelper->wafer_hash_max()); + if (! m_SpacePointContainer_SCT.isValid() ){ + msg(MSG:: FATAL) << "SpacePointContainer " << m_SpacePointContainer_SCT.name() << "could not be initialised !"<< endreq; + return StatusCode::FAILURE; + } + +//n m_SpacePointContainer_SCT->addRef(); + ATH_MSG_DEBUG( "Container '" << m_SpacePointContainer_SCT.name() << "' initialised and recorded in StoreGate" ); } // Get hold of IdentifiableContainer holding SCT clusters from TDS // ( because we need random access to get the second side). // Note there may not be any, but there could still be pixel clusters. - m_spacepointoverlapCollection = new SpacePointOverlapCollection(); +// m_spacepointoverlapCollection = new SpacePointOverlapCollection(); + + m_spacepointoverlapCollection = CxxUtils::make_unique<SpacePointOverlapCollection>(); + if (! m_spacepointoverlapCollection.isValid() ){ + msg(MSG:: FATAL) << "SpacePointOverlapCollection " << m_spacepointoverlapCollection.name() << "could not be initialised !"<< endreq; + return StatusCode::FAILURE; + } + +// m_spacepointoverlapCollection->addRef(); + ATH_MSG_DEBUG( "Container '" << m_spacepointoverlapCollection.name() << "' initialised" ); + if (m_selectSCTs){ // retrieve SCT cluster container - StatusCode sc = evtStore()->retrieve(m_Sct_clcontainer, m_SCT_ClustersName); - if (sc.isFailure() || ! m_Sct_clcontainer){ - ATH_MSG_ERROR( "SCT Cluster container not found" ); - return StatusCode::RECOVERABLE; - } else{ - ATH_MSG_DEBUG( "SCT Cluster container found: " << m_Sct_clcontainer->size() << " collections" ); - } - + if (!m_Sct_clcontainer.isValid()){ + msg(MSG:: FATAL) << "Could not find the data object "<< m_Sct_clcontainer.name() << " !" << endreq; + return StatusCode::RECOVERABLE; + } + ATH_MSG_DEBUG( "SCT Cluster container found: " << m_Sct_clcontainer->size() << " collections" ); // Get hold of all clusters and iterate through them. // Pixel clusters will be converted immediately to pixel space points. // For SCT clusters, posssible pairs will be found and space points computed. @@ -236,7 +267,7 @@ StatusCode SiTrackerSpacePointFinder::execute() SpacePointCollection* spacepointCollection = new SpacePointCollection(idHash); spacepointCollection->setIdentifier(elementID); - if ( colNext->size() != 0){ + if ( colNext->size() != 0){ addSCT_SpacePoints(colNext,spacepointCollection); } else { ATH_MSG_DEBUG( "Empty SCT cluster collection" ); @@ -246,29 +277,36 @@ StatusCode SiTrackerSpacePointFinder::execute() ATH_MSG_VERBOSE( "SiTrackerSpacePointFinder algorithm found no space points" ); // -me- clean up memory delete (spacepointCollection); - } else { - sc= m_SpacePointContainer_SCT->addCollection( spacepointCollection, + } else { + StatusCode sc= m_SpacePointContainer_SCT->addCollection( spacepointCollection, spacepointCollection->identifyHash() ); 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 !" ); - } + } } } if (m_selectPixels) { // retrieve Pixel cluster container - m_Pixel_clcontainer=0; - StatusCode sc = evtStore()->retrieve(m_Pixel_clcontainer, m_PixelsClustersName); - if (sc.isFailure() || ! m_Pixel_clcontainer) - { - ATH_MSG_ERROR( "Pixel Cluster container not found" ); - return StatusCode::RECOVERABLE; - } - ATH_MSG_DEBUG( "Pixel Cluster container found: " << m_Pixel_clcontainer->size() << " collections" ); +// m_Pixel_clcontainer=0; + //StatusCode sc = evtStore()->retrieve(m_Pixel_clcontainer, m_PixelsClustersName); +// if (sc.isFailure() || ! m_Pixel_clcontainer) +// { +// ATH_MSG_ERROR( "Pixel Cluster container not found" ); +// return StatusCode::RECOVERABLE; +// } +// ATH_MSG_DEBUG( "Pixel Cluster container found: " << m_Pixel_clcontainer->size() << " collections" ); + + if (!m_Pixel_clcontainer.isValid()){ + msg(MSG:: FATAL) << "Could not find the data object "<< m_Pixel_clcontainer.name() << " !" << endreq; + return StatusCode::RECOVERABLE; + } + + ATH_MSG_DEBUG( "Data object " << m_Pixel_clcontainer.name() << " found" ); // loop over Pixel clusterCollections PixelClusterContainer::const_iterator colNext = m_Pixel_clcontainer->begin(); @@ -302,7 +340,7 @@ StatusCode SiTrackerSpacePointFinder::execute() } else { - sc= m_SpacePointContainerPixel->addCollection( spacepointCollection, + StatusCode sc= m_SpacePointContainerPixel->addCollection( spacepointCollection, spacepointCollection->identifyHash() ); if (sc.isFailure()) { @@ -325,13 +363,14 @@ StatusCode SiTrackerSpacePointFinder::execute() { ATH_MSG_DEBUG( m_spacepointoverlapCollection->size() <<" overlap space points registered." ); } +/* StatusCode sc = evtStore()->record(m_spacepointoverlapCollection, m_spacePointsOverlapName, false); if (sc.isFailure()) { ATH_MSG_ERROR( "Failed to register overlap space points" ); return StatusCode::RECOVERABLE; } - +*/ return StatusCode::SUCCESS; } @@ -340,7 +379,7 @@ StatusCode SiTrackerSpacePointFinder::finalize() { ATH_MSG_INFO( "SiTrackerSpacePointFinder::finalize()" ); ATH_MSG_INFO( m_numberOfEvents << " events processed" ); - +/* if (m_selectPixels) { m_SpacePointContainerPixel->cleanup(); @@ -352,7 +391,7 @@ StatusCode SiTrackerSpacePointFinder::finalize() m_SpacePointContainer_SCT->cleanup(); m_SpacePointContainer_SCT->release(); } - +*/ delete m_properties; return StatusCode::SUCCESS; @@ -471,7 +510,7 @@ checkForSCT_Points(const SCT_ClusterCollection* clusters1, m_SiSpacePointMakerTool->fillSCT_SpacePointCollection(clusters1, clusters2, min, max, m_allClusters, m_vertex, m_manager, spacepointCollection); } else { - m_SiSpacePointMakerTool->fillSCT_SpacePointEtaOverlapCollection(clusters1, clusters2, min, max, m_allClusters, m_vertex, m_manager, m_spacepointoverlapCollection); + m_SiSpacePointMakerTool->fillSCT_SpacePointEtaOverlapCollection(clusters1, clusters2, min, max, m_allClusters, m_vertex, m_manager, m_spacepointoverlapCollection.ptr()); } } //-------------------------------------------------------------------------- @@ -489,16 +528,10 @@ checkForSCT_Points(const SCT_ClusterCollection* clusters1, if (it==m_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, m_spacepointoverlapCollection); + m_SiSpacePointMakerTool->fillSCT_SpacePointPhiOverlapCollection(clusters1, clusters2, min1, max1, min2, max2, m_allClusters, m_vertex, m_manager, m_spacepointoverlapCollection.ptr()); } -//-------------------------------------------------------------------------- -std::string SiTrackerSpacePointFinder::intString(int n) -{ - return std::to_string(n); -} -//-------------------------------------------------------------------------- } -- GitLab