From f77f6b3e7aeaf7c8e20f22e33bc8ca53dd651515 Mon Sep 17 00:00:00 2001 From: Paul Gessinger <paul.gessinger@cern.ch> Date: Wed, 20 Mar 2019 16:55:17 +0100 Subject: [PATCH] Remove variant data --- .../Acts/EventData/TrackStateSorters.hpp | 4 - .../Acts/Fitter/GainMatrixSmoother.hpp | 1 - Core/include/Acts/Fitter/KalmanFitter.hpp | 1 - Core/include/Acts/Layers/CylinderLayer.hpp | 13 - Core/include/Acts/Layers/DiscLayer.hpp | 11 - Core/include/Acts/Layers/NavigationLayer.hpp | 11 - Core/include/Acts/Surfaces/ConeBounds.hpp | 10 - Core/include/Acts/Surfaces/ConeSurface.hpp | 11 - Core/include/Acts/Surfaces/CylinderBounds.hpp | 11 - .../include/Acts/Surfaces/CylinderSurface.hpp | 11 - Core/include/Acts/Surfaces/DiamondBounds.hpp | 11 - Core/include/Acts/Surfaces/DiscSurface.hpp | 11 - .../Acts/Surfaces/DiscTrapezoidalBounds.hpp | 11 - Core/include/Acts/Surfaces/EllipseBounds.hpp | 11 - Core/include/Acts/Surfaces/InfiniteBounds.hpp | 6 - Core/include/Acts/Surfaces/LineBounds.hpp | 11 - Core/include/Acts/Surfaces/LineSurface.hpp | 11 - Core/include/Acts/Surfaces/PerigeeSurface.hpp | 11 - Core/include/Acts/Surfaces/PlanarBounds.hpp | 7 - Core/include/Acts/Surfaces/PlaneSurface.hpp | 11 - Core/include/Acts/Surfaces/RadialBounds.hpp | 11 - .../include/Acts/Surfaces/RectangleBounds.hpp | 11 - Core/include/Acts/Surfaces/StrawSurface.hpp | 11 - Core/include/Acts/Surfaces/Surface.hpp | 6 - Core/include/Acts/Surfaces/SurfaceArray.hpp | 28 - Core/include/Acts/Surfaces/SurfaceBounds.hpp | 6 - .../include/Acts/Surfaces/TrapezoidBounds.hpp | 11 - Core/include/Acts/Surfaces/TriangleBounds.hpp | 11 - .../Acts/Utilities/InstanceFactory.hpp | 137 ---- Core/include/Acts/Utilities/VariantData.hpp | 622 ------------------ .../include/Acts/Utilities/VariantDataFwd.hpp | 31 - Core/src/Layers/CylinderLayer.cpp | 128 ---- Core/src/Layers/DiscLayer.cpp | 108 --- Core/src/Layers/NavigationLayer.cpp | 38 -- Core/src/Surfaces/ConeBounds.cpp | 33 - Core/src/Surfaces/ConeSurface.cpp | 40 -- Core/src/Surfaces/CylinderBounds.cpp | 33 - Core/src/Surfaces/CylinderSurface.cpp | 41 -- Core/src/Surfaces/DiamondBounds.cpp | 41 -- Core/src/Surfaces/DiscSurface.cpp | 48 -- Core/src/Surfaces/DiscTrapezoidalBounds.cpp | 36 - Core/src/Surfaces/EllipseBounds.cpp | 42 -- Core/src/Surfaces/InfinitieBounds.cpp | 8 - Core/src/Surfaces/LineBounds.cpp | 32 - Core/src/Surfaces/LineSurface.cpp | 47 -- Core/src/Surfaces/PerigeeSurface.cpp | 40 -- Core/src/Surfaces/PlaneSurface.cpp | 54 -- Core/src/Surfaces/RadialBounds.cpp | 31 - Core/src/Surfaces/RectangleBounds.cpp | 28 - Core/src/Surfaces/StrawSurface.cpp | 47 -- Core/src/Surfaces/SurfaceArray.cpp | 297 --------- Core/src/Surfaces/TrapezoidBounds.cpp | 35 - Core/src/Surfaces/TriangleBounds.cpp | 44 -- Core/src/Tools/LayerCreator.cpp | 1 + Plugins/Json/CMakeLists.txt | 7 +- .../include/Acts/Plugins/Json/FromJson.hpp | 22 - Plugins/Json/src/FromJson.cpp | 50 -- .../Tests/CommonHelpers/LineSurfaceStub.hpp | 6 - Tests/Core/EventData/BoundParametersTests.cpp | 1 - Tests/Core/Layers/ConeLayerTests.cpp | 1 + Tests/Core/Layers/CylinderLayerTests.cpp | 45 +- Tests/Core/Layers/DiscLayerTests.cpp | 39 +- Tests/Core/Layers/NavigationLayerTests.cpp | 30 - Tests/Core/Surfaces/ConeBoundsTests.cpp | 28 - Tests/Core/Surfaces/ConeSurfaceTests.cpp | 29 - Tests/Core/Surfaces/CylinderBoundsTests.cpp | 25 - Tests/Core/Surfaces/CylinderSurfaceTests.cpp | 29 - Tests/Core/Surfaces/DiamondBoundsTests.cpp | 27 - Tests/Core/Surfaces/DiscSurfaceTests.cpp | 51 -- .../Surfaces/DiscTrapezoidalBoundsTests.cpp | 30 - Tests/Core/Surfaces/EllipseBoundsTests.cpp | 30 - Tests/Core/Surfaces/LineSurfaceTests.cpp | 24 - Tests/Core/Surfaces/PerigeeSurfaceTests.cpp | 20 - Tests/Core/Surfaces/PlaneSurfaceTests.cpp | 41 -- Tests/Core/Surfaces/RadialBoundsTests.cpp | 25 - Tests/Core/Surfaces/RectangleBoundsTests.cpp | 19 +- Tests/Core/Surfaces/StrawSurfaceTests.cpp | 23 - Tests/Core/Surfaces/SurfaceArrayTests.cpp | 134 ---- Tests/Core/Surfaces/SurfaceBoundsTests.cpp | 7 - Tests/Core/Surfaces/SurfaceStub.hpp | 11 - Tests/Core/Surfaces/TrapezoidBoundsTests.cpp | 24 - Tests/Core/Surfaces/TriangleBoundsTests.cpp | 32 - Tests/Core/Tools/LayerCreatorTests.cpp | 102 --- Tests/Plugins/Json/CMakeLists.txt | 5 - Tests/Plugins/Json/FromJsonTests.cpp | 209 ------ 85 files changed, 8 insertions(+), 3440 deletions(-) delete mode 100644 Core/include/Acts/Utilities/InstanceFactory.hpp delete mode 100644 Core/include/Acts/Utilities/VariantData.hpp delete mode 100644 Core/include/Acts/Utilities/VariantDataFwd.hpp delete mode 100644 Plugins/Json/include/Acts/Plugins/Json/FromJson.hpp delete mode 100644 Plugins/Json/src/FromJson.cpp diff --git a/Core/include/Acts/EventData/TrackStateSorters.hpp b/Core/include/Acts/EventData/TrackStateSorters.hpp index d38ca3383..d07bd7491 100644 --- a/Core/include/Acts/EventData/TrackStateSorters.hpp +++ b/Core/include/Acts/EventData/TrackStateSorters.hpp @@ -8,11 +8,7 @@ #pragma once -// boost include(s) -#include <boost/variant.hpp> - namespace Acts { -/// @brief Sorter for boost_variant struct TrackStatePathLengthSorter { public: diff --git a/Core/include/Acts/Fitter/GainMatrixSmoother.hpp b/Core/include/Acts/Fitter/GainMatrixSmoother.hpp index 54d09501e..d353c404c 100644 --- a/Core/include/Acts/Fitter/GainMatrixSmoother.hpp +++ b/Core/include/Acts/Fitter/GainMatrixSmoother.hpp @@ -9,7 +9,6 @@ #pragma once #include <boost/range/adaptors.hpp> -#include <boost/variant.hpp> #include <memory> #include "Acts/EventData/TrackParameters.hpp" diff --git a/Core/include/Acts/Fitter/KalmanFitter.hpp b/Core/include/Acts/Fitter/KalmanFitter.hpp index 3ef90f0c6..a3197ab17 100644 --- a/Core/include/Acts/Fitter/KalmanFitter.hpp +++ b/Core/include/Acts/Fitter/KalmanFitter.hpp @@ -8,7 +8,6 @@ #pragma once -#include <boost/variant.hpp> #include <memory> #include "Acts/EventData/Measurement.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" diff --git a/Core/include/Acts/Layers/CylinderLayer.hpp b/Core/include/Acts/Layers/CylinderLayer.hpp index 93f520a6b..210525f87 100644 --- a/Core/include/Acts/Layers/CylinderLayer.hpp +++ b/Core/include/Acts/Layers/CylinderLayer.hpp @@ -15,9 +15,7 @@ #include "Acts/Layers/Layer.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/InstanceFactory.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" #include "Acts/Volumes/CylinderVolumeBounds.hpp" namespace Acts { @@ -64,12 +62,6 @@ public: laytyp)); } - /// Factory for shared Layer pointer, that accepts @c variant_data - /// @param vardata The data to build from - /// @return The return object is a shared poiter to the layer. - static MutableLayerPtr - create(const variant_data& vardata); - /// Copy constructor - deleted CylinderLayer(const CylinderLayer& cla) = delete; @@ -93,11 +85,6 @@ public: CylinderSurface& surfaceRepresentation() override; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: /// build approach surfaces */ void diff --git a/Core/include/Acts/Layers/DiscLayer.hpp b/Core/include/Acts/Layers/DiscLayer.hpp index f26f2e4da..14be927b7 100644 --- a/Core/include/Acts/Layers/DiscLayer.hpp +++ b/Core/include/Acts/Layers/DiscLayer.hpp @@ -16,7 +16,6 @@ #include "Acts/Layers/Layer.hpp" #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -60,11 +59,6 @@ public: laytyp)); } - /// Factory for shared Layer pointer, that accepts @c variant_data - /// @param vardata The data to build from - static MutableLayerPtr - create(const variant_data& vardata); - /// Default Constructor DiscLayer() = delete; @@ -88,11 +82,6 @@ public: DiscSurface& surfaceRepresentation() override; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: /// build approach surfaces void diff --git a/Core/include/Acts/Layers/NavigationLayer.hpp b/Core/include/Acts/Layers/NavigationLayer.hpp index 7406f5132..2cae030a2 100644 --- a/Core/include/Acts/Layers/NavigationLayer.hpp +++ b/Core/include/Acts/Layers/NavigationLayer.hpp @@ -16,7 +16,6 @@ #include "Acts/Utilities/BinnedArray.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/GeometryStatics.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -43,11 +42,6 @@ public: return LayerPtr(new NavigationLayer(std::move(sRepresentation), thickness)); } - /// Factory for shared Layer pointer, that accepts @c variant_data - /// @param vardata The data to build from - static LayerPtr - create(const variant_data& vardata); - /// Destructor ~NavigationLayer() override; @@ -101,11 +95,6 @@ public: bool resolveMaterial, bool resolvePassive) const final; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const; - protected: /// Private Constructor /// - this is called by the creat(args*) method diff --git a/Core/include/Acts/Surfaces/ConeBounds.hpp b/Core/include/Acts/Surfaces/ConeBounds.hpp index f095e029c..fdcfd3b52 100644 --- a/Core/include/Acts/Surfaces/ConeBounds.hpp +++ b/Core/include/Acts/Surfaces/ConeBounds.hpp @@ -15,7 +15,6 @@ #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -70,10 +69,6 @@ public: double halfphi = M_PI, double avphi = 0.); - /// Constructor which accepts @c variant_data - /// @param vardata The data to build from - ConeBounds(const variant_data& vardata); - ~ConeBounds() override; ConeBounds* @@ -150,11 +145,6 @@ public: double halfPhiSector() const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: double m_alpha, m_tanAlpha; double m_zMin, m_zMax; diff --git a/Core/include/Acts/Surfaces/ConeSurface.hpp b/Core/include/Acts/Surfaces/ConeSurface.hpp index 61f3ac5be..b111a062f 100644 --- a/Core/include/Acts/Surfaces/ConeSurface.hpp +++ b/Core/include/Acts/Surfaces/ConeSurface.hpp @@ -16,7 +16,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/ParameterDefinitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" namespace Acts { @@ -79,11 +78,6 @@ protected: /// @param transf is the additional transfrom applied after copying ConeSurface(const ConeSurface& other, const Transform3D& transf); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - ConeSurface(const variant_data& vardata); - public: /// Destructor - defaulted ~ConeSurface() override = default; @@ -234,11 +228,6 @@ public: std::string name() const override; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - protected: std::shared_ptr<const ConeBounds> m_bounds; ///< bounds (shared) diff --git a/Core/include/Acts/Surfaces/CylinderBounds.hpp b/Core/include/Acts/Surfaces/CylinderBounds.hpp index 4fe75f269..bc129e5ac 100644 --- a/Core/include/Acts/Surfaces/CylinderBounds.hpp +++ b/Core/include/Acts/Surfaces/CylinderBounds.hpp @@ -15,7 +15,6 @@ #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" #include "Acts/Utilities/detail/periodic.hpp" namespace Acts { @@ -76,11 +75,6 @@ public: double halfPhi, double halfZ); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - CylinderBounds(const variant_data& vardata); - ~CylinderBounds() override; CylinderBounds* @@ -138,11 +132,6 @@ public: double halflengthZ() const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: /// the bound radius, average, half phi and half Z double m_radius, m_avgPhi, m_halfPhi, m_halfZ; diff --git a/Core/include/Acts/Surfaces/CylinderSurface.hpp b/Core/include/Acts/Surfaces/CylinderSurface.hpp index b59f55d87..c6477e9c5 100644 --- a/Core/include/Acts/Surfaces/CylinderSurface.hpp +++ b/Core/include/Acts/Surfaces/CylinderSurface.hpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/GeometryStatics.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" namespace Acts { @@ -93,11 +92,6 @@ protected: /// cylinder CylinderSurface(const CylinderSurface& other, const Transform3D& transf); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - CylinderSurface(const variant_data& vardata); - public: /// Destructor - defaulted ~CylinderSurface() override = default; @@ -250,11 +244,6 @@ public: std::string name() const override; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - /// Return a PolyhedronRepresentation for this object /// @param l0div Number of divisions along l0 (phi) /// @param l1div Number of divisions along l1 (z) diff --git a/Core/include/Acts/Surfaces/DiamondBounds.hpp b/Core/include/Acts/Surfaces/DiamondBounds.hpp index 50183c995..c05252a17 100644 --- a/Core/include/Acts/Surfaces/DiamondBounds.hpp +++ b/Core/include/Acts/Surfaces/DiamondBounds.hpp @@ -17,7 +17,6 @@ #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/ParameterDefinitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -52,11 +51,6 @@ public: double haley1, double haley2); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - DiamondBounds(const variant_data& vardata); - ~DiamondBounds() override; DiamondBounds* @@ -122,11 +116,6 @@ public: double halflengthY2() const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: double m_minHalfX, m_medHalfX, m_maxHalfX; double m_minY, m_maxY; diff --git a/Core/include/Acts/Surfaces/DiscSurface.hpp b/Core/include/Acts/Surfaces/DiscSurface.hpp index ccb074772..34b4c4d95 100644 --- a/Core/include/Acts/Surfaces/DiscSurface.hpp +++ b/Core/include/Acts/Surfaces/DiscSurface.hpp @@ -18,7 +18,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/GeometryStatics.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -111,11 +110,6 @@ protected: /// @param transf The additional transform applied to the surface DiscSurface(const DiscSurface& other, const Transform3D& transf); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - DiscSurface(const variant_data& vardata); - public: /// Destructor - defaulted ~DiscSurface() override = default; @@ -310,11 +304,6 @@ public: virtual PolyhedronRepresentation polyhedronRepresentation(size_t l0div = 10, size_t l1div = 1) const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - protected: std::shared_ptr<const DiscBounds> m_bounds; ///< bounds (shared) private: diff --git a/Core/include/Acts/Surfaces/DiscTrapezoidalBounds.hpp b/Core/include/Acts/Surfaces/DiscTrapezoidalBounds.hpp index 9c6bf5a4a..c47932a38 100644 --- a/Core/include/Acts/Surfaces/DiscTrapezoidalBounds.hpp +++ b/Core/include/Acts/Surfaces/DiscTrapezoidalBounds.hpp @@ -16,7 +16,6 @@ #include "Acts/Surfaces/DiscBounds.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/ParameterDefinitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -60,11 +59,6 @@ public: double avephi = M_PI_2, double stereo = 0.); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - DiscTrapezoidalBounds(const variant_data& vardata); - ~DiscTrapezoidalBounds() override; DiscTrapezoidalBounds* @@ -130,11 +124,6 @@ public: double halflengthY() const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: double m_rMin, m_rMax, m_minHalfX, m_maxHalfX, m_avgPhi; double m_stereo; // TODO 2017-04-09 msmk: what is this good for? diff --git a/Core/include/Acts/Surfaces/EllipseBounds.hpp b/Core/include/Acts/Surfaces/EllipseBounds.hpp index 3abe6b830..8f4b05c91 100644 --- a/Core/include/Acts/Surfaces/EllipseBounds.hpp +++ b/Core/include/Acts/Surfaces/EllipseBounds.hpp @@ -17,7 +17,6 @@ #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -61,11 +60,6 @@ public: double averagePhi = 0., double halfPhi = M_PI); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - EllipseBounds(const variant_data& vardata); - ~EllipseBounds() override; EllipseBounds* @@ -130,11 +124,6 @@ public: double halfPhiSector() const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: double m_rMinX, m_rMinY, m_rMaxX, m_rMaxY, m_avgPhi, m_halfPhi; RectangleBounds m_boundingBox; diff --git a/Core/include/Acts/Surfaces/InfiniteBounds.hpp b/Core/include/Acts/Surfaces/InfiniteBounds.hpp index c9c204517..d1991511b 100644 --- a/Core/include/Acts/Surfaces/InfiniteBounds.hpp +++ b/Core/include/Acts/Surfaces/InfiniteBounds.hpp @@ -13,7 +13,6 @@ #pragma once #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -73,11 +72,6 @@ public: os << "Acts::InfiniteBounds ... boundless surface" << std::endl; return os; } - - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; }; static const InfiniteBounds s_noBounds{}; diff --git a/Core/include/Acts/Surfaces/LineBounds.hpp b/Core/include/Acts/Surfaces/LineBounds.hpp index 392f24d3c..bdc5e626d 100644 --- a/Core/include/Acts/Surfaces/LineBounds.hpp +++ b/Core/include/Acts/Surfaces/LineBounds.hpp @@ -13,7 +13,6 @@ #pragma once #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -35,11 +34,6 @@ public: /// @param halez is the half length in z, defualt = 0. LineBounds(double radius = 0., double halez = 0.); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - LineBounds(const variant_data& vardata); - ~LineBounds() override; LineBounds* @@ -84,11 +78,6 @@ public: std::ostream& dump(std::ostream& sl) const final; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: double m_radius, m_halfZ; }; diff --git a/Core/include/Acts/Surfaces/LineSurface.hpp b/Core/include/Acts/Surfaces/LineSurface.hpp index 63cd7c948..ce9e9b7a6 100644 --- a/Core/include/Acts/Surfaces/LineSurface.hpp +++ b/Core/include/Acts/Surfaces/LineSurface.hpp @@ -16,7 +16,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/GeometryStatics.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -73,11 +72,6 @@ protected: /// @param transf The additional transform applied after copying LineSurface(const LineSurface& other, const Transform3D& transf); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - LineSurface(const variant_data& vardata); - public: /// Destructor - defaulted ~LineSurface() override = default; @@ -265,11 +259,6 @@ public: std::string name() const override; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - protected: std::shared_ptr<const LineBounds> m_bounds; ///< bounds (shared) diff --git a/Core/include/Acts/Surfaces/PerigeeSurface.hpp b/Core/include/Acts/Surfaces/PerigeeSurface.hpp index 40ad5063e..3f8ff7fb2 100644 --- a/Core/include/Acts/Surfaces/PerigeeSurface.hpp +++ b/Core/include/Acts/Surfaces/PerigeeSurface.hpp @@ -15,7 +15,6 @@ #include "Acts/Surfaces/LineSurface.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/GeometryStatics.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -54,11 +53,6 @@ protected: /// @param shift is the transformed applied after copying PerigeeSurface(const PerigeeSurface& other, const Transform3D& shift); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - PerigeeSurface(const variant_data& vardata); - public: /// Destructor - defaulted ~PerigeeSurface() override = default; @@ -90,11 +84,6 @@ public: std::ostream& dump(std::ostream& sl) const final; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: /// Clone method. Uses the copy constructor a new position can optionally be /// given a shift. diff --git a/Core/include/Acts/Surfaces/PlanarBounds.hpp b/Core/include/Acts/Surfaces/PlanarBounds.hpp index 0b2aaf269..ef8fc9de3 100644 --- a/Core/include/Acts/Surfaces/PlanarBounds.hpp +++ b/Core/include/Acts/Surfaces/PlanarBounds.hpp @@ -14,8 +14,6 @@ #include <vector> #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" - namespace Acts { /// forward declare rectangle bounds as boundary box @@ -37,11 +35,6 @@ public: // Bounding box parameters virtual const RectangleBounds& boundingBox() const = 0; - - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override = 0; }; } // namespace \ No newline at end of file diff --git a/Core/include/Acts/Surfaces/PlaneSurface.hpp b/Core/include/Acts/Surfaces/PlaneSurface.hpp index 2d239f384..34301e9ef 100644 --- a/Core/include/Acts/Surfaces/PlaneSurface.hpp +++ b/Core/include/Acts/Surfaces/PlaneSurface.hpp @@ -18,7 +18,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/GeometryStatics.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -73,11 +72,6 @@ protected: PlaneSurface(std::shared_ptr<const Transform3D> htrans, std::shared_ptr<const PlanarBounds> pbounds = nullptr); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - PlaneSurface(const variant_data& vardata); - public: /// Destructor - defaulted ~PlaneSurface() override = default; @@ -202,11 +196,6 @@ public: std::string name() const override; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - protected: /// the bounds of this surface std::shared_ptr<const PlanarBounds> m_bounds; diff --git a/Core/include/Acts/Surfaces/RadialBounds.hpp b/Core/include/Acts/Surfaces/RadialBounds.hpp index 13be29b46..905ccaaf6 100644 --- a/Core/include/Acts/Surfaces/RadialBounds.hpp +++ b/Core/include/Acts/Surfaces/RadialBounds.hpp @@ -16,7 +16,6 @@ #include "Acts/Surfaces/DiscBounds.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/ParameterDefinitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" #include "Acts/Utilities/detail/periodic.hpp" namespace Acts { @@ -60,11 +59,6 @@ public: /// coverage) RadialBounds(double minrad, double maxrad, double avephi, double hphisec); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - RadialBounds(const variant_data& vardata); - ~RadialBounds() override; RadialBounds* @@ -116,11 +110,6 @@ public: double halfPhiSector() const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: double m_rMin, m_rMax, m_avgPhi, m_halfPhi; diff --git a/Core/include/Acts/Surfaces/RectangleBounds.hpp b/Core/include/Acts/Surfaces/RectangleBounds.hpp index 83e240617..9cd296b8d 100644 --- a/Core/include/Acts/Surfaces/RectangleBounds.hpp +++ b/Core/include/Acts/Surfaces/RectangleBounds.hpp @@ -13,7 +13,6 @@ #pragma once #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -41,11 +40,6 @@ public: /// @param haley halflength in Y RectangleBounds(double halex, double haley); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - RectangleBounds(const variant_data& vardata); - ~RectangleBounds() override; RectangleBounds* @@ -96,11 +90,6 @@ public: double halflengthY() const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: double m_halfX, m_halfY; }; diff --git a/Core/include/Acts/Surfaces/StrawSurface.hpp b/Core/include/Acts/Surfaces/StrawSurface.hpp index 6ad8427f3..a0536c5ad 100644 --- a/Core/include/Acts/Surfaces/StrawSurface.hpp +++ b/Core/include/Acts/Surfaces/StrawSurface.hpp @@ -15,7 +15,6 @@ #include "Acts/Surfaces/LineBounds.hpp" #include "Acts/Surfaces/LineSurface.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -75,11 +74,6 @@ protected: /// @param htrans is the additional transform applied after copying StrawSurface(const StrawSurface& other, const Transform3D& htrans); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - StrawSurface(const variant_data& vardata); - public: /// Destructor - defaulted ~StrawSurface() override = default; @@ -105,11 +99,6 @@ public: std::string name() const final; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - /// Return a PolyhedronRepresentation for this object /// @param l0div Number of divisions along l0 (phi) /// @param l1div Number of divisions along l1 (z) diff --git a/Core/include/Acts/Surfaces/Surface.hpp b/Core/include/Acts/Surfaces/Surface.hpp index 56debf2fc..922a37c76 100644 --- a/Core/include/Acts/Surfaces/Surface.hpp +++ b/Core/include/Acts/Surfaces/Surface.hpp @@ -21,7 +21,6 @@ #include "Acts/Utilities/GeometryObject.hpp" #include "Acts/Utilities/GeometryStatics.hpp" #include "Acts/Utilities/Intersection.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" #include <memory> @@ -481,11 +480,6 @@ public: virtual std::string name() const = 0; - /// Produce a @c variant_data representation of this object - /// @return The representation - virtual variant_data - toVariantData() const = 0; - protected: /// Transform3D definition that positions /// (translation, rotation) the surface in global space diff --git a/Core/include/Acts/Surfaces/SurfaceArray.hpp b/Core/include/Acts/Surfaces/SurfaceArray.hpp index a2bf1d2b0..3bf03a7cd 100644 --- a/Core/include/Acts/Surfaces/SurfaceArray.hpp +++ b/Core/include/Acts/Surfaces/SurfaceArray.hpp @@ -14,8 +14,6 @@ #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/IAxis.hpp" -#include "Acts/Utilities/InstanceFactory.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" #include "Acts/Utilities/detail/Axis.hpp" #include "Acts/Utilities/detail/Grid.hpp" @@ -518,26 +516,6 @@ public: /// @param srf The one and only surface SurfaceArray(std::shared_ptr<const Surface> srf); - /// Constructor which accepts @c variant_data - /// - /// @param data the @c variant_data to build from - /// @param g2l Callable that converts from global to local - /// @param l2g Callable that converts from local to global - /// @param transform Optional additional transform for this SurfaceArray - /// @note the transform parameter is ONLY used for the serialization. - /// Apart from that, the SGL handles the transforms. - SurfaceArray(const variant_data& data_, - const std::function<Vector2D(const Vector3D&)>& g2l, - const std::function<Vector3D(const Vector2D&)>& l2g, - std::shared_ptr<const Transform3D> transform = nullptr); - - // This is here so that overload resolution can figure out - // we need std::array<double, 1> as local parameters here. - SurfaceArray(const variant_data& data_, - std::function<std::array<double, 1>(const Vector3D&)> g2l, - std::function<Vector3D(const std::array<double, 1>&)> l2g, - std::shared_ptr<const Transform3D> transform = nullptr); - /// @brief Get all surfaces in bin given by position. /// @param pos the lookup position /// @return reference to @c SurfaceVector contained in bin at that position @@ -650,9 +628,6 @@ public: std::ostream& dump(std::ostream& sl) const; - variant_data - toVariantData() const; - private: std::unique_ptr<ISurfaceGridLookup> p_gridLookup; // this vector makes sure we have shared ownership over the surfaces @@ -663,9 +638,6 @@ private: // this is only used to keep info on transform applied // by l2g and g2l std::shared_ptr<const Transform3D> m_transform; - - variant_data - surfaceGridLookupToVariantData(const ISurfaceGridLookup& sgl) const; }; } // namespace Acts \ No newline at end of file diff --git a/Core/include/Acts/Surfaces/SurfaceBounds.hpp b/Core/include/Acts/Surfaces/SurfaceBounds.hpp index 8697543f8..2f8f07bb3 100644 --- a/Core/include/Acts/Surfaces/SurfaceBounds.hpp +++ b/Core/include/Acts/Surfaces/SurfaceBounds.hpp @@ -15,7 +15,6 @@ #include "Acts/Surfaces/BoundaryCheck.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -95,11 +94,6 @@ public: /// @param sl is the outstream in which the string dump is done virtual std::ostream& dump(std::ostream& os) const = 0; - - /// Produce a @c variant_data representation of this object - /// @return The representation - virtual variant_data - toVariantData() const = 0; }; inline bool diff --git a/Core/include/Acts/Surfaces/TrapezoidBounds.hpp b/Core/include/Acts/Surfaces/TrapezoidBounds.hpp index 7ce367621..62767ae83 100644 --- a/Core/include/Acts/Surfaces/TrapezoidBounds.hpp +++ b/Core/include/Acts/Surfaces/TrapezoidBounds.hpp @@ -17,7 +17,6 @@ #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/ParameterDefinitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -50,11 +49,6 @@ public: /// @param haley half length Y - defined at x=0 TrapezoidBounds(double minhalex, double maxhalex, double haley); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - TrapezoidBounds(const variant_data& vardata); - ~TrapezoidBounds() override; TrapezoidBounds* @@ -149,11 +143,6 @@ public: double halflengthY() const; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: double m_minHalfX; double m_maxHalfX; diff --git a/Core/include/Acts/Surfaces/TriangleBounds.hpp b/Core/include/Acts/Surfaces/TriangleBounds.hpp index d1580435d..93258f596 100644 --- a/Core/include/Acts/Surfaces/TriangleBounds.hpp +++ b/Core/include/Acts/Surfaces/TriangleBounds.hpp @@ -18,7 +18,6 @@ #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/ParameterDefinitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" namespace Acts { @@ -49,11 +48,6 @@ public: /// @param vertices is the vector of vertices TriangleBounds(const std::array<Vector2D, 3>& vertices); - /// Constructor which accepts @c variant_data - /// - /// @param vardata the @c variant_data to build from - TriangleBounds(const variant_data& vardata); - ~TriangleBounds() override; TriangleBounds* @@ -95,11 +89,6 @@ public: std::ostream& dump(std::ostream& sl) const final; - /// Produce a @c variant_data representation of this object - /// @return The representation - variant_data - toVariantData() const override; - private: std::array<Vector2D, 3> m_vertices; RectangleBounds m_boundingBox; ///< internal bounding box cache diff --git a/Core/include/Acts/Utilities/InstanceFactory.hpp b/Core/include/Acts/Utilities/InstanceFactory.hpp deleted file mode 100644 index 143cc31a5..000000000 --- a/Core/include/Acts/Utilities/InstanceFactory.hpp +++ /dev/null @@ -1,137 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2018 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once -#include <boost/functional/value_factory.hpp> -#include <map> -#include <memory> -#include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" - -#include "Acts/Surfaces/CylinderBounds.hpp" -#include "Acts/Surfaces/DiamondBounds.hpp" -#include "Acts/Surfaces/DiscBounds.hpp" -#include "Acts/Surfaces/DiscTrapezoidalBounds.hpp" -#include "Acts/Surfaces/EllipseBounds.hpp" -#include "Acts/Surfaces/PlaneSurface.hpp" -#include "Acts/Surfaces/RadialBounds.hpp" -#include "Acts/Surfaces/RectangleBounds.hpp" -#include "Acts/Surfaces/TrapezoidBounds.hpp" -#include "Acts/Surfaces/TriangleBounds.hpp" - -namespace Acts { - -/// Class that creates instances for certain types of objects -/// from @c variant_data input. This is used to avoid duplicating -/// this type of code anywhere we construct from @c variant_data. -class InstanceFactory -{ - // internal typedefs - using SurfaceBoundsPtr = std::shared_ptr<const SurfaceBounds>; - using PlanarBoundsPtr = std::shared_ptr<const PlanarBounds>; - using SurfaceBoundsFactory - = std::function<SurfaceBoundsPtr(const variant_data&)>; - using SurfaceFactory - = std::function<std::shared_ptr<Surface>(const variant_data&)>; - -public: - /// Default constructor. Sets up a map to lambdas which return - /// pointers to the newly constructor instances. - InstanceFactory() - { - // set up map to store factories - m_surfaceBounds["RectangleBounds"] = [](auto const& data) { - return std::make_shared<const RectangleBounds>(data); - }; - m_surfaceBounds["TriangleBounds"] = [](auto const& data) { - return std::make_shared<const TriangleBounds>(data); - }; - m_surfaceBounds["DiamondBounds"] = [](auto const& data) { - return std::make_shared<const DiamondBounds>(data); - }; - m_surfaceBounds["EllipseBounds"] = [](auto const& data) { - return std::make_shared<const EllipseBounds>(data); - }; - m_surfaceBounds["TrapezoidBounds"] = [](auto const& data) { - return std::make_shared<const TrapezoidBounds>(data); - }; - m_surfaceBounds["CylinderBounds"] = [](auto const& data) { - return std::make_shared<const CylinderBounds>(data); - }; - m_surfaceBounds["RadialBounds"] = [](auto const& data) { - return std::make_shared<const RadialBounds>(data); - }; - m_surfaceBounds["DiscTrapezoidalBounds"] = [](auto const& data) { - return std::make_shared<const DiscTrapezoidalBounds>(data); - }; - - m_surfaces["PlaneSurface"] = [](auto const& data) { - return Surface::makeShared<PlaneSurface>(data); - }; - } - - /// Method to produce surface bounds type objects - /// @param cname The class name - /// @param data The @c variant_data to construct from - /// @return Shared pointer to the created surfacebounds - SurfaceBoundsPtr - surfaceBounds(const std::string& cname, const variant_data& data) const - { - throw_assert(m_surfaceBounds.count(cname), - "No factory found for class " + cname); - return m_surfaceBounds.at(cname)(data); - } - - /// Method to produce planar bounds type objects - /// @param cname The class name - /// @param data The @c variant_data to construct from - /// @return Shared pointer to the created planar bounds - PlanarBoundsPtr - planarBounds(const std::string& cname, const variant_data& data) const - { - SurfaceBoundsPtr srfBnd_ptr = surfaceBounds(cname, data); - PlanarBoundsPtr plnBnd_ptr - = std::dynamic_pointer_cast<const PlanarBounds>(srfBnd_ptr); - throw_assert(plnBnd_ptr, - "Conversion to PlanarBounds failed for name " + cname); - return plnBnd_ptr; - } - - /// Method to produce disc bounds type objects - /// @param cname The class name - /// @param data The @c variant_data to construct from - /// @return Shared pointer to the created disc bounds - std::shared_ptr<const DiscBounds> - discBounds(const std::string& cname, const variant_data& data) const - { - SurfaceBoundsPtr srfBnd_ptr = surfaceBounds(cname, data); - std::shared_ptr<const DiscBounds> discBnd_ptr - = std::dynamic_pointer_cast<const DiscBounds>(srfBnd_ptr); - throw_assert(discBnd_ptr, - "Conversion to DiscBounds failed for name " + cname); - return discBnd_ptr; - } - - /// Method to produce surface objects - /// @param cname The class name - /// @param data The @c variant_data to construct from - /// @return Pointer to the created surface - std::shared_ptr<Surface> - surface(const std::string& cname, const variant_data& data) const - { - throw_assert(m_surfaces.count(cname), - "No factory found for class " + cname); - return m_surfaces.at(cname)(data); - } - -private: - std::map<std::string, SurfaceBoundsFactory> m_surfaceBounds; - std::map<std::string, SurfaceFactory> m_surfaces; -}; - -} // namespace Acts \ No newline at end of file diff --git a/Core/include/Acts/Utilities/VariantData.hpp b/Core/include/Acts/Utilities/VariantData.hpp deleted file mode 100644 index dd53bf0d9..000000000 --- a/Core/include/Acts/Utilities/VariantData.hpp +++ /dev/null @@ -1,622 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2018 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once -// This file is a "Hello, world!" in C++ language by GCC for wandbox. -#include <boost/variant.hpp> -#include <iomanip> -#include <iostream> -#include <map> -#include <sstream> -#include <vector> - -#include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/ThrowAssert.hpp" - -namespace Acts { - -/// Forward declarations for the recursive definition to work. -class variant_map; -class variant_vector; - -/// This data type allows construction of a tree-like -/// data structure that contains varying data, in particular -/// int, double, strings, bools, maps and vectors. The latter -/// two can also contain variant_data (this allows trees) -/// The definition here uses boost's recursive_wrapper, because -/// @c variant_map and @c variant_vector have to be defined later on. -using variant_data = boost::variant<int, - double, - std::string, - bool, - boost::recursive_wrapper<variant_map>, - boost::recursive_wrapper<variant_vector>>; - -/// @brief Class which wraps an @c std::map<std::string, variant_data> -/// -/// This class allows tree-like recursive data, and provides some -/// convenience methods to access keys. The key type is always @c std::string -class variant_map -{ -public: - /// Map type used by the class - using map_t = std::map<std::string, variant_data>; - - using iterator = map_t::iterator; - using const_iterator = map_t::const_iterator; - - /// Constructor which takes a @c map_t and wraps it. - /// @param src The source map, empty by default - variant_map(map_t src = {}) : m_map(std::move(src)) {} - - /// Method to get the size of the map. Is forwarded to the - /// contained map - /// @return The size - size_t - size() const - { - return m_map.size(); - } - - /// Subscript operator to elements in the map - /// @param key The key to access - /// @return Value stored here. Note that this is @c variant_data. - variant_data& operator[](const std::string& key) { return m_map[key]; } - - /// Method to count a key. Is forwarded - /// @param key The key to count elements for - /// @return Number of elements found - size_t - count(const std::string& key) const - { - return m_map.count(key); - } - - /// Convenience method to access a key and transform it to a specific - /// type. This will throw an error if the key is not found. - /// @tparam T The type you want - /// @param key The key to look up in the map - template <class T> - T& - get(const std::string& key) - { - if (!m_map.count(key)) { - throw std::out_of_range("variant_map key " + key + " not found"); - } - return boost::get<T>(m_map.at(key)); - } - - /// Convenience method to access a key and transform it to a specific - /// type. This will throw an error if the key is not found. - /// @tparam T The type you want - /// @param key The key to look up in the map - template <class T> - const T& - get(const std::string& key) const - { - if (!m_map.count(key)) { - throw std::out_of_range("variant_map key " + key + " not found"); - } - return boost::get<T>(m_map.at(key)); - } - - /// Direct access to a key in the map, is forwarded - /// @param key The key to look up - /// @return value as @c variant_data - const variant_data& - at(const std::string& key) const - { - return m_map.at(key); - } - - /// Direct access to a key in the map, is forwarded - /// @param key The key to look up - /// @return value as @c variant_data - variant_data& - at(const std::string& key) - { - return m_map.at(key); - } - - /// Returns an iterator for the contained map, pointing to begin - /// @return Iterator pointing at begin - iterator - begin() - { - return m_map.begin(); - } - - /// Returns an iterator for the contained map, pointing to end - /// @return Iterator pointing at end - iterator - end() - { - return m_map.end(); - } - - /// Returns an const iterator for the contained map, pointing to begin - /// @return Const iterator pointing at begin - const_iterator - begin() const - { - return m_map.begin(); - } - - /// Returns an const iterator for the contained map, pointing to end - /// @return Const iterator pointing at end - const_iterator - end() const - { - return m_map.end(); - } - - /// Returns a const iterator for the contained map, pointing to begin - /// @return Const iterator pointing at begin - const_iterator - cbegin() - { - return m_map.cbegin(); - } - - /// Returns a const iterator for the contained map, pointing to end - /// @return Const iterator pointing at end - const_iterator - cend() - { - return m_map.cend(); - } - - /// Returns an const iterator for the contained map, pointing to begin - /// @return Const iterator pointing at begin - const_iterator - cbegin() const - { - return m_map.cbegin(); - } - - /// Returns an const iterator for the contained map, pointing to end - /// @return Const iterator pointing at end - const_iterator - cend() const - { - return m_map.cend(); - } - -private: - map_t m_map; -}; - -/// Class that wraps a vector of @c variant_data items -/// Provides some convenience methods for access. -class variant_vector -{ -public: - /// Vector type used by the class - using vector_t = std::vector<variant_data>; - using iterator = vector_t::iterator; - using const_iterator = vector_t::const_iterator; - - /// Constructor for the class accepting an input vector - /// @param src The source vector to wrap - variant_vector(vector_t src = {}) : m_vector(std::move(src)) {} - - /// Method to get the current size of the wrapped vector - /// @return The size - size_t - size() const - { - return m_vector.size(); - } - - /// Operator to get subscript access to an element. - /// @param idx The index to access - /// @return The value at idx, as @c variant_data - variant_data& operator[](size_t idx) { return m_vector[idx]; } - - /// Method to access value at an index - /// @param idx The index to access - /// @return The value at idx, as @c variant_data - variant_data& - at(size_t idx) - { - return m_vector.at(idx); - } - - /// Method to access value at an index - /// @param idx The index to access - /// @return The value at @c idx, as @c variant_data - const variant_data& - at(size_t idx) const - { - return m_vector.at(idx); - } - - /// Method to append an element to the vector - /// @param data @c variant_data value to add - void - push_back(const variant_data& data) - { - m_vector.push_back(data); - } - - /// Convenience method which accesses a value and converts it - /// to a provided type - /// @tparam T the type you want - /// @param idx The index to access - /// @return The value at @c idx as @c T - template <class T> - T& - get(const size_t& idx) - { - return boost::get<T>(m_vector.at(idx)); - } - - /// Convenience method which accesses a value and converts it - /// to a provided type - /// @tparam T the type you want - /// @param idx The index to access - /// @return The value at @c idx as @c T - template <class T> - const T& - get(const size_t& idx) const - { - return boost::get<T>(m_vector.at(idx)); - } - - /// Returns an iterator for the contained vector, pointing to begin - /// @return Iterator pointing at begin - iterator - begin() - { - return m_vector.begin(); - } - - /// Returns an iterator for the contained vector, pointing to end - /// @return Iterator pointing at end - iterator - end() - { - return m_vector.end(); - } - - /// Returns an const iterator for the contained vector, pointing to begin - /// @return Const iterator pointing at begin - const_iterator - begin() const - { - return m_vector.begin(); - } - - /// Returns an const iterator for the contained vector, pointing to end - /// @return Const iterator pointing at end - const_iterator - end() const - { - return m_vector.end(); - } - - /// Returns an const iterator for the contained vector, pointing to begin - /// @return Const iterator pointing at begin - const_iterator - cbegin() - { - return m_vector.cbegin(); - } - - /// Returns an const iterator for the contained vector, pointing to end - /// @return Const iterator pointing at end - const_iterator - cend() - { - return m_vector.cend(); - } - - /// Returns an const iterator for the contained vector, pointing to begin - /// @return Const iterator pointing at begin - const_iterator - cbegin() const - { - return m_vector.cbegin(); - } - - /// Returns an const iterator for the contained vector, pointing to end - /// @return Const iterator pointing at end - const_iterator - cend() const - { - return m_vector.cend(); - } - -private: - vector_t m_vector; -}; - -/// This class implements a @c boost::static_vistor -/// which can turn a @c variant_data tree into a json string -class variant_json_visitor : public boost::static_visitor<> -{ -public: - /// Constructor for the visitor. - /// @param pretty Whether the output is indented. - variant_json_visitor(bool pretty = false) - : m_json_str(std::stringstream()), m_pretty(pretty) - { - m_json_str << std::fixed << std::setprecision(30); - } - - /// Visitor operator overload - /// @param b The bool - void - operator()(const bool& b) - { - if (b) { - m_json_str << "true"; - } else { - m_json_str << "false"; - } - } - - /// Visitor operator overload - /// @param i The int - void - operator()(const int& i) - { - m_json_str << i; - } - - /// Visitor operator overload - /// @param d The double - void - operator()(const double& d) - { - m_json_str << d; - } - - /// Visitor operator overload - /// @param str The string - void - operator()(const std::string& str) - { - m_json_str << "\"" << str << "\""; - } - - /// Visitor operator overload - /// @param map The map - void - operator()(const variant_map& map) - { - m_json_str << "{"; - if (m_pretty) { - m_json_str << std::endl; - } - - size_t i = 0; - m_depth += 1; - for (const auto& entry : map) { - indent(); - m_json_str << "\"" << entry.first << "\": "; - boost::apply_visitor(*this, entry.second); - - if (i < map.size() - 1) { - m_json_str << ", "; - if (m_pretty) { - m_json_str << std::endl; - } - } - ++i; - } - m_depth -= 1; - - if (m_pretty) { - m_json_str << std::endl; - } - indent(); - m_json_str << "}"; - } - - /// Visitor operator overload - /// @param vec The vector - void - operator()(const variant_vector& vec) - { - m_json_str << "["; - if (m_pretty) { - m_json_str << std::endl; - } - size_t i = 0; - m_depth += 1; - for (const auto& entry : vec) { - indent(); - boost::apply_visitor(*this, entry); - if (i < vec.size() - 1) { - m_json_str << ", "; - if (m_pretty) { - m_json_str << std::endl; - } - } - ++i; - } - - m_depth -= 1; - if (m_pretty) { - m_json_str << std::endl; - } - indent(); - m_json_str << "]"; - } - - /// Method to get the resulting json string - /// @return The json string - std::string - str() const - { - return m_json_str.str(); - } - -private: - std::stringstream m_json_str; - bool m_pretty; - size_t m_depth = 0; - - void - indent() - { - if (m_pretty) { - for (size_t d = 0; d < m_depth; d++) { - m_json_str << " "; - } - } - } -}; - -/// Function to apply the @c variant_json_visitor to a @c variant_data -/// instance. This turns the input into a json string and returns it. -/// @param data The input data to serialize -/// @param pretty Whether to indent the output -/// @return JSON string representation of the variant_data -inline std::string -to_json(const variant_data& data, bool pretty = false) -{ - variant_json_visitor jv(pretty); - boost::apply_visitor(jv, data); - return jv.str(); -} - -/// Operator overload for the stream operator. This allows -/// printing of @c variant_data instances. -/// @param os The outstream -/// @param data The variant_data -/// @return The stream given as @p os -inline std::ostream& -operator<<(std::ostream& os, const variant_data& data) -{ - os << to_json(data, true) << std::endl; - return os; -} - -/// Function to turn a @c Vector2D into @c variant_data -/// @param vec The vector to transform -/// @return The @c variant_data instance -inline variant_data -to_variant(const Vector2D& vec) -{ - using namespace std::string_literals; - variant_map data; - data["type"] = "Vector2D"s; - data["payload"] = variant_vector({vec[0], vec[1]}); - return data; -} - -/// Function to turn a @c Transform3D into @c variant_data -/// @param trf The transform to convert -/// @return The @c variant_data instance -inline variant_data -to_variant(const Transform3D& trf) -{ - using namespace std::string_literals; - variant_map data; - data["type"] = "Transform3D"s; - - variant_map payload; - variant_vector matrix_data; - for (size_t i = 0; i < 4; i++) { - for (size_t j = 0; j < 4; j++) { - matrix_data.push_back(trf(i, j)); - } - } - payload["data"] = matrix_data; - - data["payload"] = payload; - return data; -} - -/// Function to turn a @c ActsMatrix into @c variant_data -/// @param vec The vector to transform -/// @return The @c variant_data instance -inline variant_data -to_variant(const ActsMatrixD<4, 4>& matrix) -{ - using namespace std::string_literals; - variant_map data; - data["type"] = "Matrix4x4"s; - - variant_map payload; - payload["cols"] = 4; - payload["rows"] = 4; - - variant_vector matrix_data; - for (size_t i = 0; i < 4; i++) { - for (size_t j = 0; j < 4; j++) { - matrix_data.push_back(matrix(i, j)); - } - } - payload["data"] = matrix_data; - - data["payload"] = payload; - - return data; -} - -/// Function to produce an instance of type @c T from @c variant_data. -/// This is the unimplemented base template that is specialized -/// for various types. -/// @tparam T The type you want -/// @param vardata The data -/// @return The converted data as type @c T -template <typename T> -inline T -from_variant(const variant_data& vardata); - -/// Function to produce a @c Transform3D from @c variant_data. -/// @param vardata The input @c variant_data -/// @return The converted @c Transform3D -template <> -inline Transform3D -from_variant<Transform3D>(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Must be variant_map"); - const variant_map& data = boost::get<variant_map>(vardata); - throw_assert(data.get<std::string>("type") == "Transform3D", - "Must be type Transform3D"); - - const variant_map& payload = data.get<variant_map>("payload"); - - const variant_vector& matrix_data = payload.get<variant_vector>("data"); - Transform3D trf; - for (size_t i = 0; i < 4; i++) { - for (size_t j = 0; j < 4; j++) { - - size_t k = i * 4 + j; - double value = matrix_data.get<double>(k); - trf(i, j) = value; - } - } - - return trf; -} - -/// Function to produce a @c Vector2D from @c variant_data. -/// @param vardata The input @c variant_data -/// @return The converted @c Vector2D -template <> -inline Vector2D -from_variant<Vector2D>(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Must be variant_map"); - const variant_map& data = boost::get<variant_map>(vardata); - throw_assert(data.get<std::string>("type") == "Vector2D", - "Must be type Vector2D"); - - const variant_vector& vector_data = data.get<variant_vector>("payload"); - - Vector2D vec{vector_data.get<double>(0), vector_data.get<double>(1)}; - - return vec; -} - -} // namespace Acts diff --git a/Core/include/Acts/Utilities/VariantDataFwd.hpp b/Core/include/Acts/Utilities/VariantDataFwd.hpp deleted file mode 100644 index 47bf823f2..000000000 --- a/Core/include/Acts/Utilities/VariantDataFwd.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2018 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once -#include <boost/variant/recursive_wrapper.hpp> -#include <boost/variant/variant_fwd.hpp> -#include <iostream> -#include <map> -#include <sstream> -#include <string> -#include <vector> - -namespace Acts { - -class variant_map; -class variant_vector; - -/// Forward declaration for the variant data structure -/// using boost's own forward variant. -using variant_data = boost::variant<int, - double, - std::string, - bool, - boost::recursive_wrapper<variant_map>, - boost::recursive_wrapper<variant_vector>>; -} \ No newline at end of file diff --git a/Core/src/Layers/CylinderLayer.cpp b/Core/src/Layers/CylinderLayer.cpp index 2ade170e9..2030575b7 100644 --- a/Core/src/Layers/CylinderLayer.cpp +++ b/Core/src/Layers/CylinderLayer.cpp @@ -16,8 +16,6 @@ #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Utilities/BinUtility.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/InstanceFactory.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Volumes/AbstractVolume.hpp" #include "Acts/Volumes/BoundarySurfaceFace.hpp" #include "Acts/Volumes/CylinderVolumeBounds.hpp" @@ -53,77 +51,6 @@ Acts::CylinderLayer::CylinderLayer( } } -std::shared_ptr<Acts::Layer> -Acts::CylinderLayer::create(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "CylinderLayer", "Type must be CylinderLayer"); - - variant_map payload = data.get<variant_map>("payload"); - - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - - LayerType laytyp; - std::string laytyp_str = payload.get<std::string>("layer_type"); - if (laytyp_str == "active") { - laytyp = active; - } else if (laytyp_str == "passive") { - laytyp = passive; - } else { /*laytyp_str == "navigation"*/ - laytyp = navigation; - } - - double thickness = payload.get<double>("thickness"); - - InstanceFactory factory; - const variant_map& var_bounds = payload.get<variant_map>("cylinder_bounds"); - - auto cbounds = std::dynamic_pointer_cast<const CylinderBounds>( - factory.surfaceBounds(var_bounds.get<std::string>("type"), var_bounds)); - - std::unique_ptr<SurfaceArray> sArray = nullptr; - - // only attempt to reover surface array if present - if (payload.count("surfacearray") != 0u) { - - // get surface array transform - const Transform3D& sa_trf = from_variant<Transform3D>( - payload.get<variant_map>("surfacearray_transform")); - const Transform3D& sa_itrf = sa_trf.inverse(); - - // we need to reproduce the coordinate conversions - double R = cbounds->r(); - double avgPhi = cbounds->averagePhi(); - auto g2l = [sa_trf, avgPhi](const Vector3D& pos) -> Vector2D { - // @TODO: Check if - is right here, might be the other way round - Vector3D loc = sa_trf * pos; - return Vector2D(phi(loc) - avgPhi, loc.z()); - }; - auto l2g = [sa_itrf, R, avgPhi](const Vector2D& loc) -> Vector3D { - return sa_itrf * Vector3D(R * std::cos(loc[0] + avgPhi), - R * std::sin(loc[0] + avgPhi), - loc[1]); - }; - - sArray = std::make_unique<SurfaceArray>( - payload.at("surfacearray"), - g2l, - l2g, - std::make_shared<const Transform3D>(sa_trf)); - } - - // @TODO: Implement ApproachDescriptor serialization - return MutableLayerPtr(new CylinderLayer(trf, - cbounds, - std::move(sArray), - thickness, - nullptr, // std::move(ad), - laytyp)); -} - const Acts::CylinderSurface& Acts::CylinderLayer::surfaceRepresentation() const { @@ -183,58 +110,3 @@ Acts::CylinderLayer::buildApproachDescriptor() } } } - -Acts::variant_data -Acts::CylinderLayer::toVariantData() const -{ - using namespace std::string_literals; - variant_map payload; - - if (m_transform == nullptr) { - payload["transform"] = to_variant(Transform3D::Identity()); - } else { - payload["transform"] = to_variant(*m_transform); - } - - // we need to recover the bounds - const AbstractVolume* absVol = representingVolume(); - std::cout << __PRETTY_FUNCTION__ << " " << __LINE__ << std::endl; - auto cvBounds - = dynamic_cast<const CylinderVolumeBounds*>(&absVol->volumeBounds()); - - std::cout << __PRETTY_FUNCTION__ << " " << __LINE__ << std::endl; - double cylR = cvBounds->innerRadius() + 0.5 * thickness(); - double hlZ = cvBounds->halflengthZ(); - - std::cout << __PRETTY_FUNCTION__ << " " << __LINE__ << std::endl; - CylinderBounds cylBounds(cylR, hlZ); - - std::cout << __PRETTY_FUNCTION__ << " " << __LINE__ << std::endl; - const variant_data bounds = cylBounds.toVariantData(); - std::cout << __PRETTY_FUNCTION__ << " " << __LINE__ << std::endl; - payload["cylinder_bounds"] = bounds; - - payload["thickness"] = thickness(); - - std::cout << __PRETTY_FUNCTION__ << " " << __LINE__ << std::endl; - if (layerType() == active) { - payload["layer_type"] = "active"s; - } else if (layerType() == passive) { - payload["layer_type"] = "passive"s; - } else { /*layerType() == navigation*/ - payload["layer_type"] = "navigation"s; - } - - std::cout << __PRETTY_FUNCTION__ << " " << __LINE__ << std::endl; - - // this lacks localToGlobal and globalToLocal - if (m_surfaceArray) { - payload["surfacearray"] = m_surfaceArray->toVariantData(); - payload["surfacearray_transform"] = to_variant(m_surfaceArray->transform()); - } - - variant_map data; - data["type"] = "CylinderLayer"s; - data["payload"] = payload; - return data; -} diff --git a/Core/src/Layers/DiscLayer.cpp b/Core/src/Layers/DiscLayer.cpp index 8fef0238c..78bf3453a 100644 --- a/Core/src/Layers/DiscLayer.cpp +++ b/Core/src/Layers/DiscLayer.cpp @@ -18,7 +18,6 @@ #include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Utilities/BinUtility.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Volumes/AbstractVolume.hpp" #include "Acts/Volumes/BoundarySurfaceFace.hpp" #include "Acts/Volumes/CylinderVolumeBounds.hpp" @@ -57,73 +56,6 @@ Acts::DiscLayer::DiscLayer(const std::shared_ptr<const Transform3D>& transform, } } -std::shared_ptr<Acts::Layer> -Acts::DiscLayer::create(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "DiscLayer", "Type must be DiscLayer"); - - variant_map payload = data.get<variant_map>("payload"); - - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - - LayerType laytyp; - std::string laytyp_str = payload.get<std::string>("layer_type"); - if (laytyp_str == "active") { - laytyp = active; - } else if (laytyp_str == "passive") { - laytyp = passive; - } else { /*laytyp_str == "navigation"*/ - laytyp = navigation; - } - - double thickness = payload.get<double>("thickness"); - double minR = payload.get<double>("minR"); - double maxR = payload.get<double>("maxR"); - double R = (minR + maxR) / 2.; - - auto rbounds = std::make_shared<const RadialBounds>(minR, maxR); - - std::unique_ptr<SurfaceArray> sArray = nullptr; - - // only attempt to reover surface array if present - if (payload.count("surfacearray") != 0u) { - - // get surface array transform - const Transform3D& sa_trf = from_variant<Transform3D>( - payload.get<variant_map>("surfacearray_transform")); - const Transform3D& sa_itrf = sa_trf.inverse(); - - // we need to reproduce the coordinate conversions - auto g2l = [sa_trf](const Vector3D& pos) -> Vector2D { - // @TODO: Check if - is right here, might be the other way round - Vector3D loc = sa_trf * pos; - return Vector2D(perp(loc), phi(loc)); - }; - auto l2g = [sa_itrf, R](const Vector2D& loc) -> Vector3D { - return sa_itrf - * Vector3D(R * std::cos(loc[0]), R * std::sin(loc[0]), loc[1]); - }; - - sArray = std::make_unique<SurfaceArray>( - payload.at("surfacearray"), - g2l, - l2g, - std::make_shared<const Transform3D>(sa_trf)); - } - - // @TODO: Implement ApproachDescriptor serialization - return MutableLayerPtr(new DiscLayer(trf, - rbounds, - std::move(sArray), - thickness, - nullptr, // std::move(ad), - laytyp)); -} - const Acts::DiscSurface& Acts::DiscLayer::surfaceRepresentation() const { @@ -185,43 +117,3 @@ Acts::DiscLayer::buildApproachDescriptor() } } } - -Acts::variant_data -Acts::DiscLayer::toVariantData() const -{ - using namespace std::string_literals; - variant_map payload; - - if (m_transform) { - payload["transform"] = to_variant(*m_transform); - } - - // we need to recover the bounds - const AbstractVolume* absVol = representingVolume(); - throw_assert(absVol, - "Cannot serialize DiscLayer without representing volume"); - auto cvBounds - = dynamic_cast<const CylinderVolumeBounds*>(&absVol->volumeBounds()); - - payload["minR"] = cvBounds->innerRadius(); - payload["maxR"] = cvBounds->outerRadius(); - payload["thickness"] = thickness(); - - if (layerType() == active) { - payload["layer_type"] = "active"s; - } else if (layerType() == passive) { - payload["layer_type"] = "passive"s; - } else { /*layerType() == navigation*/ - payload["layer_type"] = "navigation"s; - } - - if (m_surfaceArray) { - payload["surfacearray"] = m_surfaceArray->toVariantData(); - payload["surfacearray_transform"] = to_variant(m_surfaceArray->transform()); - } - - variant_map data; - data["type"] = "DiscLayer"s; - data["payload"] = payload; - return data; -} diff --git a/Core/src/Layers/NavigationLayer.cpp b/Core/src/Layers/NavigationLayer.cpp index fcd8eaea1..ac6622a4c 100644 --- a/Core/src/Layers/NavigationLayer.cpp +++ b/Core/src/Layers/NavigationLayer.cpp @@ -12,8 +12,6 @@ #include "Acts/Layers/NavigationLayer.hpp" #include "Acts/Surfaces/Surface.hpp" -#include "Acts/Utilities/InstanceFactory.hpp" -#include "Acts/Utilities/VariantData.hpp" Acts::NavigationLayer::NavigationLayer( std::shared_ptr<const Surface> surfaceRepresentation, @@ -25,40 +23,4 @@ Acts::NavigationLayer::NavigationLayer( m_layerType = navigation; } -std::shared_ptr<const Acts::Layer> -Acts::NavigationLayer::create(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "NavigationLayer", "Type must be NavigationLayer"); - - const variant_map& payload = data.get<variant_map>("payload"); - - double thickness = payload.get<double>("thickness"); - InstanceFactory factory; - - const variant_map& var_surface - = payload.get<variant_map>("surface_representation"); - std::shared_ptr<const Surface> surface_ptr - = factory.surface(var_surface.get<std::string>("type"), var_surface); - - return NavigationLayer::create(std::move(surface_ptr), thickness); -} - Acts::NavigationLayer::~NavigationLayer() = default; - -Acts::variant_data -Acts::NavigationLayer::toVariantData() const -{ - using namespace std::string_literals; - variant_map payload; - - payload["surface_representation"] = m_surfaceRepresentation->toVariantData(); - payload["thickness"] = thickness(); - - variant_map data; - data["type"] = "NavigationLayer"s; - data["payload"] = payload; - return data; -} diff --git a/Core/src/Surfaces/ConeBounds.cpp b/Core/src/Surfaces/ConeBounds.cpp index 6cbb1b614..a6833348b 100644 --- a/Core/src/Surfaces/ConeBounds.cpp +++ b/Core/src/Surfaces/ConeBounds.cpp @@ -17,7 +17,6 @@ #include <iostream> #include <limits> -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Utilities/detail/periodic.hpp" Acts::ConeBounds::ConeBounds(double alpha, @@ -46,23 +45,6 @@ Acts::ConeBounds::ConeBounds(double alpha, { } -Acts::ConeBounds::ConeBounds(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "ConeBounds", "Type must be ConeBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - - m_alpha = payload.get<double>("alpha"); - m_tanAlpha = std::tan(m_alpha); - m_zMin = payload.get<double>("zMin"); - m_zMax = payload.get<double>("zMax"); - m_avgPhi = payload.get<double>("avgPhi"); - m_halfPhi = payload.get<double>("halfPhi"); -} - Acts::ConeBounds::~ConeBounds() = default; Acts::ConeBounds* @@ -133,18 +115,3 @@ Acts::ConeBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::ConeBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["alpha"] = m_alpha; - payload["zMin"] = m_zMin; - payload["zMax"] = m_zMax; - payload["avgPhi"] = m_avgPhi; - payload["halfPhi"] = m_halfPhi; - - return variant_map({{"type", "ConeBounds"s}, {"payload", payload}}); -} diff --git a/Core/src/Surfaces/ConeSurface.cpp b/Core/src/Surfaces/ConeSurface.cpp index 3c93c3d9e..51d19399c 100644 --- a/Core/src/Surfaces/ConeSurface.cpp +++ b/Core/src/Surfaces/ConeSurface.cpp @@ -19,7 +19,6 @@ #include <utility> #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" using Acts::VectorHelpers::phi; @@ -63,27 +62,6 @@ Acts::ConeSurface::ConeSurface(std::shared_ptr<const Transform3D> htrans, throw_assert(cbounds, "ConeBounds must not be nullptr"); } -Acts::ConeSurface::ConeSurface(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - variant_map data = boost::get<variant_map>(vardata); - throw_assert(data.count("type"), "Variant data must have type."); - std::string type = data.get<std::string>("type"); - throw_assert(type == "ConeSurface", "Variant data type must be ConeSurface"); - - variant_map payload = data.get<variant_map>("payload"); - variant_map var_bounds = payload.get<variant_map>("bounds"); - - m_bounds = std::make_shared<const ConeBounds>(var_bounds); - - if (payload.count("transform") != 0u) { - // we have a transform - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - m_transform = trf; - } -} - const Acts::Vector3D Acts::ConeSurface::binningPosition(Acts::BinningValue bValue) const { @@ -242,21 +220,3 @@ Acts::ConeSurface::bounds() const // is safe because no constructor w/o bounds exists return (*m_bounds.get()); } - -Acts::variant_data -Acts::ConeSurface::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["bounds"] = m_bounds->toVariantData(); - - if (m_transform) { - payload["transform"] = to_variant(*m_transform); - } - - variant_map data; - data["type"] = "ConeSurface"s; - data["payload"] = payload; - return data; -} diff --git a/Core/src/Surfaces/CylinderBounds.cpp b/Core/src/Surfaces/CylinderBounds.cpp index 1b6e1e4d8..691c2a384 100644 --- a/Core/src/Surfaces/CylinderBounds.cpp +++ b/Core/src/Surfaces/CylinderBounds.cpp @@ -17,7 +17,6 @@ #include <iostream> #include "Acts/Utilities/Helpers.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Utilities/detail/periodic.hpp" using Acts::VectorHelpers::phi; @@ -51,22 +50,6 @@ Acts::CylinderBounds::CylinderBounds(double radius, } } -Acts::CylinderBounds::CylinderBounds(const variant_data& vardata) - : m_radius(0), m_avgPhi(0), m_halfPhi(0), m_halfZ(0) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "CylinderBounds", "Type must be CylinderBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - - m_radius = payload.get<double>("radius"); - m_avgPhi = payload.get<double>("avgPhi"); - m_halfPhi = payload.get<double>("halfPhi"); - m_halfZ = payload.get<double>("halfZ"); -} - Acts::CylinderBounds::~CylinderBounds() = default; Acts::CylinderBounds* @@ -170,19 +153,3 @@ Acts::CylinderBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::CylinderBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["radius"] = m_radius; - payload["avgPhi"] = m_avgPhi; - payload["halfPhi"] = m_halfPhi; - payload["halfZ"] = m_halfZ; - - variant_map data({{"type", "CylinderBounds"s}, {"payload", payload}}); - - return data; -} diff --git a/Core/src/Surfaces/CylinderSurface.cpp b/Core/src/Surfaces/CylinderSurface.cpp index 299e35033..2a7daf665 100644 --- a/Core/src/Surfaces/CylinderSurface.cpp +++ b/Core/src/Surfaces/CylinderSurface.cpp @@ -20,7 +20,6 @@ #include <utility> #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" using Acts::VectorHelpers::phi; using Acts::VectorHelpers::perp; @@ -74,28 +73,6 @@ Acts::CylinderSurface::CylinderSurface( throw_assert(cbounds, "CylinderBounds must not be nullptr"); } -Acts::CylinderSurface::CylinderSurface(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - variant_map data = boost::get<variant_map>(vardata); - throw_assert(data.count("type"), "Variant data must have type."); - std::string type = data.get<std::string>("type"); - throw_assert(type == "CylinderSurface", - "Variant data type must be CylinderSurface"); - - variant_map payload = data.get<variant_map>("payload"); - variant_map var_bounds = payload.get<variant_map>("bounds"); - - m_bounds = std::make_shared<const CylinderBounds>(var_bounds); - - if (payload.count("transform") != 0u) { - // we have a transform - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - m_transform = trf; - } -} - Acts::CylinderSurface& Acts::CylinderSurface::operator=(const CylinderSurface& other) { @@ -254,24 +231,6 @@ Acts::CylinderSurface::bounds() const return (*m_bounds.get()); } -Acts::variant_data -Acts::CylinderSurface::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["bounds"] = m_bounds->toVariantData(); - - if (m_transform) { - payload["transform"] = to_variant(*m_transform); - } - - variant_map data; - data["type"] = "CylinderSurface"s; - data["payload"] = payload; - return data; -} - Acts::PolyhedronRepresentation Acts::CylinderSurface::polyhedronRepresentation(size_t l0div, size_t /*l1div*/) const diff --git a/Core/src/Surfaces/DiamondBounds.cpp b/Core/src/Surfaces/DiamondBounds.cpp index 8f889260f..765a4a164 100644 --- a/Core/src/Surfaces/DiamondBounds.cpp +++ b/Core/src/Surfaces/DiamondBounds.cpp @@ -12,7 +12,6 @@ #include "Acts/Surfaces/DiamondBounds.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" #include <cmath> #include <iomanip> @@ -35,27 +34,6 @@ Acts::DiamondBounds::DiamondBounds(double minhalex, throw_assert((maxhalex <= medhalex), "Hexagon must be a convex polygon"); } -Acts::DiamondBounds::DiamondBounds(const variant_data& vardata) - : m_boundingBox(0, 0) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "DiamondBounds", "Type must be DiamondBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - - m_minHalfX = payload.get<double>("minHalfX"); - m_medHalfX = payload.get<double>("medHalfX"); - m_maxHalfX = payload.get<double>("maxHalfX"); - m_minY = payload.get<double>("minY"); - m_maxY = payload.get<double>("maxY"); - - m_boundingBox - = RectangleBounds(std::max(std::max(m_minHalfX, m_medHalfX), m_maxHalfX), - std::max(m_minY, m_maxY)); -} - Acts::DiamondBounds::~DiamondBounds() = default; Acts::DiamondBounds* @@ -127,22 +105,3 @@ Acts::DiamondBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::DiamondBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["minHalfX"] = m_minHalfX; - payload["medHalfX"] = m_medHalfX; - payload["maxHalfX"] = m_maxHalfX; - payload["minY"] = m_minY; - payload["maxY"] = m_maxY; - - variant_map data; - data["type"] = "DiamondBounds"s; - data["payload"] = payload; - - return data; -} diff --git a/Core/src/Surfaces/DiscSurface.cpp b/Core/src/Surfaces/DiscSurface.cpp index ae9a992dc..e3939c55a 100644 --- a/Core/src/Surfaces/DiscSurface.cpp +++ b/Core/src/Surfaces/DiscSurface.cpp @@ -22,9 +22,7 @@ #include "Acts/Surfaces/PolyhedronRepresentation.hpp" #include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/InstanceFactory.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" using Acts::VectorHelpers::phi; using Acts::VectorHelpers::perp; @@ -81,34 +79,6 @@ Acts::DiscSurface::DiscSurface(const std::shared_ptr<const DiscBounds>& dbounds, throw_assert(dbounds, "nullptr as DiscBounds"); } -Acts::DiscSurface::DiscSurface(const variant_data& vardata) : GeometryObject() -{ - - throw_assert(vardata.which() == 4, "Variant data must be map"); - variant_map data = boost::get<variant_map>(vardata); - throw_assert(data.count("type"), "Variant data must have type."); - // std::string type = boost::get<std::string>(data["type"]); - std::string type = data.get<std::string>("type"); - throw_assert(type == "DiscSurface", "Variant data type must be StrawSurface"); - - variant_map payload = data.get<variant_map>("payload"); - variant_map var_bounds = payload.get<variant_map>("bounds"); - std::string boundsType = var_bounds.get<std::string>("type"); - - InstanceFactory factory; - - std::shared_ptr<const DiscBounds> bounds - = factory.discBounds(boundsType, var_bounds); - m_bounds = bounds; - - if (payload.count("transform") != 0u) { - // we have a transform - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - m_transform = trf; - } -} - Acts::DiscSurface& Acts::DiscSurface::operator=(const DiscSurface& other) { @@ -217,24 +187,6 @@ Acts::DiscSurface::bounds() const return s_noBounds; } -Acts::variant_data -Acts::DiscSurface::toVariantData() const -{ - using namespace std::string_literals; - - variant_data bounds = m_bounds->toVariantData(); - variant_map payload; - payload["bounds"] = bounds; - if (m_transform) { - payload["transform"] = to_variant(*m_transform); - } - - variant_map data; - data["type"] = "DiscSurface"s; - data["payload"] = payload; - return data; -} - Acts::PolyhedronRepresentation Acts::DiscSurface::polyhedronRepresentation(size_t l0div, size_t /*l1div*/) const diff --git a/Core/src/Surfaces/DiscTrapezoidalBounds.cpp b/Core/src/Surfaces/DiscTrapezoidalBounds.cpp index 6915bf81d..acd032ed1 100644 --- a/Core/src/Surfaces/DiscTrapezoidalBounds.cpp +++ b/Core/src/Surfaces/DiscTrapezoidalBounds.cpp @@ -16,7 +16,6 @@ #include <iomanip> #include <iostream> -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Utilities/detail/periodic.hpp" Acts::DiscTrapezoidalBounds::DiscTrapezoidalBounds(double minhalfx, @@ -34,24 +33,6 @@ Acts::DiscTrapezoidalBounds::DiscTrapezoidalBounds(double minhalfx, { } -Acts::DiscTrapezoidalBounds::DiscTrapezoidalBounds(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "DiscTrapezoidalBounds", - "Type must be DiscTrapezoidalBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - - m_rMin = payload.get<double>("rMin"); - m_rMax = payload.get<double>("rMax"); - m_minHalfX = payload.get<double>("minHalfX"); - m_maxHalfX = payload.get<double>("maxHalfX"); - m_avgPhi = payload.get<double>("avgPhi"); - m_stereo = payload.get<double>("stereo"); -} - Acts::DiscTrapezoidalBounds::~DiscTrapezoidalBounds() = default; Acts::DiscTrapezoidalBounds* @@ -134,20 +115,3 @@ Acts::DiscTrapezoidalBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::DiscTrapezoidalBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["rMin"] = m_rMin; - payload["rMax"] = m_rMax; - payload["minHalfX"] = m_minHalfX; - payload["maxHalfX"] = m_maxHalfX; - payload["avgPhi"] = m_avgPhi; - payload["stereo"] = m_stereo; - - return variant_map( - {{"type", "DiscTrapezoidalBounds"s}, {"payload", payload}}); -} diff --git a/Core/src/Surfaces/EllipseBounds.cpp b/Core/src/Surfaces/EllipseBounds.cpp index 24f7893c6..71acdd01b 100644 --- a/Core/src/Surfaces/EllipseBounds.cpp +++ b/Core/src/Surfaces/EllipseBounds.cpp @@ -17,7 +17,6 @@ #include <iostream> #include "Acts/Utilities/Helpers.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Utilities/detail/periodic.hpp" using Acts::VectorHelpers::phi; @@ -40,27 +39,6 @@ Acts::EllipseBounds::EllipseBounds(double minRadius0, { } -Acts::EllipseBounds::EllipseBounds(const variant_data& vardata) - : m_boundingBox(0, 0) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "EllipseBounds", "Type must be EllipseBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - - m_rMinX = payload.get<double>("rMinX"); - m_rMinY = payload.get<double>("rMinY"); - m_rMaxX = payload.get<double>("rMaxX"); - m_rMaxY = payload.get<double>("rMaxY"); - m_avgPhi = payload.get<double>("avgPhi"); - m_halfPhi = payload.get<double>("halfPhi"); - - m_boundingBox - = RectangleBounds(std::max(m_rMinX, m_rMaxX), std::max(m_rMinY, m_rMaxY)); -} - Acts::EllipseBounds::~EllipseBounds() = default; Acts::EllipseBounds* @@ -210,23 +188,3 @@ Acts::EllipseBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::EllipseBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["rMinX"] = m_rMinX; - payload["rMinY"] = m_rMinY; - payload["rMaxX"] = m_rMaxX; - payload["rMaxY"] = m_rMaxY; - payload["avgPhi"] = m_avgPhi; - payload["halfPhi"] = m_halfPhi; - - variant_map data; - data["type"] = "EllipseBounds"s; - data["payload"] = payload; - - return data; -} diff --git a/Core/src/Surfaces/InfinitieBounds.cpp b/Core/src/Surfaces/InfinitieBounds.cpp index a9930ab7a..b19e54e99 100644 --- a/Core/src/Surfaces/InfinitieBounds.cpp +++ b/Core/src/Surfaces/InfinitieBounds.cpp @@ -7,11 +7,3 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "Acts/Surfaces/InfiniteBounds.hpp" -#include "Acts/Utilities/VariantData.hpp" - -Acts::variant_data -Acts::InfiniteBounds::toVariantData() const -{ - using namespace std::string_literals; - return variant_map({{"type", "InfiniteBounds"s}}); -} diff --git a/Core/src/Surfaces/LineBounds.cpp b/Core/src/Surfaces/LineBounds.cpp index 35daa7602..9aedea86a 100644 --- a/Core/src/Surfaces/LineBounds.cpp +++ b/Core/src/Surfaces/LineBounds.cpp @@ -11,7 +11,6 @@ /////////////////////////////////////////////////////////////////// #include "Acts/Surfaces/LineBounds.hpp" -#include "Acts/Utilities/VariantData.hpp" #include <iomanip> #include <iostream> @@ -21,22 +20,6 @@ Acts::LineBounds::LineBounds(double radius, double halez) { } -Acts::LineBounds::LineBounds(const variant_data& vardata) -{ - - throw_assert(vardata.which() == 4, "Variant data must be map"); - variant_map data = boost::get<variant_map>(vardata); - throw_assert(data.count("type"), "Variant data must have type."); - // std::string type = boost::get<std::string>(data["type"]); - std::string type = data.get<std::string>("type"); - throw_assert(type == "LineBounds", "Variant data type must be LineBounds"); - - variant_map payload = data.get<variant_map>("payload"); - - m_radius = payload.get<double>("radius"); - m_halfZ = payload.get<double>("halfZ"); -} - Acts::LineBounds::~LineBounds() = default; Acts::LineBounds* @@ -86,18 +69,3 @@ Acts::LineBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::LineBounds::toVariantData() const -{ - using namespace std::string_literals; - variant_map payload; - - payload["radius"] = m_radius; - payload["halfZ"] = m_halfZ; - - variant_map data; - data["type"] = "LineBounds"s; - data["payload"] = payload; - return data; -} diff --git a/Core/src/Surfaces/LineSurface.cpp b/Core/src/Surfaces/LineSurface.cpp index 1dd3d48ce..980332284 100644 --- a/Core/src/Surfaces/LineSurface.cpp +++ b/Core/src/Surfaces/LineSurface.cpp @@ -18,7 +18,6 @@ #include <utility> #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" Acts::LineSurface::LineSurface(std::shared_ptr<const Transform3D> htrans, double radius, @@ -62,49 +61,3 @@ Acts::LineSurface::operator=(const LineSurface& other) } return *this; } - -Acts::LineSurface::LineSurface(const variant_data& vardata) : GeometryObject() -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - variant_map data = boost::get<variant_map>(vardata); - throw_assert(data.count("type"), "Variant data must have type."); - // std::string type = boost::get<std::string>(data["type"]); - std::string type = data.get<std::string>("type"); - throw_assert(type == "LineSurface", "Variant data type must be LineSurface"); - - variant_map payload = data.get<variant_map>("payload"); - variant_map bounds = payload.get<variant_map>("bounds"); - std::string boundsType = bounds.get<std::string>("type"); - - throw_assert(boundsType == "LineBounds", - "Can only construct LineSurface from LineBounds"); - - m_bounds = std::make_shared<const LineBounds>(bounds); - - if (payload.count("transform") != 0u) { - // we have a transform - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - m_transform = trf; - } -} - -Acts::variant_data -Acts::LineSurface::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - - variant_data bounds = m_bounds->toVariantData(); - payload["bounds"] = bounds; - - if (m_transform) { - payload["transform"] = to_variant(*m_transform); - } - - variant_map data; - data["type"] = "LineSurface"s; - data["payload"] = payload; - return data; -} diff --git a/Core/src/Surfaces/PerigeeSurface.cpp b/Core/src/Surfaces/PerigeeSurface.cpp index a8432ef2a..599614f19 100644 --- a/Core/src/Surfaces/PerigeeSurface.cpp +++ b/Core/src/Surfaces/PerigeeSurface.cpp @@ -11,7 +11,6 @@ /////////////////////////////////////////////////////////////////// #include "Acts/Surfaces/PerigeeSurface.hpp" -#include "Acts/Utilities/VariantData.hpp" #include <iomanip> #include <iostream> @@ -41,28 +40,6 @@ Acts::PerigeeSurface::PerigeeSurface(const PerigeeSurface& other, { } -Acts::PerigeeSurface::PerigeeSurface(const variant_data& vardata) - : GeometryObject(), LineSurface(nullptr, nullptr) -{ - - throw_assert(vardata.which() == 4, "Variant data must be map"); - variant_map data = boost::get<variant_map>(vardata); - throw_assert(data.count("type"), "Variant data must have type."); - // std::string type = boost::get<std::string>(data["type"]); - std::string type = data.get<std::string>("type"); - throw_assert(type == "PerigeeSurface", - "Variant data type must be PerigeeSurface"); - - variant_map payload = data.get<variant_map>("payload"); - - if (payload.count("transform") != 0u) { - // we have a transform - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - m_transform = trf; - } -} - Acts::PerigeeSurface& Acts::PerigeeSurface::operator=(const PerigeeSurface& other) { @@ -110,20 +87,3 @@ Acts::PerigeeSurface::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::PerigeeSurface::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - - if (m_transform) { - payload["transform"] = to_variant(*m_transform); - } - - variant_map data; - data["type"] = "PerigeeSurface"s; - data["payload"] = payload; - return data; -} diff --git a/Core/src/Surfaces/PlaneSurface.cpp b/Core/src/Surfaces/PlaneSurface.cpp index c55a90088..5bad39035 100644 --- a/Core/src/Surfaces/PlaneSurface.cpp +++ b/Core/src/Surfaces/PlaneSurface.cpp @@ -19,9 +19,6 @@ #include "Acts/Surfaces/InfiniteBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" - -#include "Acts/Utilities/InstanceFactory.hpp" Acts::PlaneSurface::PlaneSurface(const PlaneSurface& other) : GeometryObject(), Surface(other), m_bounds(other.m_bounds) @@ -72,35 +69,6 @@ Acts::PlaneSurface::PlaneSurface(std::shared_ptr<const Transform3D> htrans, { } -Acts::PlaneSurface::PlaneSurface(const variant_data& vardata) -{ - // we need to figure out which way the PS was constructed before - throw_assert(vardata.which() == 4, "Variant data must be map"); - variant_map data = boost::get<variant_map>(vardata); - throw_assert(data.count("type"), "Variant data must have type."); - // std::string type = boost::get<std::string>(data["type"]); - std::string type = data.get<std::string>("type"); - throw_assert(type == "PlaneSurface", - "Variant data type must be PlaneSurface"); - - variant_map payload = data.get<variant_map>("payload"); - variant_map bounds = payload.get<variant_map>("bounds"); - std::string boundsType = bounds.get<std::string>("type"); - - InstanceFactory factory; - std::shared_ptr<const PlanarBounds> pbounds - = factory.planarBounds(boundsType, bounds); - - m_bounds = pbounds; - - if (payload.count("transform") != 0u) { - // we have a transform - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - m_transform = trf; - } -} - Acts::PlaneSurface& Acts::PlaneSurface::operator=(const PlaneSurface& other) { @@ -170,25 +138,3 @@ Acts::PlaneSurface::bounds() const } return s_noBounds; } - -Acts::variant_data -Acts::PlaneSurface::toVariantData() const -{ - using namespace std::string_literals; - variant_map payload; - - variant_data bounds = m_bounds->toVariantData(); - payload["bounds"] = bounds; - - if (m_transform) { - payload["transform"] = to_variant(*m_transform); - } else if (m_associatedDetElement != nullptr) { - payload["transform"] = to_variant(m_associatedDetElement->transform()); - } - - variant_map data; - data["type"] = "PlaneSurface"s; - data["payload"] = payload; - - return data; -} diff --git a/Core/src/Surfaces/RadialBounds.cpp b/Core/src/Surfaces/RadialBounds.cpp index 3662a2a6d..589eab632 100644 --- a/Core/src/Surfaces/RadialBounds.cpp +++ b/Core/src/Surfaces/RadialBounds.cpp @@ -16,7 +16,6 @@ #include <iomanip> #include <iostream> -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Utilities/detail/periodic.hpp" Acts::RadialBounds::RadialBounds(double minrad, double maxrad, double hphisec) @@ -35,22 +34,6 @@ Acts::RadialBounds::RadialBounds(double minrad, { } -Acts::RadialBounds::RadialBounds(const variant_data& vardata) -{ - - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "RadialBounds", "Type must be RadialBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - - m_rMin = payload.get<double>("rMin"); - m_rMax = payload.get<double>("rMax"); - m_avgPhi = payload.get<double>("avgPhi"); - m_halfPhi = payload.get<double>("halfPhi"); -} - Acts::RadialBounds::~RadialBounds() = default; Acts::RadialBounds* @@ -114,17 +97,3 @@ Acts::RadialBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::RadialBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["rMin"] = m_rMin; - payload["rMax"] = m_rMax; - payload["avgPhi"] = m_avgPhi; - payload["halfPhi"] = m_halfPhi; - - return variant_map({{"type", "RadialBounds"s}, {"payload", payload}}); -} diff --git a/Core/src/Surfaces/RectangleBounds.cpp b/Core/src/Surfaces/RectangleBounds.cpp index b4685abcb..86517aabc 100644 --- a/Core/src/Surfaces/RectangleBounds.cpp +++ b/Core/src/Surfaces/RectangleBounds.cpp @@ -12,7 +12,6 @@ #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" #include <cmath> #include <iomanip> @@ -23,19 +22,6 @@ Acts::RectangleBounds::RectangleBounds(double halex, double haley) { } -Acts::RectangleBounds::RectangleBounds(const variant_data& vardata) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "RectangleBounds", "Type must be RectangleBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - - m_halfX = payload.get<double>("halflengthX"); - m_halfY = payload.get<double>("halflengthY"); -} - Acts::RectangleBounds::~RectangleBounds() = default; Acts::RectangleBounds* @@ -97,17 +83,3 @@ Acts::RectangleBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::RectangleBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["halflengthX"] = m_halfX; - payload["halflengthY"] = m_halfY; - - variant_map data({{"type", "RectangleBounds"s}, {"payload", payload}}); - - return data; -} diff --git a/Core/src/Surfaces/StrawSurface.cpp b/Core/src/Surfaces/StrawSurface.cpp index a85209917..4a9097d30 100644 --- a/Core/src/Surfaces/StrawSurface.cpp +++ b/Core/src/Surfaces/StrawSurface.cpp @@ -18,7 +18,6 @@ #include <utility> #include "Acts/Surfaces/InfiniteBounds.hpp" -#include "Acts/Utilities/VariantData.hpp" Acts::StrawSurface::StrawSurface(std::shared_ptr<const Transform3D> htrans, double radius, @@ -51,34 +50,6 @@ Acts::StrawSurface::StrawSurface(const StrawSurface& other, { } -Acts::StrawSurface::StrawSurface(const variant_data& vardata) - : GeometryObject(), LineSurface(nullptr, nullptr) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - variant_map data = boost::get<variant_map>(vardata); - throw_assert(data.count("type"), "Variant data must have type."); - // std::string type = boost::get<std::string>(data["type"]); - std::string type = data.get<std::string>("type"); - throw_assert(type == "StrawSurface", - "Variant data type must be StrawSurface"); - - variant_map payload = data.get<variant_map>("payload"); - variant_map bounds = payload.get<variant_map>("bounds"); - std::string boundsType = bounds.get<std::string>("type"); - - throw_assert(boundsType == "LineBounds", - "Can only construct StrawSurface from LineBounds"); - - m_bounds = std::make_shared<const LineBounds>(bounds); - - if (payload.count("transform") != 0u) { - // we have a transform - auto trf = std::make_shared<const Transform3D>( - from_variant<Transform3D>(payload.get<variant_map>("transform"))); - m_transform = trf; - } -} - Acts::StrawSurface& Acts::StrawSurface::operator=(const StrawSurface& other) { @@ -104,24 +75,6 @@ Acts::StrawSurface::clone_impl(const Transform3D* shift) const return new StrawSurface(*this); } -Acts::variant_data -Acts::StrawSurface::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - variant_data bounds = m_bounds->toVariantData(); - payload["bounds"] = bounds; - if (m_transform) { - payload["transform"] = to_variant(*m_transform); - } - - variant_map data; - data["type"] = "StrawSurface"s; - data["payload"] = payload; - return data; -} - Acts::PolyhedronRepresentation Acts::StrawSurface::polyhedronRepresentation(size_t l0div, size_t /*l1div*/) const diff --git a/Core/src/Surfaces/SurfaceArray.cpp b/Core/src/Surfaces/SurfaceArray.cpp index 8f37ff69e..3751e1084 100644 --- a/Core/src/Surfaces/SurfaceArray.cpp +++ b/Core/src/Surfaces/SurfaceArray.cpp @@ -11,86 +11,11 @@ #include "Acts/Surfaces/SurfaceArray.hpp" #include "Acts/Tools/SurfaceArrayCreator.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/InstanceFactory.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" // implementation for pure virtual destructor of ISurfaceGridLookup Acts::SurfaceArray::ISurfaceGridLookup::~ISurfaceGridLookup() = default; -Acts::variant_data -Acts::SurfaceArray::toVariantData() const -{ - using namespace std::string_literals; - variant_map payload; - - throw_assert(p_gridLookup->dimensions() != 0, - "0-dim SurfaceGridLookups cannot currently be serialized"); - - payload["surfacegridlookup"] = surfaceGridLookupToVariantData(*p_gridLookup); - - variant_vector surfaces; - - for (const auto& srf : m_surfaces) { - surfaces.push_back(srf->toVariantData()); - } - - payload["surfaces"] = surfaces; - - variant_map data; - data["type"] = "SurfaceArray"s; - data["payload"] = payload; - return data; -} - -Acts::variant_data -Acts::SurfaceArray::surfaceGridLookupToVariantData( - const ISurfaceGridLookup& sgl) const -{ - using namespace std::string_literals; - variant_map payload; - - payload["dimensions"] = int(sgl.dimensions()); - variant_vector axes; - - for (const auto& axis : sgl.getAxes()) { - variant_map ax_pl; - - ax_pl["axistype"] = axis->isEquidistant() ? "equidistant"s : "variable"s; - - if (axis->isEquidistant()) { - ax_pl["min"] = axis->getMin(); - ax_pl["max"] = axis->getMax(); - ax_pl["nbins"] = int(axis->getNBins()); - } else { - variant_vector bin_edges; - for (const auto& bin_edge : axis->getBinEdges()) { - bin_edges.push_back(bin_edge); - } - ax_pl["bin_edges"] = bin_edges; - } - - if (axis->getBoundaryType() == detail::AxisBoundaryType::Open) { - ax_pl["axisboundarytype"] = "open"s; - } else if (axis->getBoundaryType() == detail::AxisBoundaryType::Bound) { - ax_pl["axisboundarytype"] = "bound"s; - } else if (axis->getBoundaryType() == detail::AxisBoundaryType::Closed) { - ax_pl["axisboundarytype"] = "closed"s; - } - - variant_map ax_data; - ax_data["type"] = "Axis"s; - ax_data["payload"] = ax_pl; - axes.push_back(ax_data); - } - payload["axes"] = axes; - - variant_map data; - data["type"] = "SurfaceGridLookup"s; - data["payload"] = payload; - return data; -} - Acts::SurfaceArray::SurfaceArray( std::unique_ptr<ISurfaceGridLookup> gridLookup, std::vector<std::shared_ptr<const Surface>> surfaces, @@ -110,228 +35,6 @@ Acts::SurfaceArray::SurfaceArray(std::shared_ptr<const Surface> srf) m_surfacesRawPointers.push_back(m_surfaces.at(0).get()); } -Acts::SurfaceArray::SurfaceArray( - const variant_data& data_, - const std::function<Vector2D(const Vector3D&)>& g2l, - const std::function<Vector3D(const Vector2D&)>& l2g, - std::shared_ptr<const Transform3D> transform) - : p_gridLookup(nullptr), m_transform(std::move(transform)) -{ - const variant_map& data = boost::get<variant_map>(data_); - throw_assert(data.get<std::string>("type") == "SurfaceArray", - "Type must be SurfaceArray"); - - const variant_map& payload = data.get<variant_map>("payload"); - const variant_map& var_sgl = payload.get<variant_map>("surfacegridlookup"); - throw_assert(var_sgl.get<std::string>("type") == "SurfaceGridLookup", - "Currently only SurfaceGridLookup can be deserialized"); - const variant_vector& var_surfaces = payload.get<variant_vector>("surfaces"); - - InstanceFactory factory; - - m_surfaces.reserve(var_surfaces.size()); - m_surfacesRawPointers.reserve(var_surfaces.size()); - - for (const auto& var_srf_ : var_surfaces) { - const variant_map& var_srf = boost::get<variant_map>(var_srf_); - std::shared_ptr<Surface> surface - = factory.surface(var_srf.get<std::string>("type"), var_srf); - m_surfacesRawPointers.push_back(surface.get()); - m_surfaces.push_back(std::move(surface)); - } - - // reproduce axes - const variant_vector& var_axes - = var_sgl.get<variant_map>("payload").get<variant_vector>("axes"); - - throw_assert(var_axes.size() == 2, - "This constructor cannot deserialize DIM!=2 data"); - - // two dimensional - const variant_map& var_axis_a - = var_axes.get<variant_map>(0).get<variant_map>("payload"); - const variant_map& var_axis_b - = var_axes.get<variant_map>(1).get<variant_map>("payload"); - - std::string axistype_a = var_axis_a.get<std::string>("axistype"); - std::string axisbdt_a = var_axis_a.get<std::string>("axisboundarytype"); - std::string axistype_b = var_axis_b.get<std::string>("axistype"); - std::string axisbdt_b = var_axis_b.get<std::string>("axisboundarytype"); - - auto makePAxis - = [](const std::string& axistype, - const variant_map& var_axis) -> SurfaceArrayCreator::ProtoAxis { - SurfaceArrayCreator::ProtoAxis pAxis; - if (axistype == "equidistant") { - pAxis.bType = equidistant; - pAxis.min = var_axis.get<double>("min"); - pAxis.max = var_axis.get<double>("max"); - pAxis.nBins = var_axis.get<int>("nbins"); - } else { - std::vector<double> bin_edges; - const variant_vector& var_bin_edges - = var_axis.get<variant_vector>("bin_edges"); - for (size_t i = 0; i < var_bin_edges.size(); i++) { - bin_edges.push_back(var_bin_edges.get<double>(i)); - } - - pAxis.bType = arbitrary; - pAxis.binEdges = bin_edges; - } - - return pAxis; - }; - - SurfaceArrayCreator::ProtoAxis pAxisA = makePAxis(axistype_a, var_axis_a); - SurfaceArrayCreator::ProtoAxis pAxisB = makePAxis(axistype_b, var_axis_b); - - if (axisbdt_a == "closed" && axisbdt_b == "closed") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Closed, - detail::AxisBoundaryType::Closed>( - g2l, l2g, pAxisA, pAxisB); - } else if (axisbdt_a == "closed" && axisbdt_b == "bound") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Closed, - detail::AxisBoundaryType::Bound>( - g2l, l2g, pAxisA, pAxisB); - } else if (axisbdt_a == "closed" && axisbdt_b == "open") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Closed, - detail::AxisBoundaryType::Open>( - g2l, l2g, pAxisA, pAxisB); - } else if (axisbdt_a == "open" && axisbdt_b == "closed") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Open, - detail::AxisBoundaryType::Closed>( - g2l, l2g, pAxisA, pAxisB); - } else if (axisbdt_a == "open" && axisbdt_b == "bound") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Open, - detail::AxisBoundaryType::Bound>( - g2l, l2g, pAxisA, pAxisB); - } else if (axisbdt_a == "open" && axisbdt_b == "open") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Open, - detail::AxisBoundaryType::Open>( - g2l, l2g, pAxisA, pAxisB); - } else if (axisbdt_a == "bound" && axisbdt_b == "closed") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Bound, - detail::AxisBoundaryType::Closed>( - g2l, l2g, pAxisA, pAxisB); - } else if (axisbdt_a == "bound" && axisbdt_b == "bound") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Bound, - detail::AxisBoundaryType::Bound>( - g2l, l2g, pAxisA, pAxisB); - } else if (axisbdt_a == "bound" && axisbdt_b == "open") { - p_gridLookup = SurfaceArrayCreator:: - makeSurfaceGridLookup2D<detail::AxisBoundaryType::Bound, - detail::AxisBoundaryType::Open>( - g2l, l2g, pAxisA, pAxisB); - } - - p_gridLookup->fill(m_surfacesRawPointers); -} - -Acts::SurfaceArray::SurfaceArray( - const variant_data& data_, - std::function<std::array<double, 1>(const Vector3D&)> g2l, - std::function<Vector3D(const std::array<double, 1>&)> l2g, - std::shared_ptr<const Transform3D> transform) - : p_gridLookup(nullptr), m_transform(std::move(transform)) -{ - const variant_map& data = boost::get<variant_map>(data_); - throw_assert(data.get<std::string>("type") == "SurfaceArray", - "Type must be SurfaceArray"); - - const variant_map& payload = data.get<variant_map>("payload"); - const variant_map& var_sgl = payload.get<variant_map>("surfacegridlookup"); - throw_assert(var_sgl.get<std::string>("type") == "SurfaceGridLookup", - "Currently only SurfaceGridLookup can be deserialized"); - const variant_vector& var_surfaces = payload.get<variant_vector>("surfaces"); - - InstanceFactory factory; - - m_surfaces.reserve(var_surfaces.size()); - m_surfacesRawPointers.reserve(var_surfaces.size()); - for (const auto& var_srf_ : var_surfaces) { - const variant_map& var_srf = boost::get<variant_map>(var_srf_); - std::shared_ptr<Surface> surface - = factory.surface(var_srf.get<std::string>("type"), var_srf); - m_surfacesRawPointers.push_back(surface.get()); - m_surfaces.push_back(std::move(surface)); - } - - // reproduce axes - const variant_vector& var_axes - = var_sgl.get<variant_map>("payload").get<variant_vector>("axes"); - - throw_assert(var_axes.size() == 1, - "This constructor cannot deserialize DIM!=2 data"); - - const variant_map& var_axis - = var_axes.get<variant_map>(0).get<variant_map>("payload"); - - std::string axistype = var_axis.get<std::string>("axistype"); - std::string axisbdt = var_axis.get<std::string>("axisboundarytype"); - - if (axistype == "equidistant" && axisbdt == "bound") { - detail::Axis<detail::AxisType::Equidistant, detail::AxisBoundaryType::Bound> - axis(var_axis.get<double>("min"), - var_axis.get<double>("max"), - var_axis.get<int>("nbins")); - - p_gridLookup = std::make_unique<SurfaceGridLookup<decltype(axis)>>( - g2l, l2g, std::make_tuple(axis)); - } else if (axistype == "equidistant" && axisbdt == "closed") { - detail::Axis<detail::AxisType::Equidistant, - detail::AxisBoundaryType::Closed> - axis(var_axis.get<double>("min"), - var_axis.get<double>("max"), - var_axis.get<int>("nbins")); - - p_gridLookup = std::make_unique<SurfaceGridLookup<decltype(axis)>>( - g2l, l2g, std::make_tuple(axis)); - } else if (axistype == "equidistant" && axisbdt == "open") { - detail::Axis<detail::AxisType::Equidistant, detail::AxisBoundaryType::Open> - axis(var_axis.get<double>("min"), - var_axis.get<double>("max"), - var_axis.get<int>("nbins")); - - p_gridLookup = std::make_unique<SurfaceGridLookup<decltype(axis)>>( - g2l, l2g, std::make_tuple(axis)); - } else if (axistype == "variable") { - - std::vector<double> bin_edges; - const variant_vector& var_bin_edges - = var_axis.get<variant_vector>("bin_edges"); - for (size_t i = 0; i < var_bin_edges.size(); i++) { - bin_edges.push_back(var_bin_edges.get<double>(i)); - } - - if (axisbdt == "bound") { - detail::Axis<detail::AxisType::Variable, detail::AxisBoundaryType::Bound> - axis(bin_edges); - p_gridLookup = std::make_unique<SurfaceGridLookup<decltype(axis)>>( - g2l, l2g, std::make_tuple(axis)); - } else if (axisbdt == "closed") { - detail::Axis<detail::AxisType::Variable, detail::AxisBoundaryType::Closed> - axis(bin_edges); - p_gridLookup = std::make_unique<SurfaceGridLookup<decltype(axis)>>( - g2l, l2g, std::make_tuple(axis)); - } else if (axisbdt == "open") { - detail::Axis<detail::AxisType::Variable, detail::AxisBoundaryType::Open> - axis(bin_edges); - p_gridLookup = std::make_unique<SurfaceGridLookup<decltype(axis)>>( - g2l, l2g, std::make_tuple(axis)); - } - } - - p_gridLookup->fill(m_surfacesRawPointers); -} - std::ostream& Acts::SurfaceArray::dump(std::ostream& sl) const { diff --git a/Core/src/Surfaces/TrapezoidBounds.cpp b/Core/src/Surfaces/TrapezoidBounds.cpp index 2201d58ad..b71fd49a1 100644 --- a/Core/src/Surfaces/TrapezoidBounds.cpp +++ b/Core/src/Surfaces/TrapezoidBounds.cpp @@ -15,7 +15,6 @@ #include <cmath> #include <iomanip> #include <iostream> -#include "Acts/Utilities/VariantData.hpp" Acts::TrapezoidBounds::TrapezoidBounds(double minhalex, double maxhalex, @@ -27,23 +26,6 @@ Acts::TrapezoidBounds::TrapezoidBounds(double minhalex, { } -Acts::TrapezoidBounds::TrapezoidBounds(const variant_data& vardata) - : m_boundingBox(0, 0) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "TrapezoidBounds", "Type must be TrapezoidBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - - m_minHalfX = payload.get<double>("minHalfX"); - m_maxHalfX = payload.get<double>("maxHalfX"); - m_halfY = payload.get<double>("halfY"); - - m_boundingBox = RectangleBounds(m_maxHalfX, m_halfY); -} - Acts::TrapezoidBounds::~TrapezoidBounds() = default; Acts::TrapezoidBounds* @@ -108,20 +90,3 @@ Acts::TrapezoidBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::TrapezoidBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - payload["minHalfX"] = m_minHalfX; - payload["maxHalfX"] = m_maxHalfX; - payload["halfY"] = m_halfY; - - variant_map data; - data["type"] = "TrapezoidBounds"s; - data["payload"] = payload; - - return data; -} diff --git a/Core/src/Surfaces/TriangleBounds.cpp b/Core/src/Surfaces/TriangleBounds.cpp index a6605c2d3..18703ed6a 100644 --- a/Core/src/Surfaces/TriangleBounds.cpp +++ b/Core/src/Surfaces/TriangleBounds.cpp @@ -11,7 +11,6 @@ /////////////////////////////////////////////////////////////////// #include "Acts/Surfaces/TriangleBounds.hpp" -#include "Acts/Utilities/VariantData.hpp" #include <iomanip> #include <iostream> @@ -28,30 +27,6 @@ Acts::TriangleBounds::TriangleBounds(const std::array<Vector2D, 3>& vertices) m_boundingBox = RectangleBounds(mx, my); } -Acts::TriangleBounds::TriangleBounds(const variant_data& vardata) - : m_vertices(), m_boundingBox(0, 0) -{ - throw_assert(vardata.which() == 4, "Variant data must be map"); - const variant_map& data = boost::get<variant_map>(vardata); - std::string type = data.get<std::string>("type"); - throw_assert(type == "TriangleBounds", "Type must be TriangleBounds"); - - const variant_map& payload = data.get<variant_map>("payload"); - const variant_vector& vertices = payload.get<variant_vector>("vertices"); - throw_assert(vertices.size() == 3, - "Vertices for triangle must be exactly 3."); - - double mx = 0, my = 0; - for (size_t i = 0; i < 3; i++) { - Vector2D vtx = from_variant<Vector2D>(vertices.at(i)); - mx = std::max(mx, std::abs(vtx.x())); - my = std::max(my, std::abs(vtx.y())); - m_vertices.at(i) = vtx; - } - - m_boundingBox = RectangleBounds(mx, my); -} - Acts::TriangleBounds::~TriangleBounds() = default; Acts::TriangleBounds* @@ -117,22 +92,3 @@ Acts::TriangleBounds::dump(std::ostream& sl) const sl << std::setprecision(-1); return sl; } - -Acts::variant_data -Acts::TriangleBounds::toVariantData() const -{ - using namespace std::string_literals; - - variant_map payload; - - variant_vector vertices; - for (const auto& vtx : m_vertices) { - vertices.push_back(to_variant(vtx)); - } - - variant_map data; - data["type"] = "TriangleBounds"s; - data["payload"] = variant_map({{"vertices", vertices}}); - - return data; -} diff --git a/Core/src/Tools/LayerCreator.cpp b/Core/src/Tools/LayerCreator.cpp index 311df94a5..b11958eab 100644 --- a/Core/src/Tools/LayerCreator.cpp +++ b/Core/src/Tools/LayerCreator.cpp @@ -20,6 +20,7 @@ #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Surfaces/RadialBounds.hpp" +#include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/Units.hpp" diff --git a/Plugins/Json/CMakeLists.txt b/Plugins/Json/CMakeLists.txt index 6b5ab2e63..3da078b0b 100644 --- a/Plugins/Json/CMakeLists.txt +++ b/Plugins/Json/CMakeLists.txt @@ -1,9 +1,9 @@ file (GLOB_RECURSE src_files "src/*.cpp" "include/*.hpp") -add_library (ActsJsonPlugin SHARED ${src_files}) +add_library (ActsJsonPlugin INTERFACE) -target_include_directories (ActsJsonPlugin PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> $<INSTALL_INTERFACE:include>) -target_link_libraries (ActsJsonPlugin PUBLIC ActsCore) +target_include_directories (ActsJsonPlugin SYSTEM INTERFACE ${Boost_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}) +target_include_directories (ActsJsonPlugin INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> $<INSTALL_INTERFACE:include>) install (TARGETS ActsJsonPlugin EXPORT ActsJsonPluginTargets @@ -11,4 +11,3 @@ install (TARGETS ActsJsonPlugin install (DIRECTORY include/Acts DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -acts_add_targets_to_cdash_project(PROJECT ActsJsonPlugin TARGETS ActsJsonPlugin) diff --git a/Plugins/Json/include/Acts/Plugins/Json/FromJson.hpp b/Plugins/Json/include/Acts/Plugins/Json/FromJson.hpp deleted file mode 100644 index 5947b9ef4..000000000 --- a/Plugins/Json/include/Acts/Plugins/Json/FromJson.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2018 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once -#include "Acts/Utilities/VariantDataFwd.hpp" -#include "lib/json.hpp" - -namespace Acts { - -/// Method to turn an instance of @c nlohmann::json into @c variant_data -/// which can then be processed further. -/// @param node Json input data -/// @return The converted variant data -variant_data -from_json(const nlohmann::json& node); - -} // namespace Acts \ No newline at end of file diff --git a/Plugins/Json/src/FromJson.cpp b/Plugins/Json/src/FromJson.cpp deleted file mode 100644 index aacb2db96..000000000 --- a/Plugins/Json/src/FromJson.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2018 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include "Acts/Plugins/Json/lib/json.hpp" -#include "Acts/Utilities/VariantData.hpp" - -#include "Acts/Plugins/Json/FromJson.hpp" -#include "Acts/Utilities/ThrowAssert.hpp" - -using json = nlohmann::json; - -Acts::variant_data -Acts::from_json(const json& node) -{ - throw_assert(!node.is_null(), "Null json values cannot be deserialized"); - - if (node.is_array()) { - variant_vector vec; - for (const auto& item : node) { - vec.push_back(from_json(item)); - } - - return vec; - } else if (node.is_object()) { - - variant_map map; - for (json::const_iterator it = node.begin(); it != node.end(); ++it) { - map[it.key()] = from_json(it.value()); - } - - return map; - } else if (node.is_boolean()) { - bool value = node; - return value; - } else if (node.is_string()) { - std::string value = node; - return value; - } else if (node.is_number_float()) { - double value = node; - return value; - } else /*if(node.is_number_integer())*/ { - int value = node; - return value; - } -} diff --git a/Tests/Core/CommonHelpers/include/Acts/Tests/CommonHelpers/LineSurfaceStub.hpp b/Tests/Core/CommonHelpers/include/Acts/Tests/CommonHelpers/LineSurfaceStub.hpp index d2357a8f8..7b354d612 100644 --- a/Tests/Core/CommonHelpers/include/Acts/Tests/CommonHelpers/LineSurfaceStub.hpp +++ b/Tests/Core/CommonHelpers/include/Acts/Tests/CommonHelpers/LineSurfaceStub.hpp @@ -9,7 +9,6 @@ // #include "Acts/Surfaces/LineSurface.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantDataFwd.hpp" // // #include <limits> @@ -41,11 +40,6 @@ namespace Test { { /* nop */ } - LineSurfaceStub(const variant_data& data) - : GeometryObject(), LineSurface(data) - { /* nop */ - } - // LineSurfaceStub(const LineSurfaceStub& ls) : GeometryObject(), LineSurface(ls) diff --git a/Tests/Core/EventData/BoundParametersTests.cpp b/Tests/Core/EventData/BoundParametersTests.cpp index 4ce2d99ba..f8ebc9888 100644 --- a/Tests/Core/EventData/BoundParametersTests.cpp +++ b/Tests/Core/EventData/BoundParametersTests.cpp @@ -26,7 +26,6 @@ #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/Units.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "ParametersTestHelper.hpp" diff --git a/Tests/Core/Layers/ConeLayerTests.cpp b/Tests/Core/Layers/ConeLayerTests.cpp index 1a2944872..488a3f2fc 100644 --- a/Tests/Core/Layers/ConeLayerTests.cpp +++ b/Tests/Core/Layers/ConeLayerTests.cpp @@ -25,6 +25,7 @@ #include "Acts/EventData/SingleTrackParameters.hpp" #include "Acts/Layers/GenericApproachDescriptor.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" +#include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Tools/SurfaceArrayCreator.hpp" #include "Acts/Volumes/CuboidVolumeBounds.hpp" #include "LayerStub.hpp" diff --git a/Tests/Core/Layers/CylinderLayerTests.cpp b/Tests/Core/Layers/CylinderLayerTests.cpp index d6fdebde8..f7135f2ba 100644 --- a/Tests/Core/Layers/CylinderLayerTests.cpp +++ b/Tests/Core/Layers/CylinderLayerTests.cpp @@ -19,10 +19,10 @@ #include "Acts/Layers/GenericApproachDescriptor.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" +#include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Tools/SurfaceArrayCreator.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Volumes/CuboidVolumeBounds.hpp" #include "LayerStub.hpp" @@ -100,49 +100,6 @@ namespace Test { std::string("Acts::CylinderSurface")); } - BOOST_AUTO_TEST_CASE(CylinderLayer_toVariantData) - { - Translation3D translation{0., 1., 2.}; - Transform3D rot; - rot = AngleAxis3D(M_PI / 4, Vector3D::UnitZ()); - - auto pTransform = std::make_shared<const Transform3D>(translation * rot); - double radius(0.5), halfz(10.); - auto pCylinder = std::make_shared<const CylinderBounds>(radius, halfz); - auto pCylinderLayer = std::dynamic_pointer_cast<CylinderLayer>( - CylinderLayer::create(pTransform, pCylinder, nullptr, 0.4)); - - variant_data var_data = pCylinderLayer->toVariantData(); - std::cout << var_data << std::endl; - - variant_map var_map = boost::get<variant_map>(var_data); - variant_map pl = var_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("thickness"), 0.4); - Transform3D act = from_variant<Transform3D>(pl.at("transform")); - CHECK_CLOSE_OR_SMALL(*pTransform, act, 1e-6, 1e-9); - - auto pCylinderLayer2 = std::dynamic_pointer_cast<CylinderLayer>( - CylinderLayer::create(var_data)); - - BOOST_CHECK_EQUAL(pCylinderLayer->thickness(), - pCylinderLayer2->thickness()); - CHECK_CLOSE_OR_SMALL(pCylinderLayer->transform(), - pCylinderLayer2->transform(), - 1e-6, - 1e-9); - - auto cvBoundsExp = dynamic_cast<const CylinderVolumeBounds*>( - &(pCylinderLayer->representingVolume()->volumeBounds())); - auto cvBoundsAct = dynamic_cast<const CylinderVolumeBounds*>( - &(pCylinderLayer2->representingVolume()->volumeBounds())); - - BOOST_CHECK_EQUAL(cvBoundsExp->innerRadius(), cvBoundsAct->innerRadius()); - BOOST_CHECK_EQUAL(cvBoundsExp->outerRadius(), cvBoundsAct->outerRadius()); - BOOST_CHECK_EQUAL(cvBoundsExp->halfPhiSector(), - cvBoundsAct->halfPhiSector()); - BOOST_CHECK_EQUAL(cvBoundsExp->halflengthZ(), cvBoundsAct->halflengthZ()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Layers } // namespace Test diff --git a/Tests/Core/Layers/DiscLayerTests.cpp b/Tests/Core/Layers/DiscLayerTests.cpp index 31f060ebe..69ac1267f 100644 --- a/Tests/Core/Layers/DiscLayerTests.cpp +++ b/Tests/Core/Layers/DiscLayerTests.cpp @@ -19,9 +19,9 @@ #include "Acts/Layers/GenericApproachDescriptor.hpp" #include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" +#include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Tools/SurfaceArrayCreator.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Volumes/CuboidVolumeBounds.hpp" #include "Acts/Volumes/CylinderVolumeBounds.hpp" @@ -97,43 +97,6 @@ namespace Test { std::string("Acts::DiscSurface")); } - BOOST_AUTO_TEST_CASE(DiscLayer_toVariantData) - { - Translation3D translation{0., 1., 2.}; - auto pTransform = std::make_shared<const Transform3D>(translation); - const double minRad(10.), maxRad(5.); // 20 x 10 disc - auto pDisc = std::make_shared<const RadialBounds>(minRad, maxRad); - auto pDiscLayer = std::dynamic_pointer_cast<DiscLayer>( - DiscLayer::create(pTransform, pDisc, nullptr, 6)); - - variant_data var_data = pDiscLayer->toVariantData(); - std::cout << var_data << std::endl; - - variant_map var_map = boost::get<variant_map>(var_data); - variant_map pl = var_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("thickness"), 6); - Transform3D act = from_variant<Transform3D>(pl.at("transform")); - CHECK_CLOSE_OR_SMALL(*pTransform, act, 1e-6, 1e-9); - - auto pDiscLayer2 - = std::dynamic_pointer_cast<DiscLayer>(DiscLayer::create(var_data)); - - BOOST_CHECK_EQUAL(pDiscLayer->thickness(), pDiscLayer2->thickness()); - CHECK_CLOSE_OR_SMALL( - pDiscLayer->transform(), pDiscLayer2->transform(), 1e-6, 1e-9); - - auto cvBoundsExp = dynamic_cast<const CylinderVolumeBounds*>( - &(pDiscLayer->representingVolume()->volumeBounds())); - auto cvBoundsAct = dynamic_cast<const CylinderVolumeBounds*>( - &(pDiscLayer2->representingVolume()->volumeBounds())); - - BOOST_CHECK_EQUAL(cvBoundsExp->innerRadius(), cvBoundsAct->innerRadius()); - BOOST_CHECK_EQUAL(cvBoundsExp->outerRadius(), cvBoundsAct->outerRadius()); - BOOST_CHECK_EQUAL(cvBoundsExp->halfPhiSector(), - cvBoundsAct->halfPhiSector()); - BOOST_CHECK_EQUAL(cvBoundsExp->halflengthZ(), cvBoundsAct->halflengthZ()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Layers } // namespace Test diff --git a/Tests/Core/Layers/NavigationLayerTests.cpp b/Tests/Core/Layers/NavigationLayerTests.cpp index f49b08073..a764fd052 100644 --- a/Tests/Core/Layers/NavigationLayerTests.cpp +++ b/Tests/Core/Layers/NavigationLayerTests.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Tools/SurfaceArrayCreator.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Volumes/CuboidVolumeBounds.hpp" #include "LayerStub.hpp" @@ -75,35 +74,6 @@ namespace Test { BOOST_CHECK(!pNavigationLayer->resolve(true, true, true)); } - BOOST_AUTO_TEST_CASE(NavigationLayer_toVariantData) - { - const double thickness = 0.1; - double w = 5, h = 10; - auto rbounds = std::make_shared<const RectangleBounds>(w, h); - auto trf = std::make_shared<const Transform3D>(Translation3D(0, 0, 5)); - std::shared_ptr<const Surface> pSurface - = Surface::makeShared<PlaneSurface>(trf, rbounds); - auto pNavigationLayer = std::dynamic_pointer_cast<const NavigationLayer>( - NavigationLayer::create(std::move(pSurface), thickness)); - - variant_data var_data = pNavigationLayer->toVariantData(); - std::cout << var_data << std::endl; - - auto pNavigationLayer2 = std::dynamic_pointer_cast<const NavigationLayer>( - NavigationLayer::create(var_data)); - std::cout << pNavigationLayer2->toVariantData() << std::endl; - - auto rbounds2 = dynamic_cast<const RectangleBounds*>( - &pNavigationLayer2->surfaceRepresentation().bounds()); - CHECK_CLOSE_OR_SMALL( - *trf, - pNavigationLayer2->surfaceRepresentation().transform(), - 1e-6, - 1e-9); - BOOST_CHECK_EQUAL(rbounds2->halflengthX(), w); - BOOST_CHECK_EQUAL(rbounds2->halflengthY(), h); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Layers } // namespace Test diff --git a/Tests/Core/Surfaces/ConeBoundsTests.cpp b/Tests/Core/Surfaces/ConeBoundsTests.cpp index 7cab3469c..b2d6439e5 100644 --- a/Tests/Core/Surfaces/ConeBoundsTests.cpp +++ b/Tests/Core/Surfaces/ConeBoundsTests.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/ConeBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" /* Note on nomenclature: alpha = cone opening half angle @@ -126,33 +125,6 @@ namespace Test { BOOST_CHECK_EQUAL(assignedConeBounds, originalConeBounds); } - BOOST_AUTO_TEST_CASE(ConeBounds_toVariantData) - { - double alpha = M_PI / 2., zMin = 1, zMax = 5, avgPhi = M_PI / 3., - halfPhi = M_PI; - ConeBounds cone(alpha, zMin, zMax, halfPhi, avgPhi); - - variant_data var_cone = cone.toVariantData(); - std::cout << var_cone << std::endl; - - variant_map var_cone_map = boost::get<variant_map>(var_cone); - BOOST_CHECK_EQUAL(var_cone_map.get<std::string>("type"), "ConeBounds"); - variant_map pl = var_cone_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("alpha"), alpha); - BOOST_CHECK_EQUAL(pl.get<double>("zMin"), zMin); - BOOST_CHECK_EQUAL(pl.get<double>("zMax"), zMax); - BOOST_CHECK_EQUAL(pl.get<double>("avgPhi"), avgPhi); - BOOST_CHECK_EQUAL(pl.get<double>("halfPhi"), halfPhi); - - ConeBounds cone2(var_cone); - - BOOST_CHECK_EQUAL(cone.alpha(), cone2.alpha()); - BOOST_CHECK_EQUAL(cone.minZ(), cone2.minZ()); - BOOST_CHECK_EQUAL(cone.maxZ(), cone2.maxZ()); - BOOST_CHECK_EQUAL(cone.averagePhi(), cone2.averagePhi()); - BOOST_CHECK_EQUAL(cone.halfPhiSector(), cone2.halfPhiSector()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/ConeSurfaceTests.cpp b/Tests/Core/Surfaces/ConeSurfaceTests.cpp index d7cfdc8a0..5dd320129 100644 --- a/Tests/Core/Surfaces/ConeSurfaceTests.cpp +++ b/Tests/Core/Surfaces/ConeSurfaceTests.cpp @@ -20,7 +20,6 @@ #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace tt = boost::test_tools; using boost::test_tools::output_test_stream; @@ -221,34 +220,6 @@ namespace Test { BOOST_CHECK_EQUAL(*assignedConeSurface, *coneSurfaceObject); } - BOOST_AUTO_TEST_CASE(ConeSurface_toVariantData) - { - double alpha = M_PI / 2., zMin = 1, zMax = 5, halfPhi = M_PI; - Translation3D translation{0., 1., 2.}; - auto pTransform = std::make_shared<const Transform3D>(translation); - auto cone = Surface::makeShared<ConeSurface>( - pTransform, alpha, zMin, zMax, halfPhi); - - variant_data var_cone = cone->toVariantData(); - std::cout << var_cone << std::endl; - - const variant_map& pl - = boost::get<variant_map>(var_cone).get<variant_map>("payload"); - const variant_map& bounds_pl - = pl.get<variant_map>("bounds").get<variant_map>("payload"); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("alpha"), alpha); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("zMin"), zMin); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("zMax"), zMax); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("halfPhi"), halfPhi); - - auto cone2 = Surface::makeShared<ConeSurface>(var_cone); - auto conebounds = dynamic_cast<const ConeBounds*>(&cone2->bounds()); - BOOST_CHECK_EQUAL(conebounds->alpha(), alpha); - BOOST_CHECK_EQUAL(conebounds->halfPhiSector(), halfPhi); - BOOST_CHECK_EQUAL(conebounds->minZ(), zMin); - BOOST_CHECK_EQUAL(conebounds->maxZ(), zMax); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/CylinderBoundsTests.cpp b/Tests/Core/Surfaces/CylinderBoundsTests.cpp index 609ce53c7..58ae79eb7 100644 --- a/Tests/Core/Surfaces/CylinderBoundsTests.cpp +++ b/Tests/Core/Surfaces/CylinderBoundsTests.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace Acts { @@ -135,30 +134,6 @@ namespace Test { BOOST_CHECK_EQUAL(assignedCylinderBounds, cylinderBoundsObject); } - BOOST_AUTO_TEST_CASE(RectangleBounds_toVariantData) - { - double radius = 10, avgPhi = 0, halfPhi = M_PI, halfZ = 15; - CylinderBounds cylBounds(radius, avgPhi, halfPhi, halfZ); - - variant_data var_data = cylBounds.toVariantData(); - std::cout << var_data << std::endl; - - variant_map var_map = boost::get<variant_map>(var_data); - BOOST_CHECK_EQUAL(var_map.get<std::string>("type"), "CylinderBounds"); - variant_map pl = var_map.get<variant_map>("payload"); - - BOOST_CHECK_EQUAL(pl.get<double>("radius"), radius); - BOOST_CHECK_EQUAL(pl.get<double>("avgPhi"), avgPhi); - BOOST_CHECK_EQUAL(pl.get<double>("halfPhi"), halfPhi); - BOOST_CHECK_EQUAL(pl.get<double>("halfZ"), halfZ); - - CylinderBounds cylBounds2(var_data); - BOOST_CHECK_EQUAL(cylBounds.r(), cylBounds2.r()); - BOOST_CHECK_EQUAL(cylBounds.averagePhi(), cylBounds2.averagePhi()); - BOOST_CHECK_EQUAL(cylBounds.halfPhiSector(), cylBounds2.halfPhiSector()); - BOOST_CHECK_EQUAL(cylBounds.halflengthZ(), cylBounds2.halflengthZ()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/CylinderSurfaceTests.cpp b/Tests/Core/Surfaces/CylinderSurfaceTests.cpp index 79b6bd8e5..40a22d430 100644 --- a/Tests/Core/Surfaces/CylinderSurfaceTests.cpp +++ b/Tests/Core/Surfaces/CylinderSurfaceTests.cpp @@ -21,7 +21,6 @@ #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace tt = boost::test_tools; using boost::test_tools::output_test_stream; @@ -236,34 +235,6 @@ namespace Test { BOOST_CHECK_EQUAL(*assignedCylinderSurface, *cylinderSurfaceObject); } - BOOST_AUTO_TEST_CASE(CylinderSurface_toVariantData) - { - double radius(1.0), halfZ(10.); - Translation3D translation{0., 1., 2.}; - auto pTransform = std::make_shared<const Transform3D>(translation); - auto cylinder - = Surface::makeShared<CylinderSurface>(pTransform, radius, halfZ); - - variant_data var_cyl = cylinder->toVariantData(); - std::cout << var_cyl << std::endl; - - const variant_map& pl - = boost::get<variant_map>(var_cyl).get<variant_map>("payload"); - const variant_map& bounds_pl - = pl.get<variant_map>("bounds").get<variant_map>("payload"); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("radius"), radius); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("avgPhi"), 0); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("halfPhi"), M_PI); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("halfZ"), halfZ); - - auto cylinder2 = Surface::makeShared<CylinderSurface>(var_cyl); - auto cylbounds = dynamic_cast<const CylinderBounds*>(&cylinder2->bounds()); - BOOST_CHECK_EQUAL(cylbounds->r(), radius); - BOOST_CHECK_EQUAL(cylbounds->halflengthZ(), halfZ); - BOOST_CHECK_EQUAL(cylbounds->halfPhiSector(), M_PI); - BOOST_CHECK_EQUAL(cylbounds->averagePhi(), 0); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/DiamondBoundsTests.cpp b/Tests/Core/Surfaces/DiamondBoundsTests.cpp index 9837276f6..c061ea932 100644 --- a/Tests/Core/Surfaces/DiamondBoundsTests.cpp +++ b/Tests/Core/Surfaces/DiamondBoundsTests.cpp @@ -20,7 +20,6 @@ #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace Acts { @@ -150,32 +149,6 @@ namespace Test { BOOST_CHECK_EQUAL(assignedDiamondBoundsObject, diamondBoundsObject); } - BOOST_AUTO_TEST_CASE(DiamondBounds_toVariantData) - { - double minHalfX(10.), midHalfX(50.), maxHalfX(30.), halfY1(10.), - halfY2(20.); - DiamondBounds diam(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); - variant_data var_data = diam.toVariantData(); - - std::cout << var_data << std::endl; - - variant_map var_map = boost::get<variant_map>(var_data); - BOOST_CHECK_EQUAL(var_map.get<std::string>("type"), "DiamondBounds"); - variant_map pl = var_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("minHalfX"), minHalfX); - BOOST_CHECK_EQUAL(pl.get<double>("medHalfX"), midHalfX); - BOOST_CHECK_EQUAL(pl.get<double>("maxHalfX"), maxHalfX); - BOOST_CHECK_EQUAL(pl.get<double>("minY"), halfY1); - BOOST_CHECK_EQUAL(pl.get<double>("maxY"), halfY2); - - DiamondBounds diam2(var_data); - BOOST_CHECK_EQUAL(diam.minHalflengthX(), diam2.minHalflengthX()); - BOOST_CHECK_EQUAL(diam.medHalflengthX(), diam2.medHalflengthX()); - BOOST_CHECK_EQUAL(diam.maxHalflengthX(), diam2.maxHalflengthX()); - BOOST_CHECK_EQUAL(diam.halflengthY1(), diam2.halflengthY1()); - BOOST_CHECK_EQUAL(diam.halflengthY2(), diam2.halflengthY2()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/DiscSurfaceTests.cpp b/Tests/Core/Surfaces/DiscSurfaceTests.cpp index 6435b91b1..15aec55d4 100644 --- a/Tests/Core/Surfaces/DiscSurfaceTests.cpp +++ b/Tests/Core/Surfaces/DiscSurfaceTests.cpp @@ -23,7 +23,6 @@ #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace utf = boost::unit_test; namespace tt = boost::test_tools; @@ -217,56 +216,6 @@ namespace Test { BOOST_CHECK_EQUAL(*assignedDisc, *discSurfaceObject); } - BOOST_AUTO_TEST_CASE(DiscSurface_toVariantData) - { - double minR = 1, maxR = 4, avgPhi = M_PI / 3, phiSec = M_PI; - auto rbounds - = std::make_shared<const RadialBounds>(minR, maxR, avgPhi, phiSec); - - Transform3D rot(AngleAxis3D(M_PI / 4., Vector3D::UnitZ())); - auto trf - = std::make_shared<const Transform3D>(Translation3D(0, 0, 2) * rot); - - auto rdisc = Surface::makeShared<DiscSurface>(trf, rbounds); - - variant_data var_rdisc = rdisc->toVariantData(); - std::cout << var_rdisc << std::endl; - - auto rdisc2 = Surface::makeShared<DiscSurface>(var_rdisc); - CHECK_CLOSE_OR_SMALL(rdisc->transform(), rdisc2->transform(), 1e-6, 1e-9); - CHECK_CLOSE_OR_SMALL(rdisc2->transform(), *trf, 1e-6, 1e-9); - - const RadialBounds* rbounds_act - = dynamic_cast<const RadialBounds*>(&rdisc2->bounds()); - BOOST_CHECK_EQUAL(rbounds->rMin(), rbounds_act->rMin()); - BOOST_CHECK_EQUAL(rbounds->rMax(), rbounds_act->rMax()); - BOOST_CHECK_EQUAL(rbounds->averagePhi(), rbounds_act->averagePhi()); - BOOST_CHECK_EQUAL(rbounds->halfPhiSector(), rbounds_act->halfPhiSector()); - - double rMin = 1, rMax = 5, minHalfX = 2, maxHalfX = 4, stereo = M_PI / 8.; - auto dtbounds = std::make_shared<const DiscTrapezoidalBounds>( - minHalfX, maxHalfX, rMin, rMax, avgPhi, stereo); - - auto dtdisc = Surface::makeShared<DiscSurface>(trf, dtbounds); - variant_data var_dtdisc = dtdisc->toVariantData(); - std::cout << var_dtdisc; - - auto dtdisc2 = Surface::makeShared<DiscSurface>(var_dtdisc); - - CHECK_CLOSE_OR_SMALL(dtdisc->transform(), dtdisc2->transform(), 1e-6, 1e-9); - CHECK_CLOSE_OR_SMALL(dtdisc2->transform(), *trf, 1e-6, 1e-9); - - const DiscTrapezoidalBounds* dtbounds_act - = dynamic_cast<const DiscTrapezoidalBounds*>(&dtdisc2->bounds()); - BOOST_CHECK_EQUAL(dtbounds->rMin(), dtbounds_act->rMin()); - BOOST_CHECK_EQUAL(dtbounds->rMax(), dtbounds_act->rMax()); - BOOST_CHECK_EQUAL(dtbounds->minHalflengthX(), - dtbounds_act->minHalflengthX()); - BOOST_CHECK_EQUAL(dtbounds->maxHalflengthX(), - dtbounds_act->maxHalflengthX()); - BOOST_CHECK_EQUAL(dtbounds->stereo(), dtbounds_act->stereo()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/DiscTrapezoidalBoundsTests.cpp b/Tests/Core/Surfaces/DiscTrapezoidalBoundsTests.cpp index a1c75bcc3..a1e94cc6d 100644 --- a/Tests/Core/Surfaces/DiscTrapezoidalBoundsTests.cpp +++ b/Tests/Core/Surfaces/DiscTrapezoidalBoundsTests.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/DiscTrapezoidalBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace Acts { @@ -136,35 +135,6 @@ namespace Test { discTrapezoidalBoundsObject); } - BOOST_AUTO_TEST_CASE(DiscTrapezoidalBounds_toVariantData) - { - double rMin = 1, rMax = 5, avgPhi = M_PI / 3., minHalfX = 2, maxHalfX = 4, - stereo = M_PI / 8.; - DiscTrapezoidalBounds dt(minHalfX, maxHalfX, rMin, rMax, avgPhi, stereo); - - variant_data var_dt = dt.toVariantData(); - std::cout << var_dt << std::endl; - - variant_map var_dt_map = boost::get<variant_map>(var_dt); - BOOST_CHECK_EQUAL(var_dt_map.get<std::string>("type"), - "DiscTrapezoidalBounds"); - variant_map pl = var_dt_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("rMin"), rMin); - BOOST_CHECK_EQUAL(pl.get<double>("rMax"), rMax); - BOOST_CHECK_EQUAL(pl.get<double>("avgPhi"), avgPhi); - BOOST_CHECK_EQUAL(pl.get<double>("minHalfX"), minHalfX); - BOOST_CHECK_EQUAL(pl.get<double>("maxHalfX"), maxHalfX); - BOOST_CHECK_EQUAL(pl.get<double>("stereo"), stereo); - - DiscTrapezoidalBounds dt2(var_dt); - - BOOST_CHECK_EQUAL(dt.rMin(), dt2.rMin()); - BOOST_CHECK_EQUAL(dt.rMax(), dt2.rMax()); - BOOST_CHECK_EQUAL(dt.minHalflengthX(), dt2.minHalflengthX()); - BOOST_CHECK_EQUAL(dt.maxHalflengthX(), dt2.maxHalflengthX()); - BOOST_CHECK_EQUAL(dt.stereo(), dt2.stereo()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/EllipseBoundsTests.cpp b/Tests/Core/Surfaces/EllipseBoundsTests.cpp index bcb4905ec..e20e78bbb 100644 --- a/Tests/Core/Surfaces/EllipseBoundsTests.cpp +++ b/Tests/Core/Surfaces/EllipseBoundsTests.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/EllipseBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace Acts { @@ -139,35 +138,6 @@ namespace Test { BOOST_CHECK_EQUAL(assignedEllipseBoundsObject, ellipseBoundsObject); } - BOOST_AUTO_TEST_CASE(EllipseBounds_toVariantData) - { - double minRad1(10.), minRad2(15.), maxRad1(15.), maxRad2(20.), - averagePhi(0.), phiSector(M_PI / 2.); - EllipseBounds ell( - minRad1, minRad2, maxRad1, maxRad2, averagePhi, phiSector); - variant_data var_data = ell.toVariantData(); - - std::cout << var_data << std::endl; - - variant_map var_map = boost::get<variant_map>(var_data); - BOOST_CHECK_EQUAL(var_map.get<std::string>("type"), "EllipseBounds"); - variant_map pl = var_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("rMinX"), minRad1); - BOOST_CHECK_EQUAL(pl.get<double>("rMinY"), minRad2); - BOOST_CHECK_EQUAL(pl.get<double>("rMaxX"), maxRad1); - BOOST_CHECK_EQUAL(pl.get<double>("rMaxY"), maxRad2); - BOOST_CHECK_EQUAL(pl.get<double>("avgPhi"), averagePhi); - BOOST_CHECK_EQUAL(pl.get<double>("halfPhi"), phiSector); - - EllipseBounds ell2(var_data); - BOOST_CHECK_EQUAL(ell.rMinX(), ell2.rMinX()); - BOOST_CHECK_EQUAL(ell.rMinY(), ell2.rMinY()); - BOOST_CHECK_EQUAL(ell.rMaxX(), ell2.rMaxX()); - BOOST_CHECK_EQUAL(ell.rMaxY(), ell2.rMaxY()); - BOOST_CHECK_EQUAL(ell.averagePhi(), ell2.averagePhi()); - BOOST_CHECK_EQUAL(ell.halfPhiSector(), ell2.halfPhiSector()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/LineSurfaceTests.cpp b/Tests/Core/Surfaces/LineSurfaceTests.cpp index a164dd0ec..1f2255877 100644 --- a/Tests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/Core/Surfaces/LineSurfaceTests.cpp @@ -22,7 +22,6 @@ #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Tests/CommonHelpers/LineSurfaceStub.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace utf = boost::unit_test; @@ -163,29 +162,6 @@ namespace Test { BOOST_CHECK_EQUAL(assignedLine, originalLine); // operator == from base } - BOOST_AUTO_TEST_CASE(LineSurface_toVariantData) - { - double radius = 2.0, hlZ = 20; - Translation3D translation{0., 1., 2.}; - Transform3D transform(translation); - auto pTransform = std::make_shared<const Transform3D>(translation); - LineSurfaceStub line(pTransform, radius, hlZ); - variant_data var_line = line.toVariantData(); - std::cout << var_line << std::endl; - - const variant_map& pl - = boost::get<variant_map>(var_line).get<variant_map>("payload"); - const variant_map& bounds_pl - = pl.get<variant_map>("bounds").get<variant_map>("payload"); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("radius"), radius); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("halfZ"), hlZ); - - LineSurfaceStub line2(var_line); - auto lbounds = dynamic_cast<const LineBounds*>(&line2.bounds()); - BOOST_CHECK_EQUAL(lbounds->r(), radius); - BOOST_CHECK_EQUAL(lbounds->halflengthZ(), hlZ); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/PerigeeSurfaceTests.cpp b/Tests/Core/Surfaces/PerigeeSurfaceTests.cpp index fe4ac6d3a..92375783b 100644 --- a/Tests/Core/Surfaces/PerigeeSurfaceTests.cpp +++ b/Tests/Core/Surfaces/PerigeeSurfaceTests.cpp @@ -23,7 +23,6 @@ #include "Acts/Surfaces/RectangleBounds.hpp" //to get s_noBounds #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" using boost::test_tools::output_test_stream; namespace utf = boost::unit_test; @@ -105,25 +104,6 @@ namespace Test { BOOST_CHECK_EQUAL(*assignedPerigeeSurface, *perigeeSurfaceObject); } - /// Unit test for testing PerigeeSurface properties - BOOST_AUTO_TEST_CASE(PerigeeSurface_toVariantData) - { - Vector3D unitXYZ{1., 1., 1.}; - auto perigee = Surface::makeShared<PerigeeSurface>(unitXYZ); - - variant_data var_data = perigee->toVariantData(); - std::cout << var_data << std::endl; - - // const variant_map &var_pl = - // boost::get<variant_map>(var_data).get<variant_map>("payload"); - BOOST_CHECK_EQUAL( - boost::get<variant_map>(var_data).get<std::string>("type"), - "PerigeeSurface"); - - auto perigee2 = Surface::makeShared<PerigeeSurface>(var_data); - CHECK_CLOSE_OR_SMALL( - perigee->transform(), perigee2->transform(), 1e-6, 1e-9); - } BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/Core/Surfaces/PlaneSurfaceTests.cpp index 584918ba9..afc4c3b83 100644 --- a/Tests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -22,7 +22,6 @@ #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace tt = boost::test_tools; using boost::test_tools::output_test_stream; @@ -210,46 +209,6 @@ namespace Test { BOOST_CHECK_EQUAL(*assignedPlaneSurface, *planeSurfaceObject); } - BOOST_AUTO_TEST_CASE(PlaneSurface_Serialization) - { - // build - auto rectBounds = std::make_shared<const RectangleBounds>(5, 10); - auto idTrf = std::make_shared<const Transform3D>(Transform3D::Identity()); - auto rot = std::make_shared<const Transform3D>( - AngleAxis3D(M_PI / 4., Vector3D::UnitZ())); - auto rectSrf = Surface::makeShared<PlaneSurface>(rot, rectBounds); - variant_data rectVariant = rectSrf->toVariantData(); - std::cout << rectVariant << std::endl; - - // rebuild from variant - auto rectSrfRec = Surface::makeShared<PlaneSurface>(rectVariant); - auto rectBoundsRec - = dynamic_cast<const RectangleBounds*>(&rectSrfRec->bounds()); - CHECK_CLOSE_REL( - rectBounds->halflengthX(), rectBoundsRec->halflengthX(), 1e-4); - CHECK_CLOSE_REL( - rectBounds->halflengthY(), rectBoundsRec->halflengthY(), 1e-4); - CHECK_CLOSE_OR_SMALL(*rot, rectSrfRec->transform(), 1e-4, 1e-9); - - std::array<Vector2D, 3> vertices - = {{Vector2D(1, 1), Vector2D(1, -1), Vector2D(-1, 1)}}; - auto triangleBounds = std::make_shared<const TriangleBounds>(vertices); - auto triangleSrf = Surface::makeShared<PlaneSurface>(rot, triangleBounds); - variant_data triangleVariant = triangleSrf->toVariantData(); - std::cout << triangleVariant << std::endl; - - // rebuild - auto triangleSrfRec = Surface::makeShared<PlaneSurface>(triangleVariant); - auto triangleBoundsRec - = dynamic_cast<const TriangleBounds*>(&triangleSrfRec->bounds()); - for (size_t i = 0; i < 3; i++) { - CHECK_CLOSE_REL(triangleBounds->vertices().at(i), - triangleBoundsRec->vertices().at(i), - 1e-4); - } - CHECK_CLOSE_OR_SMALL(*rot, triangleSrfRec->transform(), 1e-4, 1e-9); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/RadialBoundsTests.cpp b/Tests/Core/Surfaces/RadialBoundsTests.cpp index 0ce9980e6..948bb1f81 100644 --- a/Tests/Core/Surfaces/RadialBoundsTests.cpp +++ b/Tests/Core/Surfaces/RadialBoundsTests.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace Acts { @@ -106,30 +105,6 @@ namespace Test { BOOST_CHECK_EQUAL(assignedRadialBoundsObject, radialBoundsObject); } - BOOST_AUTO_TEST_CASE(RadialBounds_toVariantData) - { - double rMin = 1, rMax = 5, avgPhi = M_PI / 3., halfPhi = M_PI; - RadialBounds rad(rMin, rMax, avgPhi, halfPhi); - - variant_data var_rad = rad.toVariantData(); - std::cout << var_rad << std::endl; - - variant_map var_rad_map = boost::get<variant_map>(var_rad); - BOOST_CHECK_EQUAL(var_rad_map.get<std::string>("type"), "RadialBounds"); - variant_map pl = var_rad_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("rMin"), rMin); - BOOST_CHECK_EQUAL(pl.get<double>("rMax"), rMax); - BOOST_CHECK_EQUAL(pl.get<double>("avgPhi"), avgPhi); - BOOST_CHECK_EQUAL(pl.get<double>("halfPhi"), halfPhi); - - RadialBounds rad2(var_rad); - - BOOST_CHECK_EQUAL(rad.rMin(), rad2.rMin()); - BOOST_CHECK_EQUAL(rad.rMax(), rad2.rMax()); - BOOST_CHECK_EQUAL(rad.averagePhi(), rad2.averagePhi()); - BOOST_CHECK_EQUAL(rad.halfPhiSector(), rad2.halfPhiSector()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/RectangleBoundsTests.cpp b/Tests/Core/Surfaces/RectangleBoundsTests.cpp index 9a70ff145..111c56389 100644 --- a/Tests/Core/Surfaces/RectangleBoundsTests.cpp +++ b/Tests/Core/Surfaces/RectangleBoundsTests.cpp @@ -16,11 +16,11 @@ #include <algorithm> #include <limits> +#include <iostream> #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace utf = boost::unit_test; const double inf = std::numeric_limits<double>::infinity(); @@ -132,23 +132,6 @@ namespace Test { delete rectB; } - BOOST_AUTO_TEST_CASE(RectangleBounds_toVariantData) - { - RectangleBounds rect(10, 15); - variant_data var_data = rect.toVariantData(); - - std::cout << var_data << std::endl; - variant_map var_map = boost::get<variant_map>(var_data); - BOOST_CHECK_EQUAL(var_map.get<std::string>("type"), "RectangleBounds"); - variant_map pl = var_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("halflengthX"), 10.); - BOOST_CHECK_EQUAL(pl.get<double>("halflengthY"), 15.); - - RectangleBounds rect2(var_data); - BOOST_CHECK_EQUAL(rect.halflengthX(), rect2.halflengthX()); - BOOST_CHECK_EQUAL(rect.halflengthY(), rect2.halflengthY()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/StrawSurfaceTests.cpp b/Tests/Core/Surfaces/StrawSurfaceTests.cpp index b49d76602..53aebb177 100644 --- a/Tests/Core/Surfaces/StrawSurfaceTests.cpp +++ b/Tests/Core/Surfaces/StrawSurfaceTests.cpp @@ -25,7 +25,6 @@ #include "Acts/Surfaces/StrawSurface.hpp" #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" using boost::test_tools::output_test_stream; namespace utf = boost::unit_test; @@ -136,28 +135,6 @@ namespace Test { BOOST_CHECK_EQUAL(*assignedStrawSurface, *strawSurfaceObject); } - BOOST_AUTO_TEST_CASE(StrawSurface_toVariantData) - { - double radius = 2.0, hlZ = 20; - Translation3D translation{0., 1., 2.}; - Transform3D transform(translation); - auto pTransform = std::make_shared<const Transform3D>(translation); - auto straw = Surface::makeShared<StrawSurface>(pTransform, radius, hlZ); - variant_data var_straw = straw->toVariantData(); - std::cout << var_straw << std::endl; - - const variant_map& pl - = boost::get<variant_map>(var_straw).get<variant_map>("payload"); - const variant_map& bounds_pl - = pl.get<variant_map>("bounds").get<variant_map>("payload"); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("radius"), radius); - BOOST_CHECK_EQUAL(bounds_pl.get<double>("halfZ"), hlZ); - - auto straw2 = Surface::makeShared<StrawSurface>(var_straw); - auto lbounds = dynamic_cast<const LineBounds*>(&straw2->bounds()); - BOOST_CHECK_EQUAL(lbounds->r(), radius); - BOOST_CHECK_EQUAL(lbounds->halflengthZ(), hlZ); - } BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/SurfaceArrayTests.cpp b/Tests/Core/Surfaces/SurfaceArrayTests.cpp index 2704ab90d..7c30be161 100644 --- a/Tests/Core/Surfaces/SurfaceArrayTests.cpp +++ b/Tests/Core/Surfaces/SurfaceArrayTests.cpp @@ -24,7 +24,6 @@ #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/Helpers.hpp" -#include "Acts/Utilities/VariantData.hpp" #include "Acts/Utilities/detail/Grid.hpp" #include <fstream> @@ -283,139 +282,6 @@ namespace Test { BOOST_CHECK_EQUAL(sa.surfaces().at(0), srf.get()); } - BOOST_FIXTURE_TEST_CASE(SurfaceArray_toVariantData, SurfaceArrayFixture) - { - SrfVec brl = makeBarrel(30, 7, 2, 1); - std::vector<const Surface*> brlRaw = unpack_shared_vector(brl); - - detail::Axis<detail::AxisType::Equidistant, - detail::AxisBoundaryType::Closed> - phiAxis(-M_PI, M_PI, 30u); - std::vector<double> zAxis_bin_edges_exp = {-14, -10, 3, 5, 8, 14}; - detail::Axis<detail::AxisType::Variable, detail::AxisBoundaryType::Bound> - zAxis(zAxis_bin_edges_exp); - - double angleShift = 2 * M_PI / 30. / 2.; - auto transform = [angleShift](const Vector3D& pos) { - return Vector2D(phi(pos) + angleShift, pos.z()); - }; - double R = 10; - auto itransform = [angleShift, R](const Vector2D& loc) { - return Vector3D(R * std::cos(loc[0] - angleShift), - R * std::sin(loc[0] - angleShift), - loc[1]); - }; - auto sl - = std::make_unique<SurfaceArray::SurfaceGridLookup<decltype(phiAxis), - decltype(zAxis)>>( - transform, - itransform, - std::make_tuple(std::move(phiAxis), std::move(zAxis))); - sl->fill(brlRaw); - SurfaceArray sa(std::move(sl), brl); - sa.dump(std::cout); - - variant_data data = sa.toVariantData(); - // std::cout << data << std::endl; - - const variant_map& var_map = boost::get<variant_map>(data); - BOOST_CHECK_EQUAL(var_map.get<std::string>("type"), "SurfaceArray"); - const variant_map& sa_var_pl = var_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(sa_var_pl.count("surfacegridlookup"), 1); - const variant_map& sgl_var_pl - = sa_var_pl.get<variant_map>("surfacegridlookup") - .get<variant_map>("payload"); - BOOST_CHECK_EQUAL(sgl_var_pl.get<int>("dimensions"), 2); - const variant_vector& axes = sgl_var_pl.get<variant_vector>("axes"); - BOOST_CHECK_EQUAL(axes.size(), 2); - - const variant_map& phiAxis_pl - = axes.get<variant_map>(0).get<variant_map>("payload"); - BOOST_CHECK_EQUAL(phiAxis_pl.get<std::string>("axisboundarytype"), - "closed"); - BOOST_CHECK_EQUAL(phiAxis_pl.get<std::string>("axistype"), "equidistant"); - BOOST_CHECK_EQUAL(phiAxis_pl.get<double>("min"), -M_PI); - BOOST_CHECK_EQUAL(phiAxis_pl.get<double>("max"), M_PI); - BOOST_CHECK_EQUAL(phiAxis_pl.get<int>("nbins"), 30); - - const variant_map& zAxis_pl - = axes.get<variant_map>(1).get<variant_map>("payload"); - BOOST_CHECK_EQUAL(zAxis_pl.get<std::string>("axisboundarytype"), "bound"); - BOOST_CHECK_EQUAL(zAxis_pl.get<std::string>("axistype"), "variable"); - const variant_vector& zAxis_bin_edges - = zAxis_pl.get<variant_vector>("bin_edges"); - BOOST_CHECK_EQUAL(zAxis_bin_edges.size(), 6); - for (size_t i = 0; i < zAxis_bin_edges.size(); i++) { - BOOST_CHECK_EQUAL(zAxis_bin_edges.get<double>(i), - zAxis_bin_edges_exp.at(i)); - } - - SurfaceArray sa2(data, transform, itransform); - sa2.dump(std::cout); - - std::ostringstream dumpExp_os; - sa.dump(dumpExp_os); - std::string dumpExp = dumpExp_os.str(); - boost::test_tools::output_test_stream dumpAct; - sa2.dump(dumpAct); - BOOST_CHECK(dumpAct.is_equal(dumpExp)); - } - - BOOST_FIXTURE_TEST_CASE(SurfaceArray_toVariantData_1D, SurfaceArrayFixture) - { - detail::Axis<detail::AxisType::Equidistant, detail::AxisBoundaryType::Bound> - zAxis(0, 30, 10); - auto transform = [](const Vector3D& pos) { - return std::array<double, 1>({{pos.z()}}); - }; - auto itransform = [](const std::array<double, 1>& loc) { - return Vector3D(0, 0, loc[0]); - }; - auto sl - = std::make_unique<SurfaceArray::SurfaceGridLookup<decltype(zAxis)>>( - transform, itransform, std::make_tuple(zAxis)); - - // same thing in 1D - SrfVec line = straightLineSurfaces(); - std::vector<const Surface*> lineRaw = unpack_shared_vector(line); - sl->fill(lineRaw); - SurfaceArray sa(std::move(sl), line); - - sa.dump(std::cout); - - variant_data data = sa.toVariantData(); - // std::cout << data << std::endl; - - const variant_map& var_map = boost::get<variant_map>(data); - BOOST_CHECK_EQUAL(var_map.get<std::string>("type"), "SurfaceArray"); - const variant_map& sa_var_pl = var_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(sa_var_pl.count("surfacegridlookup"), 1); - const variant_map& sgl_var_pl - = sa_var_pl.get<variant_map>("surfacegridlookup") - .get<variant_map>("payload"); - BOOST_CHECK_EQUAL(sgl_var_pl.get<int>("dimensions"), 1); - const variant_vector& axes = sgl_var_pl.get<variant_vector>("axes"); - BOOST_CHECK_EQUAL(axes.size(), 1); - - const variant_map& zAxis_pl - = axes.get<variant_map>(0).get<variant_map>("payload"); - BOOST_CHECK_EQUAL(zAxis_pl.get<std::string>("axisboundarytype"), "bound"); - BOOST_CHECK_EQUAL(zAxis_pl.get<std::string>("axistype"), "equidistant"); - BOOST_CHECK_EQUAL(zAxis_pl.get<double>("min"), 0); - BOOST_CHECK_EQUAL(zAxis_pl.get<double>("max"), 30); - BOOST_CHECK_EQUAL(zAxis_pl.get<int>("nbins"), 10); - - SurfaceArray sa2(data, transform, itransform); - sa2.dump(std::cout); - - std::ostringstream dumpExp_os; - sa.dump(dumpExp_os); - std::string dumpExp = dumpExp_os.str(); - boost::test_tools::output_test_stream dumpAct; - sa2.dump(dumpAct); - BOOST_CHECK(dumpAct.is_equal(dumpExp)); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/SurfaceBoundsTests.cpp b/Tests/Core/Surfaces/SurfaceBoundsTests.cpp index c6b3583df..1bb5a0d1d 100644 --- a/Tests/Core/Surfaces/SurfaceBoundsTests.cpp +++ b/Tests/Core/Surfaces/SurfaceBoundsTests.cpp @@ -21,7 +21,6 @@ // #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace Acts { @@ -69,12 +68,6 @@ public: return sl; } - variant_data - toVariantData() const override - { - return variant_data(); - } - private: std::vector<TDD_real_t> m_values; }; diff --git a/Tests/Core/Surfaces/SurfaceStub.hpp b/Tests/Core/Surfaces/SurfaceStub.hpp index bcef3f7f2..e5e8e55ff 100644 --- a/Tests/Core/Surfaces/SurfaceStub.hpp +++ b/Tests/Core/Surfaces/SurfaceStub.hpp @@ -10,7 +10,6 @@ #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace Acts { /// Surface derived class stub @@ -132,16 +131,6 @@ public: return true; } - /// Conform to base class signature - variant_data - toVariantData() const override - { - using namespace std::string_literals; - variant_map data; - data["type"] = "SurfaceStub"s; - return data; - } - private: /// the bounds of this surface std::shared_ptr<const PlanarBounds> m_bounds; diff --git a/Tests/Core/Surfaces/TrapezoidBoundsTests.cpp b/Tests/Core/Surfaces/TrapezoidBoundsTests.cpp index dc1494293..2499e8160 100644 --- a/Tests/Core/Surfaces/TrapezoidBoundsTests.cpp +++ b/Tests/Core/Surfaces/TrapezoidBoundsTests.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/TrapezoidBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace utf = boost::unit_test; @@ -121,29 +120,6 @@ namespace Test { BOOST_CHECK_EQUAL(assignedTrapezoidBoundsObject, trapezoidBoundsObject); } - BOOST_AUTO_TEST_CASE(TrapezoidBounds_toVariantData) - { - double minHlX = 10; - double maxHlX = 15; - double hlY = 5; - TrapezoidBounds trap(minHlX, maxHlX, hlY); - variant_data var_data = trap.toVariantData(); - - std::cout << var_data << std::endl; - - variant_map var_map = boost::get<variant_map>(var_data); - BOOST_CHECK_EQUAL(var_map.get<std::string>("type"), "TrapezoidBounds"); - variant_map pl = var_map.get<variant_map>("payload"); - BOOST_CHECK_EQUAL(pl.get<double>("minHalfX"), minHlX); - BOOST_CHECK_EQUAL(pl.get<double>("maxHalfX"), maxHlX); - BOOST_CHECK_EQUAL(pl.get<double>("halfY"), hlY); - - TrapezoidBounds trap2(var_data); - BOOST_CHECK_EQUAL(trap.minHalflengthX(), trap2.minHalflengthX()); - BOOST_CHECK_EQUAL(trap.maxHalflengthX(), trap2.maxHalflengthX()); - BOOST_CHECK_EQUAL(trap.halflengthY(), trap2.halflengthY()); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Surfaces/TriangleBoundsTests.cpp b/Tests/Core/Surfaces/TriangleBoundsTests.cpp index 83fbd0f63..78c4ac1ef 100644 --- a/Tests/Core/Surfaces/TriangleBoundsTests.cpp +++ b/Tests/Core/Surfaces/TriangleBoundsTests.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/TriangleBounds.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace utf = boost::unit_test; @@ -121,37 +120,6 @@ namespace Test { originalVertices.cend()); } - BOOST_AUTO_TEST_CASE(TriangleBounds_toVariantData) - { - std::array<Vector2D, 3> vertices({{Vector2D(1., 1.), - Vector2D(4., 1.), - Vector2D(4., 5.)}}); // 3-4-5 triangle - TriangleBounds triangle(vertices); - variant_data var_data = triangle.toVariantData(); - - std::cout << var_data << std::endl; - - variant_map var_map = boost::get<variant_map>(var_data); - BOOST_CHECK_EQUAL(var_map.get<std::string>("type"), "TriangleBounds"); - variant_map pl = var_map.get<variant_map>("payload"); - - variant_vector var_vertices = pl.get<variant_vector>("vertices"); - BOOST_CHECK_EQUAL(var_vertices.size(), 3); - - for (size_t i = 0; i < 3; i++) { - Vector2D exp = vertices.at(i); - variant_map var = var_vertices.get<variant_map>(i); - BOOST_CHECK_EQUAL(var.get<std::string>("type"), "Vector2D"); - variant_vector coords = var.get<variant_vector>("payload"); - - BOOST_CHECK_EQUAL(exp.x(), coords.get<double>(0)); - BOOST_CHECK_EQUAL(exp.y(), coords.get<double>(1)); - } - - TriangleBounds triangle2(var_data); - BOOST_CHECK_EQUAL(triangle2.vertices().size(), 3); - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Core/Tools/LayerCreatorTests.cpp b/Tests/Core/Tools/LayerCreatorTests.cpp index e03db06b6..e7d6a2c1e 100644 --- a/Tests/Core/Tools/LayerCreatorTests.cpp +++ b/Tests/Core/Tools/LayerCreatorTests.cpp @@ -29,7 +29,6 @@ #include "Acts/Tools/SurfaceArrayCreator.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" namespace bdata = boost::unit_test::data; namespace tt = boost::test_tools; @@ -498,107 +497,6 @@ namespace Test { checkBinning(*layer->surfaceArray()); } - BOOST_FIXTURE_TEST_CASE(LayerCreator_Cylinder_toVariantData, - LayerCreatorFixture) - { - - auto barrel = makeBarrelStagger(30, 7, 0, M_PI / 9.); - auto brl = barrel.first; - draw_surfaces(brl, "LayerCreator_barrelStagger.obj"); - - ProtoLayer pl(brl); - std::shared_ptr<CylinderLayer> layer - = std::dynamic_pointer_cast<CylinderLayer>( - p_LC->cylinderLayer(brl, equidistant, equidistant, pl)); - - std::cout << (*layer->surfaceArray()) << std::endl; - - const variant_data var_layer = layer->toVariantData(); - // std::cout << var_layer << std::endl; - - auto layer2 = std::dynamic_pointer_cast<CylinderLayer>( - CylinderLayer::create(var_layer)); - std::cout << (*layer2->surfaceArray()) << std::endl; - - auto sa = layer->surfaceArray(); - auto sa2 = layer2->surfaceArray(); - - BOOST_CHECK(sa); - BOOST_CHECK(sa2); - - CHECK_CLOSE_OR_SMALL(sa->transform(), sa2->transform(), 1e-6, 1e-9); - - // let's make sure the binning is really ok - // we check that lookup at center of input surface centers - // gives the same number of bin content surfaces - // which also have compatible transforms. - // This is as close to "ok" as we can get I think. - for (const auto& pr : barrel.second) { - auto A = pr.first; - - Vector3D ctr = A->binningPosition(binR); - - std::vector<const Surface*> bc1 = sa->at(ctr); - std::vector<const Surface*> bc2 = sa2->at(ctr); - - BOOST_CHECK_EQUAL(bc1.size(), bc2.size()); - - for (size_t i = 0; i < bc1.size(); i++) { - auto srf1 = bc1.at(i); - auto srf2 = bc2.at(i); - - CHECK_CLOSE_OR_SMALL(srf1->transform(), srf2->transform(), 1e-6, 1e-9); - } - } - } - - BOOST_FIXTURE_TEST_CASE(LayerCreator_Disc_toVariantData, LayerCreatorFixture) - { - std::vector<std::shared_ptr<const Surface>> surfaces; - auto ringa = fullPhiTestSurfacesEC(30, 0, 0, 10); - surfaces.insert(surfaces.end(), ringa.begin(), ringa.end()); - auto ringb = fullPhiTestSurfacesEC(30, 0, 0, 15); - surfaces.insert(surfaces.end(), ringb.begin(), ringb.end()); - auto ringc = fullPhiTestSurfacesEC(30, 0, 0, 20); - surfaces.insert(surfaces.end(), ringc.begin(), ringc.end()); - - ProtoLayer pl(surfaces); - std::shared_ptr<DiscLayer> layer = std::dynamic_pointer_cast<DiscLayer>( - p_LC->discLayer(surfaces, equidistant, equidistant, pl)); - - const variant_data var_layer = layer->toVariantData(); - - std::cout << (*layer->surfaceArray()) << std::endl; - auto layer2 - = std::dynamic_pointer_cast<DiscLayer>(DiscLayer::create(var_layer)); - std::cout << (*layer2->surfaceArray()) << std::endl; - - auto sa = layer->surfaceArray(); - auto sa2 = layer2->surfaceArray(); - - BOOST_CHECK(sa); - BOOST_CHECK(sa2); - - CHECK_CLOSE_OR_SMALL(sa->transform(), sa2->transform(), 1e-6, 1e-9); - - for (const auto& srfRef : surfaces) { - - Vector3D ctr = srfRef->binningPosition(binR); - - std::vector<const Surface*> bc1 = sa->at(ctr); - std::vector<const Surface*> bc2 = sa2->at(ctr); - - BOOST_CHECK_EQUAL(bc1.size(), bc2.size()); - - for (size_t i = 0; i < bc1.size(); i++) { - auto srf1 = bc1.at(i); - auto srf2 = bc2.at(i); - - CHECK_CLOSE_OR_SMALL(srf1->transform(), srf2->transform(), 1e-6, 1e-9); - } - } - } - BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/Plugins/Json/CMakeLists.txt b/Tests/Plugins/Json/CMakeLists.txt index 81ce8e617..e69de29bb 100644 --- a/Tests/Plugins/Json/CMakeLists.txt +++ b/Tests/Plugins/Json/CMakeLists.txt @@ -1,5 +0,0 @@ -add_executable (FromJsonTests FromJsonTests.cpp) -target_include_directories (FromJsonTests PRIVATE ${Boost_INCLUDE_DIRS}) -target_link_libraries(FromJsonTests PRIVATE ActsCore ActsJsonPlugin ActsTestsCommonHelpers ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) -add_test (NAME FromJsonUnitTest COMMAND FromJsonTests) -acts_add_test_to_cdash_project (PROJECT ACore TEST FromJsonUnitTest TARGETS FromJsonTests) diff --git a/Tests/Plugins/Json/FromJsonTests.cpp b/Tests/Plugins/Json/FromJsonTests.cpp index 8c810a130..e69de29bb 100644 --- a/Tests/Plugins/Json/FromJsonTests.cpp +++ b/Tests/Plugins/Json/FromJsonTests.cpp @@ -1,209 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017-2018 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -// clang-format off -#define BOOST_TEST_MODULE FromJson Tests -#define BOOST_TEST_DYN_LINK -#include <boost/test/unit_test.hpp> -// clang-format on - -#include <climits> -#include <fstream> - -#include "Acts/Layers/DiscLayer.hpp" -#include "Acts/Layers/ProtoLayer.hpp" -#include "Acts/Plugins/Json/FromJson.hpp" -#include "Acts/Plugins/Json/lib/json.hpp" -#include "Acts/Surfaces/RectangleBounds.hpp" -#include "Acts/Surfaces/Surface.hpp" -#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" -#include "Acts/Tools/LayerCreator.hpp" -#include "Acts/Tools/SurfaceArrayCreator.hpp" -#include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/VariantData.hpp" - -namespace Acts { - -namespace Test { - - std::vector<std::shared_ptr<const Surface>> - fullPhiTestSurfacesEC(size_t n = 10, - double shift = 0, - double zbase = 0, - double r = 10) - { - - std::vector<std::shared_ptr<const Surface>> res; - - double phiStep = 2 * M_PI / n; - for (size_t i = 0; i < n; ++i) { - - double z = zbase + ((i % 2 == 0) ? 1 : -1) * 0.2; - - Transform3D trans; - trans.setIdentity(); - trans.rotate(Eigen::AngleAxisd(i * phiStep + shift, Vector3D(0, 0, 1))); - trans.translate(Vector3D(r, 0, z)); - - auto bounds = std::make_shared<const RectangleBounds>(2, 1); - - auto transptr = std::make_shared<const Transform3D>(trans); - std::shared_ptr<const Surface> srf - = Surface::makeShared<PlaneSurface>(transptr, bounds); - - res.push_back(srf); - } - - return res; - } - - BOOST_AUTO_TEST_CASE(JsonLoader_load_test) - { - using json = nlohmann::json; - using namespace std::string_literals; - - variant_map map; - map["int"] = 42; - map["float"] = 42.42; - map["string"] = "hallo"s; - variant_map object({{"key", "value"s}, {"other", "otherval"s}}); - map["object"] = object; - variant_vector vector({true, "value"s}); - map["array"] = vector; - - std::string json_str = to_json(map, true); - - std::cout << json_str << std::endl; - - json json_parsed = json::parse(json_str); - - BOOST_CHECK_EQUAL(map.get<int>("int"), json_parsed["int"].get<int>()); - BOOST_CHECK_EQUAL(map.get<double>("float"), - json_parsed["float"].get<double>()); - BOOST_CHECK_EQUAL(map.get<std::string>("string"), - json_parsed["string"].get<std::string>()); - - BOOST_CHECK_EQUAL(object.get<std::string>("key"), - json_parsed["object"]["key"].get<std::string>()); - BOOST_CHECK_EQUAL(object.get<std::string>("other"), - json_parsed["object"]["other"].get<std::string>()); - - BOOST_CHECK_EQUAL(vector.get<bool>(0), json_parsed["array"][0].get<bool>()); - BOOST_CHECK_EQUAL(vector.get<std::string>(1), - json_parsed["array"][1].get<std::string>()); - - variant_data var_from_json = from_json(json_parsed); - std::cout << var_from_json << std::endl; - - variant_map map_from_json = boost::get<variant_map>(var_from_json); - - BOOST_CHECK_EQUAL(map.get<int>("int"), map_from_json.get<int>("int")); - BOOST_CHECK_EQUAL(map.get<double>("float"), - map_from_json.get<double>("float")); - BOOST_CHECK_EQUAL(map.get<std::string>("string"), - map_from_json.get<std::string>("string")); - - variant_map object_json = map_from_json.get<variant_map>("object"); - BOOST_CHECK_EQUAL(object.get<std::string>("key"), - object_json.get<std::string>("key")); - BOOST_CHECK_EQUAL(object.get<std::string>("other"), - object_json.get<std::string>("other")); - - variant_vector vector_json = map_from_json.get<variant_vector>("array"); - BOOST_CHECK_EQUAL(vector.get<bool>(0), vector_json.get<bool>(0)); - BOOST_CHECK_EQUAL(vector.get<std::string>(1), - vector_json.get<std::string>(1)); - } - - BOOST_AUTO_TEST_CASE(JsonLoader_float_int_discrimination) - { - using json = nlohmann::json; - double ref_value = 50.0; - variant_data input = ref_value; - std::string json_str = to_json(input); - std::cout << json_str << std::endl; - json json_parsed = json::parse(json_str); - variant_data output = from_json(json_parsed); - double value = boost::get<double>(output); - - BOOST_CHECK_EQUAL(ref_value, value); - } - - BOOST_AUTO_TEST_CASE(JsonLoader_layer_load_test) - { - using json = nlohmann::json; - using namespace std::string_literals; - - std::vector<std::shared_ptr<const Surface>> surfaces; - auto ringa = fullPhiTestSurfacesEC(30, 0, 0, 10); - surfaces.insert(surfaces.end(), ringa.begin(), ringa.end()); - auto ringb = fullPhiTestSurfacesEC(30, 0, 0, 15); - surfaces.insert(surfaces.end(), ringb.begin(), ringb.end()); - auto ringc = fullPhiTestSurfacesEC(30, 0, 0, 20); - surfaces.insert(surfaces.end(), ringc.begin(), ringc.end()); - - // ProtoLayer pl(surfaces); - auto sac = std::make_shared<const SurfaceArrayCreator>( - SurfaceArrayCreator::Config(), - Acts::getDefaultLogger("SurfaceArrayCreator", Acts::Logging::VERBOSE)); - LayerCreator::Config cfg; - cfg.surfaceArrayCreator = sac; - LayerCreator lc( - cfg, Acts::getDefaultLogger("LayerCreator", Acts::Logging::VERBOSE)); - - std::shared_ptr<DiscLayer> layer = std::dynamic_pointer_cast<DiscLayer>( - lc.discLayer(surfaces, equidistant, equidistant)); - - const variant_data var_layer = layer->toVariantData(); - std::cout << (*layer->surfaceArray()) << std::endl; - - // std::cout << var_layer << std::endl; - - std::string json_string = to_json(var_layer, true); - - // check if nlohmann::json agrees we produced valid JSON - auto json_parsed = json::parse(json_string); - - variant_data var_from_json = from_json(json_parsed); - // std::cout << var_from_json << std::endl; - - auto layer2 = std::dynamic_pointer_cast<DiscLayer>( - DiscLayer::create(var_from_json)); - std::cout << (*layer2->surfaceArray()) << std::endl; - - auto sa = layer->surfaceArray(); - auto sa2 = layer2->surfaceArray(); - - BOOST_CHECK(sa); - BOOST_CHECK(sa2); - - CHECK_CLOSE_OR_SMALL(sa->transform(), sa2->transform(), 1e-6, 1e-9); - - for (const auto& srfRef : surfaces) { - - Vector3D ctr = srfRef->binningPosition(binR); - - std::vector<const Surface*> bc1 = sa->at(ctr); - std::vector<const Surface*> bc2 = sa2->at(ctr); - - BOOST_CHECK_EQUAL(bc1.size(), bc2.size()); - - for (size_t i = 0; i < bc1.size(); i++) { - auto srf1 = bc1.at(i); - auto srf2 = bc2.at(i); - - // std::cout << srf1->transform().matrix() << std::endl << - // srf2->transform().matrix() << std::endl; - CHECK_CLOSE_OR_SMALL(srf1->transform(), srf2->transform(), 1e-6, 1e-9); - } - } - } - -} // namespace Test - -} // namespace Acts -- GitLab