ECCE @ 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 
11 #include <climits>
12 
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  MaterialProperties mp(1., 2., 3., 4., 5., 0.1);
26 
27  // Constructor from arguments
28  HomogeneousSurfaceMaterial hsm(mp, 1.);
29  // Copy constructor
30  HomogeneousSurfaceMaterial hsmCopy(hsm);
31  // Test equality of the copy
32  BOOST_CHECK_EQUAL(hsm, hsmCopy);
33  // Copy move constructor
34  HomogeneousSurfaceMaterial hsmCopyMoved(std::move(hsmCopy));
35  // Test equality of the copy
36  BOOST_CHECK_EQUAL(hsm, hsmCopyMoved);
37  // Assignment constructor
38  HomogeneousSurfaceMaterial hsmAssigned = hsm;
39  // Test equality of the asignment
40  BOOST_CHECK_EQUAL(hsm, hsmAssigned);
41  // Assignment move constructor
42  HomogeneousSurfaceMaterial hsmAssignedMoved(std::move(hsmAssigned));
43  // Test equality of the copy
44  BOOST_CHECK_EQUAL(hsm, hsmAssignedMoved);
45 }
46 
47 // Test the Scaling
48 BOOST_AUTO_TEST_CASE(HomogeneousSurfaceMaterial_scaling_test) {
49  // Construct the material properties from arguments
50  MaterialProperties mat(1., 2., 3., 4., 5., 0.1);
51  MaterialProperties matHalf = mat;
52  matHalf.scaleThickness(0.5);
53 
54  HomogeneousSurfaceMaterial hsm(mat, 1.);
55  hsm *= 0.5;
56 
57  auto matBin = hsm.materialProperties(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  MaterialProperties mat(1., 2., 3., 4., 5., 0.1);
67  MaterialProperties matHalf = mat;
68  matHalf.scaleThickness(0.5);
69 
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.materialProperties(Vector2D{0., 0.});
78  auto mat3d = hsmfwd.materialProperties(Vector3D{0., 0., 0.});
79  auto matbin = hsmfwd.materialProperties(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.materialProperties(Vector3D{0., 0., 0.}, fDir, full);
103  auto matBwdFull = hsmfwd.materialProperties(Vector3D{0., 0., 0.}, bDir, full);
104 
105  auto matFwdPost = hsmfwd.materialProperties(Vector3D{0., 0., 0.}, fDir, post);
106  auto matBwdPost = hsmfwd.materialProperties(Vector3D{0., 0., 0.}, bDir, post);
107 
108  auto matFwdPre = hsmfwd.materialProperties(Vector3D{0., 0., 0.}, fDir, pre);
109  auto matBwdPre = hsmfwd.materialProperties(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.materialProperties(Vector3D{0., 0., 0.}, fDir, full);
130  matBwdFull = hsmhalf.materialProperties(Vector3D{0., 0., 0.}, bDir, full);
131 
132  matFwdPost = hsmhalf.materialProperties(Vector3D{0., 0., 0.}, fDir, post);
133  matBwdPost = hsmhalf.materialProperties(Vector3D{0., 0., 0.}, bDir, post);
134 
135  matFwdPre = hsmhalf.materialProperties(Vector3D{0., 0., 0.}, fDir, pre);
136  matBwdPre = hsmhalf.materialProperties(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.materialProperties(Vector3D{0., 0., 0.}, fDir, full);
157  matBwdFull = hsmbwd.materialProperties(Vector3D{0., 0., 0.}, bDir, full);
158 
159  matFwdPost = hsmbwd.materialProperties(Vector3D{0., 0., 0.}, fDir, post);
160  matBwdPost = hsmbwd.materialProperties(Vector3D{0., 0., 0.}, bDir, post);
161 
162  matFwdPre = hsmbwd.materialProperties(Vector3D{0., 0., 0.}, fDir, pre);
163  matBwdPre = hsmbwd.materialProperties(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