Back to home page

sPhenix code displayed by LXR

 
 

    


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

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/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0014 #include "Acts/Visualization/EventDataView3D.hpp"
0015 #include "Acts/Visualization/ObjVisualization3D.hpp"
0016 #include "Acts/Visualization/PlyVisualization3D.hpp"
0017 
0018 #include <array>
0019 #include <cmath>
0020 #include <iostream>
0021 #include <string>
0022 #include <vector>
0023 
0024 #include "PrimitivesView3DBase.hpp"
0025 #include "Visualization3DTester.hpp"
0026 
0027 namespace Acts {
0028 
0029 namespace Test {
0030 
0031 BOOST_AUTO_TEST_SUITE(Visualization)
0032 
0033 /// The tests in this section are regression tests only in order
0034 /// to catch any unexpected changes in the output format.
0035 ///
0036 BOOST_AUTO_TEST_CASE(Visualization3DHelpers) {
0037   // No correlation, fully symmetric
0038   SquareMatrix2 covariance;
0039   covariance << 4., 0., 0., 4.;
0040   auto decops = Acts::EventDataView3D::decomposeCovariance(covariance);
0041   BOOST_CHECK_EQUAL(decops[0], 4.);
0042   BOOST_CHECK_EQUAL(decops[1], 4.);
0043   BOOST_CHECK_EQUAL(decops[2], 0.);
0044 
0045   // Fully positively correlated
0046   covariance.setZero();
0047   covariance << 4., 4., 4., 4.;
0048   decops = Acts::EventDataView3D::decomposeCovariance(covariance);
0049   BOOST_CHECK_EQUAL(decops[0], 8.);
0050   BOOST_CHECK_EQUAL(decops[1], 0.);
0051   CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001);
0052 
0053   // Fully negatively correlated
0054   covariance.setZero();
0055   covariance << 4., -4., -4., 4.;
0056   decops = Acts::EventDataView3D::decomposeCovariance(covariance);
0057   BOOST_CHECK_EQUAL(decops[0], 8.);
0058   BOOST_CHECK_EQUAL(decops[1], 0.);
0059   CHECK_CLOSE_ABS(decops[2], 3 * M_PI / 4, 0.0001);
0060 
0061   // Correlation coefficient 0.5 (off-diagonal: 3*2*0.5)
0062   covariance.setZero();
0063   covariance << 4., 2., 2., 4.;
0064   decops = Acts::EventDataView3D::decomposeCovariance(covariance);
0065   BOOST_CHECK_EQUAL(decops[0], 6.);
0066   BOOST_CHECK_EQUAL(decops[1], 2.);
0067   CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001);
0068 
0069   // Correlation coefficient -0.5 & different diagonal (off-diagonal: 3*2*0.5)
0070   covariance.setZero();
0071   covariance << 9., -3., -3, 4.;
0072   decops = Acts::EventDataView3D::decomposeCovariance(covariance);
0073   CHECK_CLOSE_ABS(decops[0], 10.4051, 0.0001);
0074   CHECK_CLOSE_ABS(decops[1], 2.59488, 0.0001);
0075   CHECK_CLOSE_ABS(decops[2], 2.70356, 0.0001);
0076 }
0077 
0078 BOOST_AUTO_TEST_CASE(PrimitivesView3DObj) {
0079   ObjVisualization3D obj;
0080   auto objTest = PrimitivesView3DTest::run(obj);
0081   auto objErrors = testObjString(objTest);
0082   BOOST_CHECK(objErrors.empty());
0083   for (const auto& objerr : objErrors) {
0084     std::cout << objerr << std::endl;
0085   }
0086 }
0087 
0088 BOOST_AUTO_TEST_CASE(PrimitivesView3DPly) {
0089   PlyVisualization3D ply;
0090   auto plyTest = PrimitivesView3DTest::run(ply);
0091   auto plyErrors = testPlyString(plyTest);
0092   BOOST_CHECK(plyErrors.empty());
0093   for (const auto& plyerr : plyErrors) {
0094     std::cout << plyerr << std::endl;
0095   }
0096 }
0097 
0098 BOOST_AUTO_TEST_SUITE_END()
0099 
0100 }  // namespace Test
0101 }  // namespace Acts