ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MaterialTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MaterialTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 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/unit_test.hpp>
10 
11 #include <limits>
12 
16 #include "Acts/Utilities/Units.hpp"
17 
18 using namespace Acts::UnitLiterals;
19 
20 static constexpr auto eps = 2 * std::numeric_limits<float>::epsilon();
21 // manually calculated derived values for silicon
22 static constexpr float SiNe = 1.160954941 / 1_cm3;
23 static constexpr float SiI = 172.042290036_eV;
24 
25 BOOST_AUTO_TEST_SUITE(material)
26 
27 BOOST_AUTO_TEST_CASE(construct_vacuum) {
28  // default constructor builds invalid material a.k.a. vacuum
29  Acts::Material vacuum;
30  BOOST_TEST(!vacuum);
31 }
32 
33 BOOST_AUTO_TEST_CASE(construct_something) {
34  // anything with non-zero Ar is a valid material
35  Acts::Material notVacuum(1, 2, 3, 4, 5);
36  BOOST_TEST(!!notVacuum);
37 }
38 
41 
42  // check values w/ different units if possible
43  CHECK_CLOSE_REL(silicon.X0(), 93.70_mm, eps);
44  CHECK_CLOSE_REL(silicon.X0(), 9.370_cm, eps);
45  CHECK_CLOSE_REL(silicon.X0(), 0.09370_m, eps);
46  CHECK_CLOSE_REL(silicon.L0(), 465.2_mm, eps);
47  CHECK_CLOSE_REL(silicon.L0(), 46.52_cm, eps);
48  CHECK_CLOSE_REL(silicon.L0(), 0.4652_m, eps);
49  CHECK_CLOSE_REL(silicon.Ar(), 28.0855, eps);
50  CHECK_CLOSE_REL(silicon.Z(), 14.0, eps);
51  CHECK_CLOSE_REL(silicon.massDensity(), 2.329_g / 1_cm3, eps);
52  CHECK_CLOSE_REL(silicon.massDensity(), 0.002329_kg / 1_cm3, eps);
53  CHECK_CLOSE_REL(silicon.massDensity(), 0.002329_g / 1_mm3, eps);
54  // check derived values
57 }
58 
59 // encode values as classification vector
67  return values;
68 }
69 
70 BOOST_AUTO_TEST_CASE(classification_numbers) {
71  const auto numbers = makeSiClassificationNumbers();
72  Acts::Material fromNumbers(numbers);
74 
75  BOOST_TEST(fromNumbers == manual);
76  CHECK_CLOSE_REL(fromNumbers.classificationNumbers(), numbers, eps);
77  CHECK_CLOSE_REL(manual.classificationNumbers(), numbers, eps);
78 }
79 
80 BOOST_AUTO_TEST_SUITE_END()