ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrimitivesVisualizationTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PrimitivesVisualizationTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/tools/output_test_stream.hpp>
10 #include <boost/test/unit_test.hpp>
11 
14 #include "VisualizationTester.hpp"
15 
16 #include <fstream>
17 #include <iostream>
18 #include <sstream>
19 
20 namespace Acts {
21 
22 namespace Test {
23 
24 BOOST_AUTO_TEST_SUITE(Visualization)
25 
26 
27 
28 
29 BOOST_AUTO_TEST_CASE(VisualizationHelpers) {
30  // No correlation, fully summetric
31  ActsSymMatrixD<2> covariance;
32  covariance << 4., 0., 0., 4.;
33  auto decops = Acts::Visualization::decomposeCovariance(covariance);
34  BOOST_CHECK(decops[0] == 4.);
35  BOOST_CHECK(decops[1] == 4.);
36  BOOST_CHECK(decops[2] == 0.);
37 
38  // Fully positively correlated
39  covariance.setZero();
40  covariance << 4., 4., 4., 4.;
41  decops = Acts::Visualization::decomposeCovariance(covariance);
42  BOOST_CHECK(decops[0] == 8.);
43  BOOST_CHECK(decops[1] == 0.);
44  CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001);
45 
46  // Fully negatively correlated
47  covariance.setZero();
48  covariance << 4., -4., -4., 4.;
49  decops = Acts::Visualization::decomposeCovariance(covariance);
50  BOOST_CHECK(decops[0] == 8.);
51  BOOST_CHECK(decops[1] == 0.);
52  CHECK_CLOSE_ABS(decops[2], 3 * M_PI / 4, 0.0001);
53 
54  // Correlation coefficient 0.5 (off-diagonal: 3*2*0.5)
55  covariance.setZero();
56  covariance << 4., 2., 2., 4.;
57  decops = Acts::Visualization::decomposeCovariance(covariance);
58  BOOST_CHECK(decops[0] == 6.);
59  BOOST_CHECK(decops[1] == 2.);
60  CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001);
61 
62  // Correlation coefficient -0.5 & different diagonal (off-diagonal: 3*2*0.5)
63  covariance.setZero();
64  covariance << 9., -3., -3, 4.;
65  decops = Acts::Visualization::decomposeCovariance(covariance);
66  CHECK_CLOSE_ABS(decops[0], 10.4051, 0.0001);
67  CHECK_CLOSE_ABS(decops[1], 2.59488, 0.0001);
68  CHECK_CLOSE_ABS(decops[2], 2.70356, 0.0001);
69 }
70 
71 BOOST_AUTO_TEST_CASE(PrimitivesVisualizationObj) {
72  ObjVisualization obj;
73  auto objTest = PrimitivesVisualization::test(obj);
74  auto objErrors = testObjString(objTest);
75  BOOST_CHECK(objErrors.size() == 0);
76  for (auto objerr : objErrors) {
77  std::cout << objerr << std::endl;
78  }
79 }
80 
81 BOOST_AUTO_TEST_CASE(PrimitivesVisualizationPly) {
82  PlyVisualization ply;
83  auto plyTest = PrimitivesVisualization::test(ply);
84  auto plyErrors = testPlyString(plyTest);
85  BOOST_CHECK(plyErrors.size() == 0);
86  for (auto plyerr : plyErrors) {
87  std::cout << plyerr << std::endl;
88  }
89 }
90 
91 BOOST_AUTO_TEST_SUITE_END()
92 
93 } // namespace Test
94 } // namespace Acts