Back to home page

EIC code displayed by LXR

 
 

    


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

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/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/EventData/SourceLink.hpp"
0013 #include "Acts/EventData/detail/TestSourceLink.hpp"
0014 #include "Acts/Geometry/GeometryIdentifier.hpp"
0015 
0016 #include <any>
0017 #include <sstream>
0018 
0019 using namespace Acts::UnitLiterals;
0020 
0021 BOOST_AUTO_TEST_SUITE(EventDataSourceLink)
0022 
0023 BOOST_AUTO_TEST_CASE(TestSourceLinkCoverage) {
0024   using Acts::detail::Test::TestSourceLink;
0025 
0026   TestSourceLink ts;
0027   Acts::Vector2 stddev(0.01, 0.1);
0028   Acts::SquareMatrix2 cov = stddev.cwiseProduct(stddev).asDiagonal();
0029   TestSourceLink l1(Acts::eBoundLoc0, 0.1, cov(0, 0),
0030                     Acts::GeometryIdentifier(0x999), 0);
0031   TestSourceLink l2(l1);
0032 
0033   BOOST_CHECK(l1 == l2);     // testing the ==
0034   BOOST_CHECK(!(l1 != l2));  // testing the !=
0035   std::ostringstream str;
0036   str << l1;
0037 }
0038 
0039 struct MySourceLink {
0040   Acts::GeometryIdentifier m_geometryId;
0041 
0042   Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
0043 };
0044 
0045 BOOST_AUTO_TEST_CASE(Construct) {
0046   MySourceLink msl;
0047   msl.m_geometryId.setSensitive(42);
0048   {
0049     Acts::SourceLink sl{msl};
0050     BOOST_CHECK_EQUAL(sl.get<MySourceLink>().geometryId(), msl.geometryId());
0051     BOOST_CHECK_THROW(sl.get<int>(), std::bad_any_cast);
0052   }
0053 }
0054 
0055 BOOST_AUTO_TEST_CASE(Reassign) {
0056   int value = 5;
0057   Acts::SourceLink sl{value};
0058 
0059   BOOST_CHECK_EQUAL(sl.get<int>(), value);
0060   BOOST_CHECK_THROW(sl.get<double>(), std::bad_any_cast);
0061 
0062   double otherValue = 42.42;
0063 
0064   // this changes the stored type
0065   sl = Acts::SourceLink{otherValue};
0066   BOOST_CHECK_EQUAL(sl.get<double>(), otherValue);
0067   BOOST_CHECK_THROW(sl.get<int>(), std::bad_any_cast);
0068 }
0069 
0070 BOOST_AUTO_TEST_SUITE_END()