Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:19

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020 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 http://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   TestSourceLink ts;
0026   Acts::Vector2 stddev(0.01, 0.1);
0027   Acts::SquareMatrix2 cov = stddev.cwiseProduct(stddev).asDiagonal();
0028   TestSourceLink l1(Acts::eBoundLoc0, 0.1, cov(0, 0),
0029                     Acts::GeometryIdentifier(0x999), 0);
0030   TestSourceLink l2(l1);
0031 
0032   BOOST_CHECK(l1 == l2);     // testing the ==
0033   BOOST_CHECK(!(l1 != l2));  // testing the !=
0034   std::ostringstream str;
0035   str << l1;
0036 }
0037 
0038 struct MySourceLink {
0039   Acts::GeometryIdentifier m_geometryId;
0040 
0041   Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
0042 };
0043 
0044 BOOST_AUTO_TEST_CASE(Construct) {
0045   MySourceLink msl;
0046   msl.m_geometryId.setSensitive(42);
0047   {
0048     Acts::SourceLink sl{msl};
0049     BOOST_CHECK_EQUAL(sl.get<MySourceLink>().geometryId(), msl.geometryId());
0050     BOOST_CHECK_THROW(sl.get<int>(), std::bad_any_cast);
0051   }
0052 }
0053 
0054 BOOST_AUTO_TEST_SUITE_END()