diff --git a/Tracking/TrkDetDescr/TrkDistortedSurfaces/TrkDistortedSurfaces/SaggedLineSurface.h b/Tracking/TrkDetDescr/TrkDistortedSurfaces/TrkDistortedSurfaces/SaggedLineSurface.h index 677a0e81e96f3207630103ee066aa4a5a72d9ca8..71aeec42f815750baecb5b1788a4925557f1e90d 100755 --- a/Tracking/TrkDetDescr/TrkDistortedSurfaces/TrkDistortedSurfaces/SaggedLineSurface.h +++ b/Tracking/TrkDetDescr/TrkDistortedSurfaces/TrkDistortedSurfaces/SaggedLineSurface.h @@ -15,7 +15,7 @@ #include "TrkDistortedSurfaces/DistortedSurface.h" #include "TrkDistortedSurfaces/LineSaggingDescriptor.h" #include "TrkSurfaces/StraightLineSurface.h" - +#include "CxxUtils/CachedValue.h" namespace Trk { class TrkDetElementBase; @@ -71,10 +71,8 @@ namespace Trk { protected: - LineSaggingDescriptor* m_saggingDescriptor; //!< the distortion descriptor - CxxUtils::CachedUniquePtrT<Amg::Vector3D> m_lineDirection; //!< nominal end position - + CxxUtils::CachedValue<Amg::Vector3D> m_lineDirection; //!< nominal end position }; /** provide the Surface interface */ diff --git a/Tracking/TrkDetDescr/TrkDistortedSurfaces/src/SaggedLineSurface.cxx b/Tracking/TrkDetDescr/TrkDistortedSurfaces/src/SaggedLineSurface.cxx index 4c27f2cf5e95e527871092fcce3c52e729ccae18..90d4c5e05e3ca90b9541efe1fef49dbc5bca9806 100755 --- a/Tracking/TrkDetDescr/TrkDistortedSurfaces/src/SaggedLineSurface.cxx +++ b/Tracking/TrkDetDescr/TrkDistortedSurfaces/src/SaggedLineSurface.cxx @@ -10,7 +10,7 @@ #include "TrkDistortedSurfaces/SaggedLineSurface.h" #include "TrkSurfaces/CylinderBounds.h" -// From Dan Levin: MDT +// From Dan Levin: MDT // linear density of wire: lambda=wireLinearDensity=19.3 [gm/cm^3] * PI* //(25 *10^-4 )^2 [cm^2] = 378.954 microgram/cm // From Dan Levin: MDT @@ -20,31 +20,31 @@ Trk::SaggedLineSurface::SaggedLineSurface() : Trk::DistortedSurface(), Trk::StraightLineSurface(), m_saggingDescriptor(nullptr), - m_lineDirection(nullptr) + m_lineDirection{} {} Trk::SaggedLineSurface::SaggedLineSurface(Amg::Transform3D* htrans, - double radius, - double halez, + double radius, + double halez, Trk::LineSaggingDescriptor* lsd) : Trk::DistortedSurface(), Trk::StraightLineSurface(htrans, radius, halez), m_saggingDescriptor(lsd), - m_lineDirection(nullptr) + m_lineDirection{} {} Trk::SaggedLineSurface::SaggedLineSurface(std::unique_ptr<Amg::Transform3D> htrans) : Trk::DistortedSurface(), Trk::StraightLineSurface(std::move(htrans)), m_saggingDescriptor(nullptr), - m_lineDirection(nullptr) + m_lineDirection{} {} Trk::SaggedLineSurface::SaggedLineSurface(const Trk::TrkDetElementBase& detelement, const Identifier& id) : Trk::DistortedSurface(), Trk::StraightLineSurface(detelement,id), m_saggingDescriptor(), - m_lineDirection(nullptr) + m_lineDirection{} {} Trk::SaggedLineSurface::SaggedLineSurface(const Trk::TrkDetElementBase& detelement, const Identifier& id, @@ -52,7 +52,7 @@ Trk::SaggedLineSurface::SaggedLineSurface(const Trk::TrkDetElementBase& deteleme Trk::DistortedSurface(), Trk::StraightLineSurface(detelement,id), m_saggingDescriptor(), - m_lineDirection(nullptr) + m_lineDirection{} { m_saggingDescriptor = new Trk::LineSaggingDescriptor(wireLength, wireTension, linearDensity); } @@ -61,7 +61,7 @@ Trk::SaggedLineSurface::SaggedLineSurface(const Trk::SaggedLineSurface& sls) : Trk::DistortedSurface(sls), Trk::StraightLineSurface(sls), m_saggingDescriptor(new Trk::LineSaggingDescriptor(sls.distortionDescriptor())), - m_lineDirection(nullptr) + m_lineDirection{} {} Trk::SaggedLineSurface::~SaggedLineSurface() @@ -69,13 +69,13 @@ Trk::SaggedLineSurface::~SaggedLineSurface() delete m_saggingDescriptor; } -Trk::SaggedLineSurface& Trk::SaggedLineSurface::operator=(const Trk::SaggedLineSurface& sls) +Trk::SaggedLineSurface& Trk::SaggedLineSurface::operator=(const Trk::SaggedLineSurface& sls) { if (this != &sls ) { Trk::DistortedSurface::operator=(sls); Trk::StraightLineSurface::operator=(sls); delete m_saggingDescriptor; - m_lineDirection.store(nullptr); + m_lineDirection=sls.m_lineDirection; m_saggingDescriptor=new Trk::LineSaggingDescriptor(sls.distortionDescriptor()); } return *this; @@ -85,14 +85,14 @@ Trk::StraightLineSurface* Trk::SaggedLineSurface::correctedSurface(const Amg::Ve { // prepare Amg::Transform3D* newHepTransform =nullptr; - if (!m_lineDirection) { - m_lineDirection.set(std::make_unique<Amg::Vector3D>(transform().rotation().col(3))); + if (!m_lineDirection.isValid()) { + m_lineDirection.set(transform().rotation().col(3)); } if (m_saggingDescriptor){ // first get the hep transform from the distortion descriptor newHepTransform = m_saggingDescriptor->correctedSurfaceTransform(lp, center(), - *m_lineDirection); + *(m_lineDirection.ptr())); } else if (Trk::Surface::associatedDetectorElement()) { // get the sagging descriptor and the endpoints from GeoModel // m_saggingDescriptor diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h index 89463c2c30f5436edf232458c0c85c65016ae081..81aae6c7e1b21ae854a346b4f119aeb019d8c8ad 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h @@ -17,6 +17,7 @@ // Amg #include "EventPrimitives/EventPrimitives.h" #include "GeoPrimitives/GeoPrimitives.h" +#include "CxxUtils/CachedValue.h" class MsgStream; @@ -267,7 +268,7 @@ public: protected: //!< data members //!< cache of the line direction (speeds up) - CxxUtils::CachedUniquePtrT<Amg::Vector3D> m_lineDirection; + CxxUtils::CachedValue<Amg::Vector3D> m_lineDirection; static const NoBounds s_perigeeBounds; }; diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc index b77ef81b8d5bbe1bffdbbc534c2bb064f9b76d77..5a4d693d99c109bb4a6c903db57e1e2fe670c677 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc @@ -181,12 +181,16 @@ PerigeeSurface::straightLineIntersection(const Amg::Vector3D& pos, inline const Amg::Vector3D& PerigeeSurface::lineDirection() const { - if (m_lineDirection) - return (*m_lineDirection); - if (!m_lineDirection && Surface::m_transform) { - m_lineDirection.set( - std::make_unique<Amg::Vector3D>(transform().rotation().col(2))); - return (*m_lineDirection); + if (m_lineDirection.isValid()) { + return *(m_lineDirection.ptr()); + } + + if (Surface::m_transform) { + + if (!m_lineDirection.isValid()) { + m_lineDirection.set(transform().rotation().col(2)); + return *(m_lineDirection.ptr()); + } } return Trk::s_zAxis; } diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h index 1a24cf335da35d14b8c78c708298464bd120dbdf..9c7548b1a19cca5668bff56cd8b3cc254d301b53 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h @@ -18,6 +18,7 @@ // Amg #include "EventPrimitives/EventPrimitives.h" #include "GeoPrimitives/GeoPrimitives.h" +#include "CxxUtils/CachedValue.h" class Identifier; class MsgStream; @@ -269,7 +270,7 @@ protected: //!< data members template<class SURFACE, class BOUNDS_CNV> friend class ::BoundSurfaceCnv_p1; //!< cache of the line direction (speeds up) - CxxUtils::CachedUniquePtrT<Amg::Vector3D> m_lineDirection; + CxxUtils::CachedValue<Amg::Vector3D> m_lineDirection; //!< bounds (shared) SharedObject<const CylinderBounds> m_bounds; //!< NoBounds as return object when no bounds are declared diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc index a148487d6f5e55c7a33d01e8107ef0e0e07ace59..3eefcf7f203a3615fb7e54d974992398e847dc79 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc @@ -130,11 +130,10 @@ StraightLineSurface::insideBoundsCheck(const Amg::Vector2D& locpos, inline const Amg::Vector3D& StraightLineSurface::lineDirection() const { - if (!m_lineDirection) { - m_lineDirection.set( - std::make_unique<Amg::Vector3D>(transform().rotation().col(2))); + if (!m_lineDirection.isValid()) { + m_lineDirection.set(transform().rotation().col(2)); } - return (*m_lineDirection); + return *(m_lineDirection.ptr()); } /** the pathCorrection for derived classes with thickness */ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/src/PerigeeSurface.cxx b/Tracking/TrkDetDescr/TrkSurfaces/src/PerigeeSurface.cxx index 04634e9a14b47f8a0837f951a8e8b74bfb2b45d3..081f668a88660d0e4fe21dd15e5f4e696f57f166 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/src/PerigeeSurface.cxx +++ b/Tracking/TrkDetDescr/TrkSurfaces/src/PerigeeSurface.cxx @@ -20,12 +20,12 @@ const Trk::NoBounds Trk::PerigeeSurface::s_perigeeBounds; Trk::PerigeeSurface::PerigeeSurface() : Surface() - , m_lineDirection(nullptr) + , m_lineDirection{} {} Trk::PerigeeSurface::PerigeeSurface(const Amg::Vector3D& gp) : Surface() - , m_lineDirection(nullptr) + , m_lineDirection{} { Surface::m_center = std::make_unique<const Amg::Vector3D>(gp); Surface::m_transform = std::make_unique<Amg::Transform3D>(); @@ -34,19 +34,19 @@ Trk::PerigeeSurface::PerigeeSurface(const Amg::Vector3D& gp) Trk::PerigeeSurface::PerigeeSurface(Amg::Transform3D* tTransform) : Surface() - , m_lineDirection(nullptr) + , m_lineDirection{} { Surface::m_transform=std::unique_ptr<Amg::Transform3D>(tTransform); } Trk::PerigeeSurface::PerigeeSurface(std::unique_ptr<Amg::Transform3D> tTransform) : Surface(std::move(tTransform)) - , m_lineDirection(nullptr) + , m_lineDirection{} {} Trk::PerigeeSurface::PerigeeSurface(const PerigeeSurface& pesf) : Surface(pesf) - , m_lineDirection(nullptr) + , m_lineDirection{} { if (pesf.m_center) Surface::m_center = std::make_unique<const Amg::Vector3D>(*pesf.m_center); @@ -56,7 +56,7 @@ Trk::PerigeeSurface::PerigeeSurface(const PerigeeSurface& pesf) Trk::PerigeeSurface::PerigeeSurface(const PerigeeSurface& pesf, const Amg::Transform3D& shift) : Surface() - , m_lineDirection(nullptr) + , m_lineDirection{} { if (pesf.m_center) Surface::m_center = std::make_unique<const Amg::Vector3D>(shift * (*pesf.m_center)); @@ -71,7 +71,7 @@ Trk::PerigeeSurface::operator=(const Trk::PerigeeSurface& pesf) { if (this != &pesf) { Trk::Surface::operator=(pesf); - m_lineDirection.store(std::make_unique<Amg::Vector3D>(lineDirection())); + m_lineDirection=pesf.m_lineDirection; } return *this; } diff --git a/Tracking/TrkDetDescr/TrkSurfaces/src/StraightLineSurface.cxx b/Tracking/TrkDetDescr/TrkSurfaces/src/StraightLineSurface.cxx index a6107d958f2aabb2ae81023ec2b4f6794ae38520..6918f043c70bec22ba0efd286b7dfbae6670de73 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/src/StraightLineSurface.cxx +++ b/Tracking/TrkDetDescr/TrkSurfaces/src/StraightLineSurface.cxx @@ -22,49 +22,49 @@ const Trk::NoBounds Trk::StraightLineSurface::s_boundless; // default constructor Trk::StraightLineSurface::StraightLineSurface() : Surface() - , m_lineDirection(nullptr) + , m_lineDirection{} , m_bounds() {} // constructors by arguments: boundless surface Trk::StraightLineSurface::StraightLineSurface(Amg::Transform3D* htrans) : Surface(htrans) - , m_lineDirection(nullptr) + , m_lineDirection{} , m_bounds() {} // constructors by arguments: boundless surface Trk::StraightLineSurface::StraightLineSurface(std::unique_ptr<Amg::Transform3D> htrans) : Surface(std::move(htrans)) - , m_lineDirection(nullptr) + , m_lineDirection{} , m_bounds() {} // constructors by arguments Trk::StraightLineSurface::StraightLineSurface(Amg::Transform3D* htrans, double radius, double halez) : Surface(htrans) - , m_lineDirection(nullptr) + , m_lineDirection{} , m_bounds(new Trk::CylinderBounds(radius, halez)) {} // dummy implementation Trk::StraightLineSurface::StraightLineSurface(const Trk::TrkDetElementBase& detelement, const Identifier& id) : Surface(detelement, id) - , m_lineDirection(nullptr) + , m_lineDirection{} , m_bounds() {} // copy constructor Trk::StraightLineSurface::StraightLineSurface(const Trk::StraightLineSurface& slsf) : Surface(slsf) - , m_lineDirection(nullptr) + , m_lineDirection{} , m_bounds(slsf.m_bounds) {} // copy constructor with shift Trk::StraightLineSurface::StraightLineSurface(const StraightLineSurface& csf, const Amg::Transform3D& transf) : Surface(csf, transf) - , m_lineDirection(nullptr) + , m_lineDirection{} , m_bounds(csf.m_bounds) {} @@ -74,8 +74,8 @@ Trk::StraightLineSurface& Trk::StraightLineSurface::operator=(const Trk::StraightLineSurface& slsf) { if (this != &slsf) { - m_lineDirection.store(nullptr); Trk::Surface::operator=(slsf); + m_lineDirection=slsf.m_lineDirection; m_bounds = slsf.m_bounds; } return *this; @@ -245,9 +245,9 @@ Trk::StraightLineSurface::straightLineDistanceEstimate(const Amg::Vector3D& pos, double dist = dxyz.dot(dxyz) - Lz * Lz; dist = (dist > Rm * Rm) ? sqrt(dist) - Rm : 0.; double dL = fabs(Lz) - Lzm; - if (dL > 0.) + if (dL > 0.){ dist = sqrt(dist * dist + dL * dL); - + } return Trk::DistanceSolution(1, dist, false, s); }