diff --git a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SCT_ClusterOnTrack.h b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SCT_ClusterOnTrack.h index edd10789db39ad9beeec60fe2ce0d3859c14856a..4952e71948ff0e383e29c71c5c6f74b8d68f1911 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SCT_ClusterOnTrack.h +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SCT_ClusterOnTrack.h @@ -109,17 +109,12 @@ namespace InDet{ /** Destructor */ virtual ~SCT_ClusterOnTrack() = default; - /** returns global position (gathered through Surface constraint) - - fullfills Trk::MeasurementBase interface - Overload of the method in parent class */ - virtual const Amg::Vector3D& globalPosition() const override final; - /** Pseudo-constructor */ virtual SCT_ClusterOnTrack* clone() const override; - /** returns the surface for the local to global transformation - - fullfills the Trk::MeasurementBase interface - */ + /** returns the surface for the local to global transformation + - fullfills the Trk::MeasurementBase interface + */ virtual const Trk::Surface& associatedSurface() const override; virtual bool rioType(Trk::RIO_OnTrackType::Type type) const override final diff --git a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SiClusterOnTrack.h b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SiClusterOnTrack.h index f6aa3bc12b3192cb88aaed8e409a737d1ac9a866..eefb8627ebaf3b209e350a25e80f17942770629e 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SiClusterOnTrack.h +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/InDetRIO_OnTrack/SiClusterOnTrack.h @@ -10,7 +10,6 @@ #define TRKRIO_ONTRACK_SICLUSTERONTRACK_H #include "TrkRIO_OnTrack/RIO_OnTrack.h" -#include "CxxUtils/CachedUniquePtr.h" #include "Identifier/IdentifierHash.h" class SiClusterOnTrackCnv_p1; @@ -105,7 +104,7 @@ namespace InDet { /** The IdentifierHash - probably not used*/ IdentifierHash m_idDE; /** The global position */ - CxxUtils::CachedUniquePtr<const Amg::Vector3D> m_globalPosition; + 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 156d7287743689f2bd1a5d6c150902ccb581c4d3..567c65026556c16c20126bce06bdbd7a604539e2 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/PixelClusterOnTrack.cxx +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/PixelClusterOnTrack.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -30,6 +30,9 @@ InDet::PixelClusterOnTrack::PixelClusterOnTrack( m_detEl( RIO->detectorElement() ) { m_rio.setElement(RIO); + + // Set global position + m_globalPosition = associatedSurface().localToGlobalPos(localParameters()); } // Constructor with parameters @@ -68,8 +71,10 @@ InDet::PixelClusterOnTrack::PixelClusterOnTrack m_hasClusterAmbiguity (hasClusterAmbiguity), m_isFake (isFake), m_energyLoss (energyLoss), - m_detEl (nullptr) + m_detEl ((*RIO)->detectorElement()) { + // Set global position + m_globalPosition = associatedSurface().localToGlobalPos(localParameters()); } diff --git a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SCT_ClusterOnTrack.cxx b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SCT_ClusterOnTrack.cxx index 02f8b5a93b7af7fd00b7a1c3d8dccf82103f10e6..d534d01251a2ec6262381053e0bde2f84ac5e626 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SCT_ClusterOnTrack.cxx +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SCT_ClusterOnTrack.cxx @@ -23,9 +23,13 @@ InDet::SCT_ClusterOnTrack::SCT_ClusterOnTrack(const InDet::SCT_Cluster* RIO, bool isbroad) : SiClusterOnTrack(locpars, locerr, idDE, RIO->identify(),isbroad) //call base class constructor { - m_detEl=nullptr; + m_detEl=RIO->detectorElement(); m_positionAlongStrip=std::numeric_limits<double>::quiet_NaN(); m_rio.setElement(RIO); + + // Set global position + Amg::Vector2D lpos(localParameters().get(Trk::locX), m_positionAlongStrip); + m_globalPosition = detectorElement()->surface(identify()).localToGlobalPos(lpos); } // Constructor with parameters @@ -60,17 +64,21 @@ InDet::SCT_ClusterOnTrack::SCT_ClusterOnTrack( const ElementLinkToIDCSCT_Cluster idDE, id, isbroad), - m_rio (RIO), - m_detEl (nullptr), + m_rio(RIO), + m_detEl((*RIO)->detectorElement()), m_positionAlongStrip (positionAlongStrip) -{} +{ + // Set global position + Amg::Vector2D lpos(localParameters().get(Trk::locX), m_positionAlongStrip); + m_globalPosition = detectorElement()->surface(identify()).localToGlobalPos(lpos); +} // Default constructor: InDet::SCT_ClusterOnTrack::SCT_ClusterOnTrack(): SiClusterOnTrack(), m_rio(), - m_detEl(0), + m_detEl(nullptr), m_positionAlongStrip(std::numeric_limits<double>::quiet_NaN()) {} @@ -85,20 +93,6 @@ void InDet::SCT_ClusterOnTrack::setValues(const Trk::TrkDetElementBase* detEl, c m_detEl = dynamic_cast< const InDetDD::SiDetectorElement* >(detEl); } -const Amg::Vector3D& InDet::SCT_ClusterOnTrack::globalPosition() const - { - //checking whether the globalposition is available - if (not m_globalPosition) - { - - // calculate global position from the position of the strip and the position along the strip - Amg::Vector2D lpos( localParameters().get(Trk::locX), m_positionAlongStrip ); - m_globalPosition.set(std::unique_ptr<const Amg::Vector3D>(detectorElement()->surface( identify() ).localToGlobal( lpos ))); - } - - return (*m_globalPosition); -} - MsgStream& InDet::SCT_ClusterOnTrack::dump( MsgStream& sl ) const { SiClusterOnTrack::dump(sl);// use dump(...) from SiClusterOnTrack diff --git a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SiClusterOnTrack.cxx b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SiClusterOnTrack.cxx index 4ede0a611f7feab865fbccde592fe1d6d88129cb..9c87958e5fa6babe658e32668bc00d5af02fc08e 100755 --- a/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SiClusterOnTrack.cxx +++ b/InnerDetector/InDetRecEvent/InDetRIO_OnTrack/src/SiClusterOnTrack.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -26,7 +26,7 @@ InDet::SiClusterOnTrack::SiClusterOnTrack( const Trk::LocalParameters& locpars, bool isbroad) : RIO_OnTrack(locpars, locerr, id), //call base class constructor m_idDE(idDE), - m_globalPosition{}, + m_globalPosition(), // should be set in constructor of derived class m_isbroad(isbroad) {} @@ -40,7 +40,7 @@ InDet::SiClusterOnTrack::SiClusterOnTrack( const Trk::LocalParameters& locpars, : RIO_OnTrack(locpars, locerr, id), //call base class constructor m_idDE(idDE), - m_globalPosition(std::make_unique<Amg::Vector3D>(globalPosition)), + m_globalPosition(globalPosition), m_isbroad(isbroad) {} @@ -54,7 +54,7 @@ InDet::SiClusterOnTrack::~SiClusterOnTrack() InDet::SiClusterOnTrack::SiClusterOnTrack(): Trk::RIO_OnTrack(), m_idDE(), - m_globalPosition{}, + m_globalPosition(), // should be set in constructor of derived class m_isbroad(false) {} @@ -63,24 +63,16 @@ InDet::SiClusterOnTrack::SiClusterOnTrack( const SiClusterOnTrack& rot) : RIO_OnTrack(rot), m_idDE(rot.m_idDE), - m_globalPosition{}, + m_globalPosition(rot.m_globalPosition), m_isbroad(rot.m_isbroad) -{ - if (rot.m_globalPosition) { - m_globalPosition.set(std::make_unique<const Amg::Vector3D>(*(rot.m_globalPosition))); - } -} +{} // assignment operator: InDet::SiClusterOnTrack& InDet::SiClusterOnTrack::operator=( const SiClusterOnTrack& rot){ if ( &rot != this) { Trk::RIO_OnTrack::operator=(rot); m_idDE = rot.m_idDE; - if (rot.m_globalPosition) { - m_globalPosition.set(std::make_unique<const Amg::Vector3D>(*(rot.m_globalPosition))); - } else if (m_globalPosition) { - m_globalPosition.release().reset(); - } + m_globalPosition = rot.m_globalPosition; m_isbroad = rot.m_isbroad; } return *this; @@ -91,10 +83,7 @@ InDet::SiClusterOnTrack& InDet::SiClusterOnTrack::operator=( const SiClusterOnTr const Amg::Vector3D& InDet::SiClusterOnTrack::globalPosition() const { - if (not m_globalPosition) { - m_globalPosition.set(std::unique_ptr<const Amg::Vector3D>(associatedSurface().localToGlobal(localParameters()))); - } - return (*m_globalPosition); + return m_globalPosition; } MsgStream& InDet::SiClusterOnTrack::dump( MsgStream& sl ) const @@ -104,15 +93,9 @@ MsgStream& InDet::SiClusterOnTrack::dump( MsgStream& sl ) const Trk::RIO_OnTrack::dump(sl); sl << "Global position (x,y,z) = ("; - this->globalPosition(); - if (m_globalPosition) - { - sl <<this->globalPosition().x()<<", " - <<this->globalPosition().y()<<", " - <<this->globalPosition().z()<<")"<<endmsg; - } else { - sl<<"NULL!), "<<endmsg; - } + sl <<this->globalPosition().x()<<", " + <<this->globalPosition().y()<<", " + <<this->globalPosition().z()<<")"<<endmsg; sl<<"}"<<endmsg; return sl; } @@ -124,16 +107,9 @@ std::ostream& InDet::SiClusterOnTrack::dump( std::ostream& sl ) const Trk::RIO_OnTrack::dump(sl); sl << "Global position (x,y,z) = ("; - this->globalPosition(); - if (m_globalPosition) - { - sl <<this->globalPosition().x()<<", " - <<this->globalPosition().y()<<", " - <<this->globalPosition().z()<<")"<<std::endl; - } else { - sl<<"NULL!), "<<std::endl; - } - + sl <<this->globalPosition().x()<<", " + <<this->globalPosition().y()<<", " + <<this->globalPosition().z()<<")"<<std::endl; sl<<"}"<<std::endl; return sl; }