Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CartesianSegmentationTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CartesianSegmentationTests.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/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
20 
21 #include <cmath>
22 #include <cstdlib>
23 #include <memory>
24 
25 namespace bdata = boost::unit_test::data;
26 namespace tt = boost::test_tools;
27 using namespace Acts::UnitLiterals;
28 
29 namespace Acts {
30 namespace Test {
31 
32 size_t nbinsx = 100;
33 size_t nbinsy = 200;
34 double hThickness = 75_um;
35 double lAngle = 0.1;
36 
37 // Module bounds
38 auto moduleBounds = std::make_shared<const RectangleBounds>(5_mm, 10_mm);
40 
41 // Create a test context
43 
46 BOOST_AUTO_TEST_CASE(cartesian_segmentation) {
47  // The surface vectors: positive readout, zero lorentz angle
48  // -> PZL
49  SurfacePtrVector boundariesPZL;
50  SurfacePtrVector segSurfacesXPZL;
51  SurfacePtrVector segSurfacesYPZL;
52 
53  cSegmentation.createSegmentationSurfaces(boundariesPZL, segSurfacesXPZL,
54  segSurfacesYPZL, hThickness, 1, 0.);
55 
56  BOOST_CHECK_EQUAL(boundariesPZL.size(), 6u);
57 
58  // There's one less because of the boundary and lorentz plane
59  BOOST_CHECK_EQUAL(segSurfacesXPZL.size(), size_t(nbinsx - 1));
60  BOOST_CHECK_EQUAL(segSurfacesYPZL.size(), size_t(nbinsy - 1));
61 
62  // Check the boundary surfaces are thickness away
63  auto centerReadoutPZL = boundariesPZL[0]->center(tgContext);
64  auto centerCounterPZL = boundariesPZL[1]->center(tgContext);
65  auto centerDiffPZL = centerReadoutPZL - centerCounterPZL;
66  double thicknessPZL = centerDiffPZL.norm();
67 
68  CHECK_CLOSE_REL(thicknessPZL, 2 * hThickness, 10e-6);
69 
70  // The surface vectors: negative readout, zero lorentz angle
71  // -> NZL
72  SurfacePtrVector boundariesNZL;
73  SurfacePtrVector segSurfacesXNZL;
74  SurfacePtrVector segSurfacesYNZL;
75 
76  cSegmentation.createSegmentationSurfaces(boundariesNZL, segSurfacesXNZL,
77  segSurfacesYNZL, hThickness, -1, 0.);
78 
79  BOOST_CHECK_EQUAL(boundariesNZL.size(), 6u);
80 
81  // There's one less because of the boundary and lorentz plane
82  BOOST_CHECK_EQUAL(segSurfacesXNZL.size(), size_t(nbinsx - 1));
83  BOOST_CHECK_EQUAL(segSurfacesYNZL.size(), size_t(nbinsy - 1));
84 
85  // Check the boundary surfaces are thickness away
86  auto centerReadoutNZL = boundariesNZL[0]->center(tgContext);
87  auto centerCounterNZL = boundariesNZL[1]->center(tgContext);
88  auto centerDiffNZL = centerReadoutNZL - centerCounterNZL;
89  double thicknessNZL = centerDiffNZL.norm();
90 
91  CHECK_CLOSE_REL(thicknessNZL, 2 * hThickness, 10e-6);
92 
93  // Check that the readout / counter surfaces are reversed
94  CHECK_CLOSE_OR_SMALL(centerReadoutPZL, centerCounterNZL, 10e-6, 10e-9);
95  CHECK_CLOSE_OR_SMALL(centerReadoutNZL, centerCounterPZL, 10e-6, 10e-9);
96 
97  // The surface vectors: positive readout, lorentz angle
98  // -> PL
99  SurfacePtrVector boundariesPL;
100  SurfacePtrVector segSurfacesXPL;
101  SurfacePtrVector segSurfacesYPL;
102 
104  boundariesPL, segSurfacesXPL, segSurfacesYPL, hThickness, 1, lAngle);
105 
106  BOOST_CHECK_EQUAL(boundariesPL.size(), 6u);
107 
108  // There's one less because of the boundary and lorentz plane
109  BOOST_CHECK_EQUAL(segSurfacesXPL.size(), size_t(nbinsx - 1));
110  BOOST_CHECK_EQUAL(segSurfacesYPL.size(), size_t(nbinsy - 1));
111 
112  // Check the boundary surfaces are thickness away
113  auto centerReadoutPL = boundariesPL[0]->center(tgContext);
114  auto centerCounterPL = boundariesPL[1]->center(tgContext);
115  double thicknessPL = abs((centerReadoutPL - centerCounterPL).z());
116 
117  CHECK_CLOSE_REL(thicknessPL, 2 * hThickness, 10e-6);
118 
119  // check the lorentz angle - let's take the second one
120  auto nLorentzPlane = segSurfacesXPL[2]->normal(tgContext);
121 
122  Vector3 nNominal(1., 0., 0.);
123  double tAngle = acos(nLorentzPlane.dot(nNominal));
124 
125  CHECK_CLOSE_REL(tAngle, lAngle, 0.001);
126 }
127 
128 } // namespace Test
129 } // namespace Acts