Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrimitivesView3DTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PrimitivesView3DTests.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 
17 
18 #include <array>
19 #include <cmath>
20 #include <iostream>
21 #include <string>
22 #include <vector>
23 
24 #include "PrimitivesView3DBase.hpp"
26 
27 namespace Acts {
28 
29 namespace Test {
30 
31 BOOST_AUTO_TEST_SUITE(Visualization)
32 
33 
34 
35 
36 BOOST_AUTO_TEST_CASE(Visualization3DHelpers) {
37  // No correlation, fully symmetric
39  covariance << 4., 0., 0., 4.;
40  auto decops = Acts::EventDataView3D::decomposeCovariance(covariance);
41  BOOST_CHECK(decops[0] == 4.);
42  BOOST_CHECK(decops[1] == 4.);
43  BOOST_CHECK(decops[2] == 0.);
44 
45  // Fully positively correlated
46  covariance.setZero();
47  covariance << 4., 4., 4., 4.;
48  decops = Acts::EventDataView3D::decomposeCovariance(covariance);
49  BOOST_CHECK(decops[0] == 8.);
50  BOOST_CHECK(decops[1] == 0.);
51  CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001);
52 
53  // Fully negatively correlated
54  covariance.setZero();
55  covariance << 4., -4., -4., 4.;
56  decops = Acts::EventDataView3D::decomposeCovariance(covariance);
57  BOOST_CHECK(decops[0] == 8.);
58  BOOST_CHECK(decops[1] == 0.);
59  CHECK_CLOSE_ABS(decops[2], 3 * M_PI / 4, 0.0001);
60 
61  // Correlation coefficient 0.5 (off-diagonal: 3*2*0.5)
62  covariance.setZero();
63  covariance << 4., 2., 2., 4.;
64  decops = Acts::EventDataView3D::decomposeCovariance(covariance);
65  BOOST_CHECK(decops[0] == 6.);
66  BOOST_CHECK(decops[1] == 2.);
67  CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001);
68 
69  // Correlation coefficient -0.5 & different diagonal (off-diagonal: 3*2*0.5)
70  covariance.setZero();
71  covariance << 9., -3., -3, 4.;
72  decops = Acts::EventDataView3D::decomposeCovariance(covariance);
73  CHECK_CLOSE_ABS(decops[0], 10.4051, 0.0001);
74  CHECK_CLOSE_ABS(decops[1], 2.59488, 0.0001);
75  CHECK_CLOSE_ABS(decops[2], 2.70356, 0.0001);
76 }
77 
78 BOOST_AUTO_TEST_CASE(PrimitivesView3DObj) {
80  auto objTest = PrimitivesView3DTest::run(obj);
81  auto objErrors = testObjString(objTest);
82  BOOST_CHECK(objErrors.empty());
83  for (const auto& objerr : objErrors) {
84  std::cout << objerr << std::endl;
85  }
86 }
87 
88 BOOST_AUTO_TEST_CASE(PrimitivesView3DPly) {
90  auto plyTest = PrimitivesView3DTest::run(ply);
91  auto plyErrors = testPlyString(plyTest);
92  BOOST_CHECK(plyErrors.empty());
93  for (const auto& plyerr : plyErrors) {
94  std::cout << plyerr << std::endl;
95  }
96 }
97 
98 BOOST_AUTO_TEST_SUITE_END()
99 
100 } // namespace Test
101 } // namespace Acts