Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:51

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Surfaces/PerigeeSurface.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 
0017 #include <memory>
0018 #include <string>
0019 
0020 namespace Acts::Test {
0021 
0022 // Create a test context
0023 GeometryContext tgContext = GeometryContext();
0024 
0025 BOOST_AUTO_TEST_SUITE(PerigeeSurfaces)
0026 /// Unit test for creating compliant/non-compliant PerigeeSurface object
0027 BOOST_AUTO_TEST_CASE(PerigeeSurfaceConstruction) {
0028   /// Test default construction
0029   // default construction is deleted
0030 
0031   /// Constructor with Vector3
0032   Vector3 unitXYZ{1., 1., 1.};
0033   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0034   BOOST_CHECK_EQUAL(Surface::makeShared<PerigeeSurface>(unitXYZ)->type(),
0035                     Surface::Perigee);
0036 
0037   /// Constructor with transform
0038   Translation3 translation{0., 1., 2.};
0039   auto pTransform = Transform3(translation);
0040   BOOST_CHECK_EQUAL(Surface::makeShared<PerigeeSurface>(pTransform)->type(),
0041                     Surface::Perigee);
0042 
0043   /// Copy constructor
0044   auto copiedPerigeeSurface =
0045       Surface::makeShared<PerigeeSurface>(*perigeeSurfaceObject);
0046   BOOST_CHECK_EQUAL(copiedPerigeeSurface->type(), Surface::Perigee);
0047   BOOST_CHECK(*copiedPerigeeSurface == *perigeeSurfaceObject);
0048 
0049   /// Copied and transformed
0050   auto copiedTransformedPerigeeSurface = Surface::makeShared<PerigeeSurface>(
0051       tgContext, *perigeeSurfaceObject, pTransform);
0052   BOOST_CHECK_EQUAL(copiedTransformedPerigeeSurface->type(), Surface::Perigee);
0053 }
0054 
0055 /// Unit test for testing PerigeeSurface properties
0056 BOOST_AUTO_TEST_CASE(PerigeeSurfaceProperties) {
0057   /// Test clone method
0058   Vector3 unitXYZ{1., 1., 1.};
0059   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0060 
0061   /// Test type (redundant)
0062   BOOST_CHECK_EQUAL(perigeeSurfaceObject->type(), Surface::Perigee);
0063 
0064   /// Test name
0065   BOOST_CHECK_EQUAL(perigeeSurfaceObject->name(),
0066                     std::string("Acts::PerigeeSurface"));
0067 
0068   /// Test dump
0069   boost::test_tools::output_test_stream dumpOutput;
0070   dumpOutput << perigeeSurfaceObject->toStream(tgContext);
0071   BOOST_CHECK(
0072       dumpOutput.is_equal("Acts::PerigeeSurface:\n\
0073      Center position  (x, y, z) = (1.0000000, 1.0000000, 1.0000000)"));
0074 }
0075 
0076 BOOST_AUTO_TEST_CASE(EqualityOperators) {
0077   Vector3 unitXYZ{1., 1., 1.};
0078   Vector3 invalidPosition{0., 0., 0.};
0079   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0080   auto perigeeSurfaceObject2 = Surface::makeShared<PerigeeSurface>(unitXYZ);
0081   auto assignedPerigeeSurface =
0082       Surface::makeShared<PerigeeSurface>(invalidPosition);
0083 
0084   /// Test equality operator
0085   BOOST_CHECK(*perigeeSurfaceObject == *perigeeSurfaceObject2);
0086 
0087   /// Test assignment
0088   *assignedPerigeeSurface = *perigeeSurfaceObject;
0089 
0090   /// Test equality of assigned to original
0091   BOOST_CHECK(*assignedPerigeeSurface == *perigeeSurfaceObject);
0092 }
0093 
0094 BOOST_AUTO_TEST_SUITE_END()
0095 }  // namespace Acts::Test