EIC 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 
13 
14 #include <fstream>
15 #include <iostream>
16 #include <sstream>
17 
18 #include "PrimitivesView3DBase.hpp"
20 
21 namespace Acts {
22 
23 namespace Test {
24 
25 BOOST_AUTO_TEST_SUITE(Visualization)
26 
27 
28 
29 
30 BOOST_AUTO_TEST_CASE(Visualization3DHelpers) {
31  // No correlation, fully summetric
32  SymMatrix2D covariance;
33  covariance << 4., 0., 0., 4.;
34  auto decops = Acts::EventDataView3D::decomposeCovariance(covariance);
35  BOOST_CHECK(decops[0] == 4.);
36  BOOST_CHECK(decops[1] == 4.);
37  BOOST_CHECK(decops[2] == 0.);
38 
39  // Fully positively correlated
40  covariance.setZero();
41  covariance << 4., 4., 4., 4.;
42  decops = Acts::EventDataView3D::decomposeCovariance(covariance);
43  BOOST_CHECK(decops[0] == 8.);
44  BOOST_CHECK(decops[1] == 0.);
45  CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001);
46 
47  // Fully negatively correlated
48  covariance.setZero();
49  covariance << 4., -4., -4., 4.;
50  decops = Acts::EventDataView3D::decomposeCovariance(covariance);
51  BOOST_CHECK(decops[0] == 8.);
52  BOOST_CHECK(decops[1] == 0.);
53  CHECK_CLOSE_ABS(decops[2], 3 * M_PI / 4, 0.0001);
54 
55  // Correlation coefficient 0.5 (off-diagonal: 3*2*0.5)
56  covariance.setZero();
57  covariance << 4., 2., 2., 4.;
58  decops = Acts::EventDataView3D::decomposeCovariance(covariance);
59  BOOST_CHECK(decops[0] == 6.);
60  BOOST_CHECK(decops[1] == 2.);
61  CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001);
62 
63  // Correlation coefficient -0.5 & different diagonal (off-diagonal: 3*2*0.5)
64  covariance.setZero();
65  covariance << 9., -3., -3, 4.;
66  decops = Acts::EventDataView3D::decomposeCovariance(covariance);
67  CHECK_CLOSE_ABS(decops[0], 10.4051, 0.0001);
68  CHECK_CLOSE_ABS(decops[1], 2.59488, 0.0001);
69  CHECK_CLOSE_ABS(decops[2], 2.70356, 0.0001);
70 }
71 
72 BOOST_AUTO_TEST_CASE(PrimitivesView3DObj) {
74  auto objTest = PrimitivesView3DTest::run(obj);
75  auto objErrors = testObjString(objTest);
76  BOOST_CHECK(objErrors.size() == 0);
77  for (auto objerr : objErrors) {
78  std::cout << objerr << std::endl;
79  }
80 }
81 
82 BOOST_AUTO_TEST_CASE(PrimitivesView3DPly) {
84  auto plyTest = PrimitivesView3DTest::run(ply);
85  auto plyErrors = testPlyString(plyTest);
86  BOOST_CHECK(plyErrors.size() == 0);
87  for (auto plyerr : plyErrors) {
88  std::cout << plyerr << std::endl;
89  }
90 }
91 
92 BOOST_AUTO_TEST_SUITE_END()
93 
94 } // namespace Test
95 } // namespace Acts