Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 08:21:11

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 <iomanip>
0018 #include <memory>
0019 #include <sstream>
0020 #include <string>
0021 
0022 using namespace Acts;
0023 
0024 namespace ActsTests {
0025 
0026 // Create a test context
0027 GeometryContext tgContext = GeometryContext::dangerouslyDefaultConstruct();
0028 
0029 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0030 
0031 /// Unit test for creating compliant/non-compliant PerigeeSurface object
0032 BOOST_AUTO_TEST_CASE(PerigeeSurfaceConstruction) {
0033   /// Test default construction
0034   // default construction is deleted
0035 
0036   /// Constructor with Vector3
0037   Vector3 unitXYZ{1., 1., 1.};
0038   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0039   BOOST_CHECK_EQUAL(Surface::makeShared<PerigeeSurface>(unitXYZ)->type(),
0040                     Surface::Perigee);
0041 
0042   /// Constructor with transform
0043   Translation3 translation{0., 1., 2.};
0044   auto pTransform = Transform3(translation);
0045   BOOST_CHECK_EQUAL(Surface::makeShared<PerigeeSurface>(pTransform)->type(),
0046                     Surface::Perigee);
0047 
0048   /// Copy constructor
0049   auto copiedPerigeeSurface =
0050       Surface::makeShared<PerigeeSurface>(*perigeeSurfaceObject);
0051   BOOST_CHECK_EQUAL(copiedPerigeeSurface->type(), Surface::Perigee);
0052   BOOST_CHECK(*copiedPerigeeSurface == *perigeeSurfaceObject);
0053 
0054   /// Copied and transformed
0055   auto copiedTransformedPerigeeSurface = Surface::makeShared<PerigeeSurface>(
0056       tgContext, *perigeeSurfaceObject, pTransform);
0057   BOOST_CHECK_EQUAL(copiedTransformedPerigeeSurface->type(), Surface::Perigee);
0058 }
0059 
0060 /// Unit test for testing PerigeeSurface properties
0061 BOOST_AUTO_TEST_CASE(PerigeeSurfaceProperties) {
0062   /// Test clone method
0063   Vector3 unitXYZ{1., 1., 1.};
0064   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0065 
0066   /// Test type (redundant)
0067   BOOST_CHECK_EQUAL(perigeeSurfaceObject->type(), Surface::Perigee);
0068 
0069   /// Test name
0070   BOOST_CHECK_EQUAL(perigeeSurfaceObject->name(),
0071                     std::string("Acts::PerigeeSurface"));
0072 
0073   /// Test dump
0074   boost::test_tools::output_test_stream dumpOutput;
0075   dumpOutput << perigeeSurfaceObject->toStream(tgContext);
0076   BOOST_CHECK(
0077       dumpOutput.is_equal("Acts::PerigeeSurface:\n\
0078      Center position  (x, y, z) = (1.0000000, 1.0000000, 1.0000000)"));
0079 }
0080 
0081 BOOST_AUTO_TEST_CASE(PerigeeSurfaceToStreamPreservesStreamState) {
0082   std::ostringstream stream;
0083   stream << std::scientific << std::showpos << std::setfill('#')
0084          << std::setprecision(3);
0085   stream.width(17);
0086 
0087   const auto flags = stream.flags();
0088   const auto precision = stream.precision();
0089   const auto width = stream.width();
0090   const auto fill = stream.fill();
0091 
0092   auto perigeeSurface =
0093       Surface::makeShared<PerigeeSurface>(Vector3{1., 1., 1.});
0094   stream << perigeeSurface->toStream(tgContext);
0095 
0096   BOOST_CHECK(stream.flags() == flags);
0097   BOOST_CHECK_EQUAL(stream.precision(), precision);
0098   BOOST_CHECK_EQUAL(stream.width(), width);
0099   BOOST_CHECK_EQUAL(stream.fill(), fill);
0100 }
0101 
0102 BOOST_AUTO_TEST_CASE(EqualityOperators) {
0103   Vector3 unitXYZ{1., 1., 1.};
0104   Vector3 invalidPosition{0., 0., 0.};
0105   auto perigeeSurfaceObject = Surface::makeShared<PerigeeSurface>(unitXYZ);
0106   auto perigeeSurfaceObject2 = Surface::makeShared<PerigeeSurface>(unitXYZ);
0107   auto assignedPerigeeSurface =
0108       Surface::makeShared<PerigeeSurface>(invalidPosition);
0109 
0110   /// Test equality operator
0111   BOOST_CHECK(*perigeeSurfaceObject == *perigeeSurfaceObject2);
0112 
0113   /// Test assignment
0114   *assignedPerigeeSurface = *perigeeSurfaceObject;
0115 
0116   /// Test equality of assigned to original
0117   BOOST_CHECK(*assignedPerigeeSurface == *perigeeSurfaceObject);
0118 }
0119 
0120 BOOST_AUTO_TEST_SUITE_END()
0121 }  // namespace ActsTests