From ec6f8aca7a7e3ef47f85cef172995a8eb54e4f63 Mon Sep 17 00:00:00 2001 From: Paul Gessinger <paul.gessinger@cern.ch> Date: Thu, 20 Dec 2018 09:33:37 +0100 Subject: [PATCH] Fixes after another rebase --- .../Acts/Tools/CuboidVolumeBuilder.hpp | 22 ++++---- Tests/Core/Layers/ConeLayerTests.cpp | 12 ++-- Tests/Core/Layers/CylinderLayerTests.cpp | 13 ++--- Tests/Core/Layers/DiscLayerTests.cpp | 6 +- Tests/Core/Layers/LayerTests.cpp | 6 +- Tests/Core/Layers/PlaneLayerTests.cpp | 6 +- Tests/Core/Tools/CMakeLists.txt | 2 +- Tests/Core/Tools/CuboidVolumeBuilderTests.cpp | 55 ++----------------- 8 files changed, 32 insertions(+), 90 deletions(-) diff --git a/Core/include/Acts/Tools/CuboidVolumeBuilder.hpp b/Core/include/Acts/Tools/CuboidVolumeBuilder.hpp index 1dee497a0..05c082e3e 100644 --- a/Core/include/Acts/Tools/CuboidVolumeBuilder.hpp +++ b/Core/include/Acts/Tools/CuboidVolumeBuilder.hpp @@ -174,7 +174,7 @@ private: std::shared_ptr<const PlaneSurface> CuboidVolumeBuilder::buildSurface(const SurfaceConfig& cfg) const { - PlaneSurface* surface; + std::shared_ptr<PlaneSurface> surface; // Build transformation Transform3D trafo(Transform3D::Identity() * cfg.rotation); @@ -182,17 +182,18 @@ CuboidVolumeBuilder::buildSurface(const SurfaceConfig& cfg) const // Create and store surface if (cfg.detElementConstructor) { - surface = new PlaneSurface(cfg.rBounds, - *(cfg.detElementConstructor(std::make_tuple( - std::make_shared<const Transform3D>(trafo), - cfg.rBounds, - cfg.thickness)))); + surface = Surface::makeShared<PlaneSurface>( + cfg.rBounds, + *(cfg.detElementConstructor( + std::make_tuple(std::make_shared<const Transform3D>(trafo), + cfg.rBounds, + cfg.thickness)))); } else { - surface = new PlaneSurface(std::make_shared<const Transform3D>(trafo), - cfg.rBounds); + surface = Surface::makeShared<PlaneSurface>( + std::make_shared<const Transform3D>(trafo), cfg.rBounds); } surface->setAssociatedMaterial(cfg.surMat); - return std::shared_ptr<const PlaneSurface>(surface); + return surface; } std::shared_ptr<const Layer> @@ -207,8 +208,7 @@ CuboidVolumeBuilder::buildLayer(LayerConfig& cfg) const trafo.translation() = cfg.surfaceCfg.position; LayerCreator::Config lCfg; - lCfg.surfaceArrayCreator - = std::shared_ptr<const SurfaceArrayCreator>(new SurfaceArrayCreator()); + lCfg.surfaceArrayCreator = std::make_shared<const SurfaceArrayCreator>(); LayerCreator layerCreator(lCfg); return layerCreator.planeLayer({cfg.surface}, diff --git a/Tests/Core/Layers/ConeLayerTests.cpp b/Tests/Core/Layers/ConeLayerTests.cpp index c7f9e8898..60fd53550 100644 --- a/Tests/Core/Layers/ConeLayerTests.cpp +++ b/Tests/Core/Layers/ConeLayerTests.cpp @@ -57,10 +57,8 @@ namespace Test { /// Constructor with transform pointer auto pNullTransform = std::make_shared<const Transform3D>(); const std::vector<std::shared_ptr<const Surface>> aSurfaces{ - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds)), - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds))}; + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds), + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds)}; const double thickness(1.0); auto pConeLayerFromSurfaces = ConeLayer::create(pTransform, pCone, nullptr); @@ -100,10 +98,8 @@ namespace Test { auto pNullTransform = std::make_shared<const Transform3D>(); auto pCone = std::make_shared<const ConeBounds>(alpha, symmetric); const std::vector<std::shared_ptr<const Surface>> aSurfaces{ - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds)), - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds))}; + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds), + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds)}; // const double thickness(1.0); auto pConeLayerFromSurfaces = ConeLayer::create(pTransform, pCone, nullptr); diff --git a/Tests/Core/Layers/CylinderLayerTests.cpp b/Tests/Core/Layers/CylinderLayerTests.cpp index 806742ef2..db05a7f69 100644 --- a/Tests/Core/Layers/CylinderLayerTests.cpp +++ b/Tests/Core/Layers/CylinderLayerTests.cpp @@ -17,14 +17,13 @@ #include <boost/test/output_test_stream.hpp> // leave blank line -//#include <limits> -#include "Acts/Layers/CylinderLayer.hpp" -#include "Acts/Surfaces/CylinderBounds.hpp" -//#include "Acts/Utilities/Definitions.hpp" #include "Acts/EventData/SingleTrackParameters.hpp" +#include "Acts/Layers/CylinderLayer.hpp" #include "Acts/Layers/GenericApproachDescriptor.hpp" +#include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Tools/SurfaceArrayCreator.hpp" +#include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/VariantData.hpp" #include "Acts/Volumes/CuboidVolumeBounds.hpp" #include "LayerStub.hpp" @@ -56,10 +55,8 @@ namespace Test { /// Constructor with transform pointer auto pNullTransform = std::make_shared<const Transform3D>(); const std::vector<std::shared_ptr<const Surface>> aSurfaces{ - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds)), - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds))}; + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds), + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds)}; const double thickness(1.0); auto pCylinderLayerFromSurfaces = CylinderLayer::create(pTransform, pCylinder, nullptr); diff --git a/Tests/Core/Layers/DiscLayerTests.cpp b/Tests/Core/Layers/DiscLayerTests.cpp index 4a85654ff..f7fb41ce0 100644 --- a/Tests/Core/Layers/DiscLayerTests.cpp +++ b/Tests/Core/Layers/DiscLayerTests.cpp @@ -57,10 +57,8 @@ namespace Test { /// Constructor with transform pointer auto pNullTransform = std::make_shared<const Transform3D>(); const std::vector<std::shared_ptr<const Surface>> aSurfaces{ - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds)), - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds))}; + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds), + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds)}; const double thickness(1.0); auto pDiscLayerFromSurfaces = DiscLayer::create(pTransform, pDisc, nullptr); diff --git a/Tests/Core/Layers/LayerTests.cpp b/Tests/Core/Layers/LayerTests.cpp index 48f7373bc..4b13a1229 100644 --- a/Tests/Core/Layers/LayerTests.cpp +++ b/Tests/Core/Layers/LayerTests.cpp @@ -71,10 +71,8 @@ namespace Test { /// Constructor with transform pointer auto pNullTransform = std::make_shared<const Transform3D>(); const std::vector<std::shared_ptr<const Surface>> aSurfaces{ - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds)), - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds))}; + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds), + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds)}; std::unique_ptr<ApproachDescriptor> ad( new GenericApproachDescriptor(aSurfaces)); auto adPtr = ad.get(); diff --git a/Tests/Core/Layers/PlaneLayerTests.cpp b/Tests/Core/Layers/PlaneLayerTests.cpp index eda425320..26cc59373 100644 --- a/Tests/Core/Layers/PlaneLayerTests.cpp +++ b/Tests/Core/Layers/PlaneLayerTests.cpp @@ -55,10 +55,8 @@ namespace Test { /// Constructor with transform pointer auto pNullTransform = std::make_shared<const Transform3D>(); const std::vector<std::shared_ptr<const Surface>> aSurfaces{ - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds)), - std::shared_ptr<const Surface>( - new PlaneSurface(pNullTransform, rBounds))}; + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds), + Surface::makeShared<PlaneSurface>(pNullTransform, rBounds)}; const double thickness(1.0); SurfaceArrayCreator sac; size_t binsX(2), binsY(4); diff --git a/Tests/Core/Tools/CMakeLists.txt b/Tests/Core/Tools/CMakeLists.txt index 53fc39b9e..0cd5bfad0 100644 --- a/Tests/Core/Tools/CMakeLists.txt +++ b/Tests/Core/Tools/CMakeLists.txt @@ -19,6 +19,6 @@ add_test (NAME SimpleGeometryUnitTest COMMAND SimpleGeometryTests) acts_add_test_to_cdash_project (PROJECT ACore TEST SimpleGeometryUnitTest TARGETS SimpleGeometryTests) add_executable (CuboidVolumeBuilderTests CuboidVolumeBuilderTests.cpp) -target_link_libraries (CuboidVolumeBuilderTests PRIVATE ActsCore) +target_link_libraries (CuboidVolumeBuilderTests PRIVATE ActsCore ActsTestsCommonHelpers) add_test (NAME CuboidVolumeBuilderUnitTest COMMAND CuboidVolumeBuilderTests) acts_add_test_to_cdash_project (PROJECT ACore TEST CuboidVolumeBuilderUnitTest TARGETS CuboidVolumeBuilderTests) diff --git a/Tests/Core/Tools/CuboidVolumeBuilderTests.cpp b/Tests/Core/Tools/CuboidVolumeBuilderTests.cpp index 801da3f78..220a70f00 100644 --- a/Tests/Core/Tools/CuboidVolumeBuilderTests.cpp +++ b/Tests/Core/Tools/CuboidVolumeBuilderTests.cpp @@ -12,6 +12,7 @@ #include <vector> #include "Acts/Material/Material.hpp" +#include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Tools/CuboidVolumeBuilder.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/Units.hpp" @@ -19,55 +20,6 @@ namespace Acts { namespace Test { - /// - /// @brief Stub implementation of the detector element - /// - class DetElem : public DetectorElementBase - { - public: - /// @brief Constructor - /// - /// @param [in] data Data container that carries information about - /// transformation, rectangle bounds and thickness of the detector element - DetElem(std::tuple<std::shared_ptr<const Transform3D>, - std::shared_ptr<const RectangleBounds>, - double> data) - : DetectorElementBase() - , m_trafo(std::get<0>(data)) - , m_surface(new PlaneSurface(std::get<1>(data), *this)) - , m_thickness(std::get<2>(data)) - { - } - - /// @brief Getter of the transformation - virtual const Transform3D& - transform() const - { - return *m_trafo; - } - - /// @brief Getter of the surface - virtual const Surface& - surface() const - { - return *m_surface; - } - - /// @brief Getter of the thickness - virtual double - thickness() const - { - return m_thickness; - } - - // Pointer to the transformation - std::shared_ptr<const Transform3D> m_trafo; - // Surface related to the detector element - Surface const* m_surface; - // Thickness of the detector element - double m_thickness; - }; - BOOST_AUTO_TEST_CASE(CuboidVolumeBuilderTest) { @@ -106,7 +58,10 @@ namespace Test { cfg.detElementConstructor = [](std::tuple<std::shared_ptr<const Transform3D>, std::shared_ptr<const RectangleBounds>, - double> data) { return new DetElem(data); }; + double> data) { + return new DetectorElementStub( + std::get<0>(data), std::get<1>(data), std::get<2>(data)); + }; surfaceConfig.push_back(cfg); } -- GitLab