EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlanarModuleStepperTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PlanarModuleStepperTests.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 #include "Acts/Utilities/Units.hpp"
21 
22 namespace bdata = boost::unit_test::data;
23 namespace tt = boost::test_tools;
24 using namespace Acts::UnitLiterals;
25 
26 namespace Acts {
27 namespace Test {
28 
29 double halfX = 5_mm;
30 double halfY = 10_mm;
31 size_t ntests = 100;
32 size_t nbinsx = 100;
33 size_t nbinsy = 200;
34 double hThickness = 75_um;
35 double lAngle = 0.1;
36 double tanAlpha = tan(lAngle);
37 double sguardX = 2 * hThickness * abs(tanAlpha);
38 
39 // Module bounds
40 auto moduleBounds = std::make_shared<const RectangleBounds>(halfX, halfY);
42  std::make_shared<const CartesianSegmentation>(moduleBounds, nbinsx, nbinsy);
43 
44 // Create digitisation modules
45 // (1) positive readout
47 // (2) negative readout
49 std::vector<DigitizationModule> testModules = {std::move(pdModule),
50  std::move(ndModule)};
51 
54 
55 // Create a test context
57 
61  readout_counter_test,
62  bdata::random((bdata::seed = 0,
63  bdata::distribution = std::uniform_real_distribution<>(
64  -halfX + sguardX, halfX - sguardX))) ^
65  bdata::random((bdata::seed = 1,
66  bdata::distribution = std::uniform_real_distribution<>(
67  -halfX + sguardX, halfX - sguardX))) ^
68  bdata::random((bdata::seed = 2,
69  bdata::distribution =
70  std::uniform_real_distribution<>(-halfY, halfY))) ^
71  bdata::random((bdata::seed = 3,
72  bdata::distribution =
73  std::uniform_int_distribution<>(-halfY, halfY))) ^
75  entryX, entryY, exitX, exitY, index) {
76  // avoid warning with void
77  (void)index;
78 
79  // Entry and exit point
80  Vector3D entry(entryX, entryY, -hThickness);
81  Vector3D exit(exitX, exitY, hThickness);
82 
83  // test the module flavours
84  for (auto& dm : testModules) {
85  // retrieve the digitiztion steps
86  auto cSteps = pmStepper.cellSteps(tgContext, dm, entry, exit);
87  BOOST_CHECK_NE(cSteps.size(), 0);
88 
89  // Test if the longitudinal distance between first and last step
90  // is equal/close to the thickness of the module
91  auto fPosition = cSteps.begin()->stepEntry;
92  auto lPosition = cSteps.rbegin()->stepExit;
93  double zDiff = (lPosition - fPosition).z();
94 
95  CHECK_CLOSE_REL(zDiff, 2 * hThickness, 10e-6);
96  }
97 }
98 
99 } // namespace Test
100 } // namespace Acts