ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AccumulatedVolumeMaterialTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AccumulatedVolumeMaterialTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 
14 
15 namespace Acts {
16 namespace Test {
17 
18 BOOST_AUTO_TEST_SUITE(accumulated_material)
19 
22 
23  // averaging over nothing is vacuum
24  BOOST_TEST(avm.average() == Material());
25 
26  // averaging over vacuum is still vacuum
28  BOOST_TEST(avm.average() == Material());
29 }
30 
31 BOOST_AUTO_TEST_CASE(single_material) {
32  Material mat(1., 2., 3., 4., 5.);
33  MaterialProperties matprop(mat, 1);
35  // mean of a single material should be the same material again for a thickness
36  // of 1
37  avm.accumulate(matprop);
38  {
39  auto result = avm.average();
40  CHECK_CLOSE_REL(result.X0(), mat.X0(), 1e-4);
41  CHECK_CLOSE_REL(result.L0(), mat.L0(), 1e-4);
42  CHECK_CLOSE_REL(result.Ar(), mat.Ar(), 1e-4);
43  CHECK_CLOSE_REL(result.Z(), mat.Z(), 1e-4);
44  CHECK_CLOSE_REL(result.massDensity(), mat.massDensity(), 1e-4);
45  }
46  // adding a vacuum step changes the average
48  {
49  auto result = avm.average();
50  // less scattering in vacuum, larger radiation length
51  CHECK_CLOSE_REL(result.X0(), 2 * mat.X0(), 1e-4);
52  CHECK_CLOSE_REL(result.L0(), 2 * mat.L0(), 1e-4);
53  // less material, lower density
54  CHECK_CLOSE_REL(result.Ar(), 0.5 * mat.Ar(), 1e-4);
55  CHECK_CLOSE_REL(result.Z(), 0.5 * mat.Z(), 1e-4);
56  CHECK_CLOSE_REL(result.massDensity(), 0.5 * mat.massDensity(), 1e-4);
57  }
58 }
59 
60 BOOST_AUTO_TEST_CASE(two_materials) {
61  Material mat1(1., 2., 3., 4., 5.);
62  Material mat2(6., 7., 8., 9., 10.);
63 
64  MaterialProperties matprop1(mat1, 1);
65  MaterialProperties matprop2(mat2, 1);
66 
68  avm.accumulate(matprop1);
69  avm.accumulate(matprop2);
70  auto result = avm.average();
71  CHECK_CLOSE_REL(result.X0(), 2. / (1. / 1. + 1. / 6.), 1e-4);
72  CHECK_CLOSE_REL(result.L0(), 2. / (1. / 2. + 1. / 7.), 1e-4);
73  CHECK_CLOSE_REL(result.Ar(), 0.5 * (3. + 8.), 1e-4);
74  CHECK_CLOSE_REL(result.Z(), 0.5 * (4. + 9.), 1e-4);
75  CHECK_CLOSE_REL(result.massDensity(), 0.5 * (5. + 10.), 1e-4);
76 }
77 
78 BOOST_AUTO_TEST_CASE(two_materials_different_lengh) {
79  Material mat1(1., 2., 3., 4., 5.);
80  Material mat2(6., 7., 8., 9., 10.);
81 
82  MaterialProperties matprop1(mat1, 0.5);
83  MaterialProperties matprop2(mat2, 2);
84 
86  avm.accumulate(matprop1);
87  avm.accumulate(matprop2);
88  auto result = avm.average();
89  CHECK_CLOSE_REL(result.X0(), 2.5 / (0.5 / 1. + 2. / 6.), 1e-4);
90  CHECK_CLOSE_REL(result.L0(), 2.5 / (0.5 / 2. + 2. / 7.), 1e-4);
91  CHECK_CLOSE_REL(result.Ar(), 0.5 * (3. + 8.), 1e-4);
92  CHECK_CLOSE_REL(result.Z(), 0.5 * (4. + 9.), 1e-4);
93  CHECK_CLOSE_REL(result.massDensity(), 0.5 * (5. + 10.), 1e-4);
94 }
95 
96 BOOST_AUTO_TEST_SUITE_END()
97 
98 } // namespace Test
99 } // namespace Acts