ECCE @ EIC 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 
18 #include "Acts/Utilities/Units.hpp"
19 
20 namespace bdata = boost::unit_test::data;
21 namespace tt = boost::test_tools;
22 using namespace Acts::UnitLiterals;
23 
24 namespace Acts {
25 namespace Test {
26 
27 size_t nbinsx = 100;
28 size_t nbinsy = 200;
29 double hThickness = 75_um;
30 double lAngle = 0.1;
31 
32 // Module bounds
33 auto moduleBounds = std::make_shared<const RectangleBounds>(5_mm, 10_mm);
35 
36 // Create a test context
38 
41 BOOST_AUTO_TEST_CASE(cartesian_segmentation) {
42  // The surface vectors: positive readout, zero lorentz angle
43  // -> PZL
44  SurfacePtrVector boundariesPZL;
45  SurfacePtrVector segSurfacesXPZL;
46  SurfacePtrVector segSurfacesYPZL;
47 
48  cSegmentation.createSegmentationSurfaces(boundariesPZL, segSurfacesXPZL,
49  segSurfacesYPZL, hThickness, 1, 0.);
50 
51  BOOST_CHECK_EQUAL(boundariesPZL.size(), 6u);
52 
53  // There's one less because of the boundary and lorentz plane
54  BOOST_CHECK_EQUAL(segSurfacesXPZL.size(), size_t(nbinsx - 1));
55  BOOST_CHECK_EQUAL(segSurfacesYPZL.size(), size_t(nbinsy - 1));
56 
57  // Check the boundary surfaces are thickness away
58  auto centerReadoutPZL = boundariesPZL[0]->center(tgContext);
59  auto centerCounterPZL = boundariesPZL[1]->center(tgContext);
60  auto centerDiffPZL = centerReadoutPZL - centerCounterPZL;
61  double thicknessPZL = centerDiffPZL.norm();
62 
63  CHECK_CLOSE_REL(thicknessPZL, 2 * hThickness, 10e-6);
64 
65  // The surface vectors: negative readout, zero lorentz angle
66  // -> NZL
67  SurfacePtrVector boundariesNZL;
68  SurfacePtrVector segSurfacesXNZL;
69  SurfacePtrVector segSurfacesYNZL;
70 
71  cSegmentation.createSegmentationSurfaces(boundariesNZL, segSurfacesXNZL,
72  segSurfacesYNZL, hThickness, -1, 0.);
73 
74  BOOST_CHECK_EQUAL(boundariesNZL.size(), 6u);
75 
76  // There's one less because of the boundary and lorentz plane
77  BOOST_CHECK_EQUAL(segSurfacesXNZL.size(), size_t(nbinsx - 1));
78  BOOST_CHECK_EQUAL(segSurfacesYNZL.size(), size_t(nbinsy - 1));
79 
80  // Check the boundary surfaces are thickness away
81  auto centerReadoutNZL = boundariesNZL[0]->center(tgContext);
82  auto centerCounterNZL = boundariesNZL[1]->center(tgContext);
83  auto centerDiffNZL = centerReadoutNZL - centerCounterNZL;
84  double thicknessNZL = centerDiffNZL.norm();
85 
86  CHECK_CLOSE_REL(thicknessNZL, 2 * hThickness, 10e-6);
87 
88  // Check that the readout / counter surfaces are reversed
89  CHECK_CLOSE_OR_SMALL(centerReadoutPZL, centerCounterNZL, 10e-6, 10e-9);
90  CHECK_CLOSE_OR_SMALL(centerReadoutNZL, centerCounterPZL, 10e-6, 10e-9);
91 
92  // The surface vectors: positive readout, lorentz angle
93  // -> PL
94  SurfacePtrVector boundariesPL;
95  SurfacePtrVector segSurfacesXPL;
96  SurfacePtrVector segSurfacesYPL;
97 
99  boundariesPL, segSurfacesXPL, segSurfacesYPL, hThickness, 1, lAngle);
100 
101  BOOST_CHECK_EQUAL(boundariesPL.size(), 6u);
102 
103  // There's one less because of the boundary and lorentz plane
104  BOOST_CHECK_EQUAL(segSurfacesXPL.size(), size_t(nbinsx - 1));
105  BOOST_CHECK_EQUAL(segSurfacesYPL.size(), size_t(nbinsy - 1));
106 
107  // Check the boundary surfaces are thickness away
108  auto centerReadoutPL = boundariesPL[0]->center(tgContext);
109  auto centerCoutnerPL = boundariesPL[1]->center(tgContext);
110  double thicknessPL = abs((centerReadoutPL - centerCoutnerPL).z());
111 
112  CHECK_CLOSE_REL(thicknessPL, 2 * hThickness, 10e-6);
113 
114  // check the lorentz angle - let's take the second one
115  auto nLorentzPlane = segSurfacesXPL[2]->normal(tgContext);
116 
117  Vector3D nNominal(1., 0., 0.);
118  double tAngle = acos(nLorentzPlane.dot(nNominal));
119 
120  CHECK_CLOSE_REL(tAngle, lAngle, 0.001);
121 }
122 
123 } // namespace Test
124 } // namespace Acts