Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-20 07:36:20

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/Algebra.hpp"
0012 #include "Acts/Geometry/Extent.hpp"
0013 #include "Acts/Utilities/BinningType.hpp"
0014 #include "ActsPlugins/Json/ExtentJsonConverter.hpp"
0015 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0016 
0017 #include <nlohmann/json.hpp>
0018 
0019 using namespace Acts;
0020 
0021 namespace ActsTests {
0022 
0023 BOOST_AUTO_TEST_SUITE(JsonSuite)
0024 
0025 BOOST_AUTO_TEST_CASE(ExtentRoundtripTests) {
0026   Extent e;
0027   e.set(AxisDirection::AxisR, 0, 200);
0028   e.set(AxisDirection::AxisZ, -50, 50);
0029 
0030   nlohmann::json j;
0031   j["extent"] = e;
0032 
0033   std::cout << j.dump(2) << std::endl;
0034 
0035   Extent eIn = j["extent"];
0036 
0037   CHECK_CLOSE_ABS(eIn.min(AxisDirection::AxisR), e.min(AxisDirection::AxisR),
0038                   10e-5);
0039   CHECK_CLOSE_ABS(eIn.max(AxisDirection::AxisR), e.max(AxisDirection::AxisR),
0040                   10e-5);
0041   CHECK_CLOSE_ABS(eIn.min(AxisDirection::AxisZ), e.min(AxisDirection::AxisZ),
0042                   10e-5);
0043   CHECK_CLOSE_ABS(eIn.max(AxisDirection::AxisZ), e.max(AxisDirection::AxisZ),
0044                   10e-5);
0045 }
0046 
0047 BOOST_AUTO_TEST_CASE(ExtentEnvelopeRoundtripTests) {
0048   ExtentEnvelope env;
0049   env[AxisDirection::AxisR] = {1., 2.};
0050   env[AxisDirection::AxisZ] = {3., 4.};
0051 
0052   nlohmann::json j;
0053   j["envelope"] = env;
0054 
0055   ExtentEnvelope envIn = j["envelope"];
0056 
0057   BOOST_CHECK_EQUAL(envIn[AxisDirection::AxisR][0],
0058                     env[AxisDirection::AxisR][0]);
0059   BOOST_CHECK_EQUAL(envIn[AxisDirection::AxisR][1],
0060                     env[AxisDirection::AxisR][1]);
0061   BOOST_CHECK_EQUAL(envIn[AxisDirection::AxisZ][0],
0062                     env[AxisDirection::AxisZ][0]);
0063   BOOST_CHECK_EQUAL(envIn[AxisDirection::AxisZ][1],
0064                     env[AxisDirection::AxisZ][1]);
0065   // Axes not set should remain zero
0066   BOOST_CHECK_EQUAL(envIn[AxisDirection::AxisX][0], 0.);
0067   BOOST_CHECK_EQUAL(envIn[AxisDirection::AxisX][1], 0.);
0068 }
0069 
0070 BOOST_AUTO_TEST_SUITE_END()
0071 
0072 }  // namespace ActsTests