Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-29 07:55:36

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 using namespace Acts;
0021 
0022 namespace ActsTests {
0023 
0024 // Create a test context
0025 GeometryContext tgContext = GeometryContext();
0026 
0027 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0028 
0029 /// Unit test for creating compliant/non-compliant PerigeeSurface object
0030 BOOST_AUTO_TEST_CASE(PerigeeSurfaceConstruction) {
0031   /// Test default construction
0032   // default construction is deleted
0033 
0034   /// Constructor with Vector3
0035   Vector3 unitXYZ{1., 1., 1.};
0036   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0037   BOOST_CHECK_EQUAL(Surface::makeShared<PerigeeSurface>(unitXYZ)->type(),
0038                     Surface::Perigee);
0039 
0040   /// Constructor with transform
0041   Translation3 translation{0., 1., 2.};
0042   auto pTransform = Transform3(translation);
0043   BOOST_CHECK_EQUAL(Surface::makeShared<PerigeeSurface>(pTransform)->type(),
0044                     Surface::Perigee);
0045 
0046   /// Copy constructor
0047   auto copiedPerigeeSurface =
0048       Surface::makeShared<PerigeeSurface>(*perigeeSurfaceObject);
0049   BOOST_CHECK_EQUAL(copiedPerigeeSurface->type(), Surface::Perigee);
0050   BOOST_CHECK(*copiedPerigeeSurface == *perigeeSurfaceObject);
0051 
0052   /// Copied and transformed
0053   auto copiedTransformedPerigeeSurface = Surface::makeShared<PerigeeSurface>(
0054       tgContext, *perigeeSurfaceObject, pTransform);
0055   BOOST_CHECK_EQUAL(copiedTransformedPerigeeSurface->type(), Surface::Perigee);
0056 }
0057 
0058 /// Unit test for testing PerigeeSurface properties
0059 BOOST_AUTO_TEST_CASE(PerigeeSurfaceProperties) {
0060   /// Test clone method
0061   Vector3 unitXYZ{1., 1., 1.};
0062   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0063 
0064   /// Test type (redundant)
0065   BOOST_CHECK_EQUAL(perigeeSurfaceObject->type(), Surface::Perigee);
0066 
0067   /// Test name
0068   BOOST_CHECK_EQUAL(perigeeSurfaceObject->name(),
0069                     std::string("Acts::PerigeeSurface"));
0070 
0071   /// Test dump
0072   boost::test_tools::output_test_stream dumpOutput;
0073   dumpOutput << perigeeSurfaceObject->toStream(tgContext);
0074   BOOST_CHECK(
0075       dumpOutput.is_equal("Acts::PerigeeSurface:\n\
0076      Center position  (x, y, z) = (1.0000000, 1.0000000, 1.0000000)"));
0077 }
0078 
0079 BOOST_AUTO_TEST_CASE(EqualityOperators) {
0080   Vector3 unitXYZ{1., 1., 1.};
0081   Vector3 invalidPosition{0., 0., 0.};
0082   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0083   auto perigeeSurfaceObject2 = Surface::makeShared<PerigeeSurface>(unitXYZ);
0084   auto assignedPerigeeSurface =
0085       Surface::makeShared<PerigeeSurface>(invalidPosition);
0086 
0087   /// Test equality operator
0088   BOOST_CHECK(*perigeeSurfaceObject == *perigeeSurfaceObject2);
0089 
0090   /// Test assignment
0091   *assignedPerigeeSurface = *perigeeSurfaceObject;
0092 
0093   /// Test equality of assigned to original
0094   BOOST_CHECK(*assignedPerigeeSurface == *perigeeSurfaceObject);
0095 }
0096 
0097 BOOST_AUTO_TEST_SUITE_END()
0098 }  // namespace ActsTests