EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HomogeneousSurfaceMaterialTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HomogeneousSurfaceMaterialTests.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 
15 
16 #include <climits>
17 
18 namespace Acts {
19 
20 namespace Test {
21 
23 BOOST_AUTO_TEST_CASE(HomogeneousSurfaceMaterial_construction_test) {
24  // construct the material properties from arguments
25  Material mat = Material::fromMolarDensity(1., 2., 3., 4., 5.);
26  MaterialSlab mp(mat, 0.1);
27 
28  // Constructor from arguments
29  HomogeneousSurfaceMaterial hsm(mp, 1.);
30  // Copy constructor
31  HomogeneousSurfaceMaterial hsmCopy(hsm);
32  // Test equality of the copy
33  BOOST_CHECK_EQUAL(hsm, hsmCopy);
34  // Copy move constructor
35  HomogeneousSurfaceMaterial hsmCopyMoved(std::move(hsmCopy));
36  // Test equality of the copy
37  BOOST_CHECK_EQUAL(hsm, hsmCopyMoved);
38  // Assignment constructor
39  HomogeneousSurfaceMaterial hsmAssigned = hsm;
40  // Test equality of the asignment
41  BOOST_CHECK_EQUAL(hsm, hsmAssigned);
42  // Assignment move constructor
43  HomogeneousSurfaceMaterial hsmAssignedMoved(std::move(hsmAssigned));
44  // Test equality of the copy
45  BOOST_CHECK_EQUAL(hsm, hsmAssignedMoved);
46 }
47 
48 // Test the Scaling
49 BOOST_AUTO_TEST_CASE(HomogeneousSurfaceMaterial_scaling_test) {
50  MaterialSlab mat(Material::fromMolarDensity(1., 2., 3., 4., 5.), 0.1);
51  MaterialSlab matHalf = mat;
52  matHalf.scaleThickness(0.5);
53 
54  HomogeneousSurfaceMaterial hsm(mat, 1.);
55  hsm *= 0.5;
56 
57  auto matBin = hsm.materialSlab(0, 0);
58 
59  BOOST_CHECK_EQUAL(matBin, matHalf);
60  BOOST_CHECK_NE(matBin, mat);
61 }
62 
63 // Test the Access
64 BOOST_AUTO_TEST_CASE(HomogeneousSurfaceMaterial_access_test) {
65  // construct the material properties from arguments
66  MaterialSlab mat(Material::fromMolarDensity(1., 2., 3., 4., 5.), 0.1);
67  MaterialSlab matHalf = mat;
68  matHalf.scaleThickness(0.5);
69 
70  MaterialSlab vacuum = MaterialSlab();
71 
72  // Constructor from arguments
73  HomogeneousSurfaceMaterial hsmfwd(mat, 1.);
74  HomogeneousSurfaceMaterial hsmhalf(mat, 0.5);
75  HomogeneousSurfaceMaterial hsmbwd(mat, 0.);
76 
77  auto mat2d = hsmfwd.materialSlab(Vector2D{0., 0.});
78  auto mat3d = hsmfwd.materialSlab(Vector3D{0., 0., 0.});
79  auto matbin = hsmfwd.materialSlab(0, 0);
80 
81  // Test equality of the copy
82  BOOST_CHECK_EQUAL(mat, mat2d);
83  BOOST_CHECK_EQUAL(mat, mat3d);
84  BOOST_CHECK_EQUAL(mat, matbin);
85 
88 
92 
93  // (a) Forward factor material test
94  BOOST_CHECK_EQUAL(hsmfwd.factor(fDir, full), 1.);
95  BOOST_CHECK_EQUAL(hsmfwd.factor(fDir, pre), 0.);
96  BOOST_CHECK_EQUAL(hsmfwd.factor(fDir, post), 1.);
97 
98  BOOST_CHECK_EQUAL(hsmfwd.factor(bDir, full), 1.);
99  BOOST_CHECK_EQUAL(hsmfwd.factor(bDir, pre), 1.);
100  BOOST_CHECK_EQUAL(hsmfwd.factor(bDir, post), 0.);
101 
102  auto matFwdFull = hsmfwd.materialSlab(Vector3D{0., 0., 0.}, fDir, full);
103  auto matBwdFull = hsmfwd.materialSlab(Vector3D{0., 0., 0.}, bDir, full);
104 
105  auto matFwdPost = hsmfwd.materialSlab(Vector3D{0., 0., 0.}, fDir, post);
106  auto matBwdPost = hsmfwd.materialSlab(Vector3D{0., 0., 0.}, bDir, post);
107 
108  auto matFwdPre = hsmfwd.materialSlab(Vector3D{0., 0., 0.}, fDir, pre);
109  auto matBwdPre = hsmfwd.materialSlab(Vector3D{0., 0., 0.}, bDir, pre);
110 
111  BOOST_CHECK_EQUAL(mat, matFwdFull);
112  BOOST_CHECK_EQUAL(mat, matBwdFull);
113 
114  BOOST_CHECK_EQUAL(mat, matFwdPost);
115  BOOST_CHECK_EQUAL(vacuum, matBwdPost);
116 
117  BOOST_CHECK_EQUAL(vacuum, matFwdPre);
118  BOOST_CHECK_EQUAL(mat, matBwdPre);
119 
120  // (b) Split factor material test
121  BOOST_CHECK_EQUAL(hsmhalf.factor(fDir, full), 1.);
122  CHECK_CLOSE_REL(hsmhalf.factor(fDir, pre), 0.5, 1e-6);
123  CHECK_CLOSE_REL(hsmhalf.factor(fDir, post), 0.5, 1e-6);
124 
125  BOOST_CHECK_EQUAL(hsmhalf.factor(bDir, full), 1.);
126  CHECK_CLOSE_REL(hsmhalf.factor(bDir, pre), 0.5, 1e-6);
127  CHECK_CLOSE_REL(hsmhalf.factor(bDir, post), 0.5, 1e-6);
128 
129  matFwdFull = hsmhalf.materialSlab(Vector3D{0., 0., 0.}, fDir, full);
130  matBwdFull = hsmhalf.materialSlab(Vector3D{0., 0., 0.}, bDir, full);
131 
132  matFwdPost = hsmhalf.materialSlab(Vector3D{0., 0., 0.}, fDir, post);
133  matBwdPost = hsmhalf.materialSlab(Vector3D{0., 0., 0.}, bDir, post);
134 
135  matFwdPre = hsmhalf.materialSlab(Vector3D{0., 0., 0.}, fDir, pre);
136  matBwdPre = hsmhalf.materialSlab(Vector3D{0., 0., 0.}, bDir, pre);
137 
138  BOOST_CHECK_EQUAL(mat, matFwdFull);
139  BOOST_CHECK_EQUAL(mat, matBwdFull);
140 
141  BOOST_CHECK_EQUAL(matHalf, matFwdPost);
142  BOOST_CHECK_EQUAL(matHalf, matBwdPost);
143 
144  BOOST_CHECK_EQUAL(matHalf, matFwdPre);
145  BOOST_CHECK_EQUAL(matHalf, matBwdPre);
146 
147  // c) Forward factor material test
148  BOOST_CHECK_EQUAL(hsmbwd.factor(fDir, full), 1.);
149  BOOST_CHECK_EQUAL(hsmbwd.factor(fDir, pre), 1.);
150  BOOST_CHECK_EQUAL(hsmbwd.factor(fDir, post), 0.);
151 
152  BOOST_CHECK_EQUAL(hsmbwd.factor(bDir, full), 1.);
153  BOOST_CHECK_EQUAL(hsmbwd.factor(bDir, pre), 0.);
154  BOOST_CHECK_EQUAL(hsmbwd.factor(bDir, post), 1.);
155 
156  matFwdFull = hsmbwd.materialSlab(Vector3D{0., 0., 0.}, fDir, full);
157  matBwdFull = hsmbwd.materialSlab(Vector3D{0., 0., 0.}, bDir, full);
158 
159  matFwdPost = hsmbwd.materialSlab(Vector3D{0., 0., 0.}, fDir, post);
160  matBwdPost = hsmbwd.materialSlab(Vector3D{0., 0., 0.}, bDir, post);
161 
162  matFwdPre = hsmbwd.materialSlab(Vector3D{0., 0., 0.}, fDir, pre);
163  matBwdPre = hsmbwd.materialSlab(Vector3D{0., 0., 0.}, bDir, pre);
164 
165  BOOST_CHECK_EQUAL(mat, matFwdFull);
166  BOOST_CHECK_EQUAL(mat, matBwdFull);
167 
168  BOOST_CHECK_EQUAL(vacuum, matFwdPost);
169  BOOST_CHECK_EQUAL(mat, matBwdPost);
170 
171  BOOST_CHECK_EQUAL(mat, matFwdPre);
172  BOOST_CHECK_EQUAL(vacuum, matBwdPre);
173 }
174 } // namespace Test
175 } // namespace Acts