From a604ddce71eb028b72b037149194720852f1a846 Mon Sep 17 00:00:00 2001 From: christos <christos@cern.ch> Date: Thu, 22 Oct 2020 01:45:34 +0200 Subject: [PATCH] Surfaces: Make staticType a constexpr variable . A bit easier to use rahter than a static constexpr function. Avoid a bit of code duplication --- .../TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h | 6 +++--- .../TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc | 9 +-------- .../TrkSurfaces/TrkSurfaces/CylinderSurface.h | 8 ++++---- .../TrkSurfaces/TrkSurfaces/CylinderSurface.icc | 8 +------- .../TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h | 6 ++---- .../TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc | 9 +-------- .../TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h | 7 +++---- .../TrkSurfaces/TrkSurfaces/PerigeeSurface.icc | 9 +-------- .../TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h | 7 ++++--- .../TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc | 9 +-------- .../TrkSurfaces/TrkSurfaces/StraightLineSurface.h | 3 +-- .../TrkSurfaces/TrkSurfaces/StraightLineSurface.icc | 9 +-------- .../TrkParametersBase/CurvilinearParametersT.icc | 2 +- .../TrkParametersBase/TrkParametersBase/ParametersT.icc | 8 +++----- 14 files changed, 27 insertions(+), 73 deletions(-) diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h index 23d711589b18..3e4098af45c6 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h @@ -46,6 +46,9 @@ class ConeSurface : public Surface { public: + /** The surface type static constexpr */ + static constexpr SurfaceType staticType = Surface::Cone; + /**Default Constructor*/ ConeSurface(); @@ -142,9 +145,6 @@ public: /** Return the surface type */ virtual SurfaceType type() const override final; - /** Return the surface type static constexpr */ - static constexpr SurfaceType staticType() ; - /** Return the measurement frame - this is needed for alignment, in particular for StraightLine and Perigee Surface - the default implementation is the the RotationMatrix3D of the transform */ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc index 442da77d2e7b..140bd00c5314 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc @@ -8,14 +8,7 @@ namespace Trk { inline Surface::SurfaceType ConeSurface::type() const { - return Surface::Cone; -} - -/** Return the surface type static constexpr */ -inline constexpr Surface::SurfaceType -ConeSurface::staticType() -{ - return Surface::Cone; + return ConeSurface::staticType; } /** Use the Surface as a ParametersBase constructor, from local parameters - diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.h index 8ddd5bb0d8af..7ddd1d4d2738 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.h @@ -51,6 +51,9 @@ class CylinderSurface : public Surface { public: + /** The surface type static constexpr */ + static constexpr SurfaceType staticType = Surface::Cylinder; + /**Default Constructor*/ CylinderSurface(); @@ -167,10 +170,7 @@ public: /** Return the surface type */ virtual SurfaceType type() const override final; - /** Return the surface type static constexpr */ - static constexpr SurfaceType staticType() ; - - /** Returns a global reference point: + /** Returns a global reference point: For the Cylinder this is @f$ (R*cos(\phi), R*sin(\phi),0)*transform() @f$ Where @f$ \phi @f$ denotes the averagePhi() of the cylinderBounds. */ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.icc index 70d71810390f..66eeb816c8a4 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.icc @@ -8,15 +8,9 @@ namespace Trk { inline Surface::SurfaceType CylinderSurface::type() const { - return Surface::Cylinder; + return CylinderSurface::staticType; } -/** Return the surface type static constexpr */ -inline constexpr Surface::SurfaceType -CylinderSurface::staticType() -{ - return Surface::Cylinder; -} /** Use the Surface as a ParametersBase constructor, from local parameters - diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h index 42d683b16de5..4c42a89311fb 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h @@ -48,6 +48,7 @@ class DiscSurface : public Surface { public: + static constexpr SurfaceType staticType = Surface::Disc; /**Default Constructor*/ DiscSurface(); @@ -162,10 +163,7 @@ public: /** Return the surface type */ virtual SurfaceType type() const override final; - /** Return the surface type */ - static constexpr SurfaceType staticType(); - - /** Returns a global reference point: + /** Returns a global reference point: For the Disc this is @f$ (R*cos(\phi), R*sin(\phi),0)*transform() @f$ Where @f$ r, \phi @f$ denote the r(), averagePhi() of the Bounds. */ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc index 8449298c6fd6..b20240a2e5e5 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc @@ -7,14 +7,7 @@ namespace Trk { inline Surface::SurfaceType DiscSurface::type() const { - return Surface::Disc; -} - -/** Return the surface type static constexpr */ -inline constexpr Surface::SurfaceType -DiscSurface::staticType() -{ - return Surface::Disc; + return DiscSurface::staticType; } /* Use the Surface as a ParametersBase constructor, from local parameters - diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h index 0c74ae462332..89463c2c30f5 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h @@ -40,6 +40,9 @@ class PerigeeSurface : public Surface { public: + /** The surface type static constexpr */ + static constexpr SurfaceType staticType = Surface::Perigee; + /**Default Constructor - needed for persistency*/ PerigeeSurface(); @@ -128,10 +131,6 @@ public: /** Return the surface type */ virtual SurfaceType type() const override final; - /** Return the surface type static constexpr */ - static constexpr SurfaceType staticType() ; - - /**Return method for transfromation, overwrites the transform() form base * class*/ virtual const Amg::Transform3D& transform() const override; diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc index 1ec96a413a9d..b77ef81b8d5b 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc @@ -85,14 +85,7 @@ PerigeeSurface::createParameters(const Amg::Vector3D& position, inline Surface::SurfaceType PerigeeSurface::type() const { - return Surface::Perigee; -} - -/** Return the surface type static constexpr */ -inline constexpr Surface::SurfaceType -PerigeeSurface::staticType() -{ - return Surface::Perigee; + return PerigeeSurface::staticType; } inline PerigeeSurface* diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h index 917177da3dfa..2bd1c76c467b 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h @@ -59,6 +59,10 @@ class ParametersT; class PlaneSurface : public Surface { public: + + /** The surface type static constexpr */ + static constexpr SurfaceType staticType = Surface::Plane; + /** Default Constructor - needed for persistency*/ PlaneSurface(); @@ -143,9 +147,6 @@ public: /** Return the surface type */ virtual SurfaceType type() const override final; - /** Return the surface type static constexpr */ - static constexpr SurfaceType staticType() ; - /** Use the Surface as a ParametersBase constructor, from local parameters - * charged */ virtual ParametersT<5, Charged, PlaneSurface>* createTrackParameters( diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc index 5c6de97bc6c2..c93b4bfd6593 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc @@ -7,14 +7,7 @@ namespace Trk { inline Surface::SurfaceType PlaneSurface::type() const { - return Surface::Plane; -} - -/** Return the surface type static constexpr */ -inline constexpr Surface::SurfaceType -PlaneSurface::staticType() -{ - return Surface::Plane; + return PlaneSurface::staticType; } /** Use the Surface as a ParametersBase constructor, from local parameters - diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h index 84ccf2153c68..1a24cf335da3 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h @@ -45,6 +45,7 @@ class StraightLineSurface : public Surface { public: + static constexpr SurfaceType staticType = Surface::Line; /**Default Constructor - needed for persistency*/ StraightLineSurface(); @@ -145,8 +146,6 @@ public: /** Return the surface type */ virtual SurfaceType type() const override final; - /** Return the surface type static constexpr */ - static constexpr SurfaceType staticType() ; /** Specified for StraightLineSurface: LocalToGlobal method without dynamic * memory allocation */ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc index 7887b07f5c41..a148487d6f5e 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc @@ -7,14 +7,7 @@ namespace Trk { inline Surface::SurfaceType StraightLineSurface::type() const { - return Surface::Line; -} - -/** Return the surface type static constexpr */ -inline constexpr Surface::SurfaceType -StraightLineSurface::staticType() -{ - return Surface::Line; + return StraightLineSurface::staticType; } /** Use the Surface as a ParametersBase constructor, from local parameters - diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc index ca7c8b4c262b..5fb9b4e780b5 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc @@ -254,7 +254,7 @@ template<int DIM, class T, class S> int CurvilinearParametersT<DIM, T, S>::surfaceType() const { - return S::staticType(); + return S::staticType; } diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc index a67a3a5665aa..cc6c53d923b1 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc @@ -260,7 +260,7 @@ template<int DIM, class T, class S> int ParametersT<DIM, T, S>::surfaceType() const { - return S::staticType(); + return S::staticType; } // return the measurementFrame @@ -288,10 +288,8 @@ ParametersT<DIM, T, S>::updateParametersHelper(const AmgVector(DIM) & (updatedParameters[Trk::theta] != m_parameters[Trk::theta]) || (updatedParameters[qOverP] != m_parameters[qOverP]); - if constexpr ( - S::staticType() == Trk::Surface::Line || - S::staticType() == Trk::Surface::Perigee - ) { + if constexpr (S::staticType == Trk::Surface::Line || + S::staticType == Trk::Surface::Perigee) { updatePosition |= updateMomentum; } -- GitLab