Analysis Software
Documentation for sPHENIX simulation 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 
21 
22 #include <cmath>
23 #include <cstdlib>
24 #include <memory>
25 #include <random>
26 #include <utility>
27 #include <vector>
28 
29 namespace bdata = boost::unit_test::data;
30 namespace tt = boost::test_tools;
31 using namespace Acts::UnitLiterals;
32 
33 namespace Acts {
34 namespace Test {
35 
36 double halfX = 5_mm;
37 double halfY = 10_mm;
38 size_t ntests = 100;
39 size_t nbinsx = 100;
40 size_t nbinsy = 200;
41 double hThickness = 75_um;
42 double lAngle = 0.1;
43 double tanAlpha = tan(lAngle);
44 double sguardX = 2 * hThickness * abs(tanAlpha);
45 
46 // Module bounds
47 auto moduleBounds = std::make_shared<const RectangleBounds>(halfX, halfY);
49  std::make_shared<const CartesianSegmentation>(moduleBounds, nbinsx, nbinsy);
50 
51 // Create digitisation modules
52 // (1) positive readout
54 // (2) negative readout
56 std::vector<DigitizationModule> testModules = {pdModule, ndModule};
57 
60 
61 // Create a test context
63 
67  readout_counter_test,
68  bdata::random((bdata::seed = 0,
69  bdata::distribution = std::uniform_real_distribution<>(
70  -halfX + sguardX, halfX - sguardX))) ^
71  bdata::random((bdata::seed = 1,
72  bdata::distribution = std::uniform_real_distribution<>(
73  -halfX + sguardX, halfX - sguardX))) ^
74  bdata::random((bdata::seed = 2,
75  bdata::distribution =
76  std::uniform_real_distribution<>(-halfY, halfY))) ^
77  bdata::random((bdata::seed = 3,
78  bdata::distribution = std::uniform_int_distribution<>(
79  -static_cast<int>(halfY),
80  static_cast<int>(halfY)))) ^
81  bdata::xrange(ntests),
82  entryX, entryY, exitX, exitY, index) {
83  // avoid warning with void
84  (void)index;
85 
86  // Entry and exit point
87  Vector3 entry(entryX, entryY, -hThickness);
88  Vector3 exit(exitX, exitY, hThickness);
89 
90  // test the module flavours
91  for (auto& dm : testModules) {
92  // retrieve the digitiztion steps
93  auto cSteps = pmStepper.cellSteps(tgContext, dm, entry, exit);
94  BOOST_CHECK_NE(cSteps.size(), 0);
95 
96  // Test if the longitudinal distance between first and last step
97  // is equal/close to the thickness of the module
98  auto fPosition = cSteps.begin()->stepEntry;
99  auto lPosition = cSteps.rbegin()->stepExit;
100  double zDiff = (lPosition - fPosition).z();
101 
102  CHECK_CLOSE_REL(zDiff, 2 * hThickness, 10e-6);
103  }
104 }
105 
106 } // namespace Test
107 } // namespace Acts