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 
13 
14 #include <climits>
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  Material mat = Material::fromMolarDensity(1., 1., 1., 1., 1.);
52  MaterialSlab one(mat, 1.);
53  MaterialSlab two(mat, 2.);
54 
55  AccumulatedSurfaceMaterial material0D{};
56  // assign 2 one steps
57  material0D.accumulate(Vector2D{0., 0.}, one);
58  material0D.accumulate(Vector2D{0., 0.}, one);
59  material0D.trackAverage();
60  // assign 1 double step
61  material0D.accumulate(Vector3D(0., 0., 0.), two);
62  material0D.trackAverage();
63  // get the single matrix
64  auto accMat0D = material0D.accumulatedMaterial();
65  auto accMatProp0D = accMat0D[0][0];
66  auto [matProp0D, trackCount] = accMatProp0D.totalAverage();
67 
68  BOOST_CHECK_EQUAL(matProp0D.thicknessInX0(), two.thicknessInX0());
69  BOOST_CHECK_EQUAL(trackCount, 2u);
70 }
71 
73 BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_fill_convert_1D) {
74  Material mat = Material::fromMolarDensity(1., 1., 1., 1., 1.);
75  MaterialSlab one(mat, 1.);
76  MaterialSlab two(mat, 2.);
77  MaterialSlab three(mat, 3.);
78  MaterialSlab four(mat, 4.);
79 
80  // BinnesSurfaceMatieral accumulation - 2D
81  BinUtility binUtility2D(2, -1., 1., open, binX);
82  binUtility2D += BinUtility(2, -1., 1., open, binY);
83  AccumulatedSurfaceMaterial material2D{binUtility2D};
84 
85  // assign in the different bins
86  // event 0
87  material2D.accumulate(Vector2D{-0.5, -0.5}, one);
88  material2D.accumulate(Vector2D{0.5, -0.5}, two);
89  material2D.accumulate(Vector2D{-0.5, 0.5}, three);
90  material2D.accumulate(Vector2D{0.5, 0.5}, four);
91  material2D.trackAverage();
92  // event 1
93  material2D.accumulate(Vector2D{0.5, -0.5}, two);
94  material2D.accumulate(Vector2D{-0.5, 0.5}, three);
95  material2D.accumulate(Vector2D{0.5, 0.5}, four);
96  material2D.trackAverage();
97  // event 2
98  material2D.accumulate(Vector2D{-0.5, 0.5}, three);
99  material2D.accumulate(Vector2D{0.5, 0.5}, four);
100  material2D.trackAverage();
101  // event 2
102  material2D.accumulate(Vector2D{0.5, 0.5}, four);
103  material2D.trackAverage();
104  // get the single matrix
105  auto accMat2D = material2D.accumulatedMaterial();
106  // the accumulated properties
107  auto [accMatProp00, trackCount00] = accMat2D[0][0].totalAverage();
108  auto [accMatProp01, trackCount01] = accMat2D[0][1].totalAverage();
109  auto [accMatProp10, trackCount10] = accMat2D[1][0].totalAverage();
110  auto [accMatProp11, trackCount11] = accMat2D[1][1].totalAverage();
111 
112  BOOST_CHECK_EQUAL(accMatProp00.thicknessInX0(), one.thicknessInX0());
113  BOOST_CHECK_EQUAL(accMatProp01.thicknessInX0(), two.thicknessInX0());
114  BOOST_CHECK_EQUAL(accMatProp10.thicknessInX0(), three.thicknessInX0());
115  BOOST_CHECK_EQUAL(accMatProp11.thicknessInX0(), four.thicknessInX0());
116  BOOST_CHECK_EQUAL(trackCount00, 1u);
117  BOOST_CHECK_EQUAL(trackCount01, 2u);
118  BOOST_CHECK_EQUAL(trackCount10, 3u);
119  BOOST_CHECK_EQUAL(trackCount11, 4u);
120 }
121 
122 } // namespace Test
123 } // namespace Acts