ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AccumulatedSurfaceMaterialTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AccumulatedSurfaceMaterialTests.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 
15 
16 namespace Acts {
17 namespace Test {
18 
20 BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_construction_test) {
21  // Test:
22  // HomogeneousSurfaceMaterial accumulation
23  AccumulatedSurfaceMaterial material0D{};
24  auto accMat0D = material0D.accumulatedMaterial();
25  BOOST_CHECK_EQUAL(accMat0D.size(), 1u);
26  BOOST_CHECK_EQUAL(accMat0D[0].size(), 1u);
27  BOOST_CHECK_EQUAL(material0D.splitFactor(), 0.);
28 
29  // Test:
30  // BinnesSurfaceMatieral accumulation - 1D
31  BinUtility binUtility1D(10, -5., 5., open, binX);
32  AccumulatedSurfaceMaterial material1D{binUtility1D};
33  auto accMat1D = material1D.accumulatedMaterial();
34  BOOST_CHECK_EQUAL(accMat1D.size(), 1u);
35  BOOST_CHECK_EQUAL(accMat1D[0].size(), 10u);
36 
37  // Test:
38  // BinnesSurfaceMatieral accumulation - 2D
39  BinUtility binUtility2D(10, -5., 5., open, binX);
40  binUtility2D += BinUtility(20, -10., 10., open, binY);
41  AccumulatedSurfaceMaterial material2D{binUtility2D};
42  auto accMat2D = material2D.accumulatedMaterial();
43  BOOST_CHECK_EQUAL(accMat2D.size(), 20u);
44  for (size_t ib = 0; ib < accMat2D.size(); ++ib) {
45  BOOST_CHECK_EQUAL(accMat2D[ib].size(), 10u);
46  }
47 }
48 
50 BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_fill_convert_0D) {
51  MaterialProperties one(1., 1., 1., 1., 1., 1.);
52  MaterialProperties two(1., 1., 1., 1., 1., 2.);
53 
54  AccumulatedSurfaceMaterial material0D{};
55  // assign 2 one steps
56  material0D.accumulate(Vector2D{0., 0.}, one);
57  material0D.accumulate(Vector2D{0., 0.}, one);
58  material0D.trackAverage();
59  // assign 1 double step
60  material0D.accumulate(Vector3D(0., 0., 0.), two);
61  material0D.trackAverage();
62  // get the single matrix
63  auto accMat0D = material0D.accumulatedMaterial();
64  auto accMatProp0D = accMat0D[0][0];
65  auto matProp0D = accMatProp0D.totalAverage();
66 
67  BOOST_CHECK_EQUAL(matProp0D.second, 2u);
68  BOOST_CHECK_EQUAL(matProp0D.first.thicknessInX0(), two.thicknessInX0());
69 }
70 
72 BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_fill_convert_1D) {
73  MaterialProperties one(1., 1., 1., 1., 1., 1.);
74  MaterialProperties two(1., 1., 1., 1., 1., 2.);
75  MaterialProperties three(1., 1., 1., 1., 1., 3.);
76  MaterialProperties four(1., 1., 1., 1., 1., 4.);
77 
78  // BinnesSurfaceMatieral accumulation - 2D
79  BinUtility binUtility2D(2, -1., 1., open, binX);
80  binUtility2D += BinUtility(2, -1., 1., open, binY);
81  AccumulatedSurfaceMaterial material2D{binUtility2D};
82 
83  // assign in the different bins
84  // event 0
85  material2D.accumulate(Vector2D{-0.5, -0.5}, one);
86  material2D.accumulate(Vector2D{0.5, -0.5}, two);
87  material2D.accumulate(Vector2D{-0.5, 0.5}, three);
88  material2D.accumulate(Vector2D{0.5, 0.5}, four);
89  material2D.trackAverage();
90  // event 1
91  material2D.accumulate(Vector2D{0.5, -0.5}, two);
92  material2D.accumulate(Vector2D{-0.5, 0.5}, three);
93  material2D.accumulate(Vector2D{0.5, 0.5}, four);
94  material2D.trackAverage();
95  // event 2
96  material2D.accumulate(Vector2D{-0.5, 0.5}, three);
97  material2D.accumulate(Vector2D{0.5, 0.5}, four);
98  material2D.trackAverage();
99  // event 2
100  material2D.accumulate(Vector2D{0.5, 0.5}, four);
101  material2D.trackAverage();
102  // get the single matrix
103  auto accMat2D = material2D.accumulatedMaterial();
104  // the accumulated properties
105  auto accMatProp00 = accMat2D[0][0].totalAverage();
106  auto accMatProp01 = accMat2D[0][1].totalAverage();
107  auto accMatProp10 = accMat2D[1][0].totalAverage();
108  auto accMatProp11 = accMat2D[1][1].totalAverage();
109 
110  BOOST_CHECK_EQUAL(accMatProp00.second, 1u);
111  BOOST_CHECK_EQUAL(accMatProp01.second, 2u);
112  BOOST_CHECK_EQUAL(accMatProp10.second, 3u);
113  BOOST_CHECK_EQUAL(accMatProp11.second, 4u);
114 
115  BOOST_CHECK_EQUAL(accMatProp00.first.thicknessInX0(), one.thicknessInX0());
116  BOOST_CHECK_EQUAL(accMatProp01.first.thicknessInX0(), two.thicknessInX0());
117  BOOST_CHECK_EQUAL(accMatProp10.first.thicknessInX0(), three.thicknessInX0());
118  BOOST_CHECK_EQUAL(accMatProp11.first.thicknessInX0(), four.thicknessInX0());
119 }
120 
121 } // namespace Test
122 } // namespace Acts