ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SingleHitSpacePointBuilderTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SingleHitSpacePointBuilderTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 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/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
17 #include "Acts/Utilities/Units.hpp"
18 
19 namespace bdata = boost::unit_test::data;
20 namespace tt = boost::test_tools;
21 
22 namespace Acts {
23 namespace Test {
24 
25 using namespace Acts::UnitLiterals;
26 
27 // Create a test context
29 
33 BOOST_DATA_TEST_CASE(SingleHitSpacePointBuilder_basic, bdata::xrange(1),
34  index) {
35  (void)index;
36 
37  // Build bounds
38  std::shared_ptr<const RectangleBounds> recBounds(
39  new RectangleBounds(35_um, 25_mm));
40 
41  // Build binning and segmentation
42  std::vector<float> boundariesX, boundariesY;
43  boundariesX.push_back(-35_um);
44  boundariesX.push_back(35_um);
45  boundariesY.push_back(-25_mm);
46  boundariesY.push_back(25_mm);
47 
48  BinningData binDataX(BinningOption::open, BinningValue::binX, boundariesX);
49  std::shared_ptr<BinUtility> buX(new BinUtility(binDataX));
50  BinningData binDataY(BinningOption::open, BinningValue::binY, boundariesY);
51  std::shared_ptr<BinUtility> buY(new BinUtility(binDataY));
52  (*buX) += (*buY);
53 
54  std::shared_ptr<const Segmentation> segmentation(
55  new CartesianSegmentation(buX, recBounds));
56 
57  // Build translation
58 
59  double rotation = 0.026_rad;
60  RotationMatrix3D rotationPos;
61  Vector3D xPos(cos(rotation), sin(rotation), 0.);
62  Vector3D yPos(-sin(rotation), cos(rotation), 0.);
63  Vector3D zPos(0., 0., 1.);
64  rotationPos.col(0) = xPos;
65  rotationPos.col(1) = yPos;
66  rotationPos.col(2) = zPos;
67  Transform3D t3d(Transform3D::Identity() * rotationPos);
68  t3d.translation() = Vector3D(0., 0., 10_m);
69 
70  // Build Digitization
71  const DigitizationModule digMod(segmentation, 1., 1., 0.);
72  DetectorElementStub detElem(std::make_shared<const Transform3D>(t3d));
73  auto pSur = Surface::makeShared<PlaneSurface>(recBounds, detElem);
75  cov << 0., 0., 0., 0., 0., 0., 0., 0., 0.;
76  Vector2D local = {0.1, -0.1};
77 
78  // Build PlanarModuleCluster
80  pSur, {}, cov, local[0], local[1], 0., {DigitizationCell(0, 0, 1.)});
81 
82  std::cout << "Hit created" << std::endl;
83 
84  std::vector<SpacePoint<PlanarModuleCluster>> data;
86 
87  std::cout << "Hit added to storage" << std::endl;
88 
89  shsp.calculateSpacePoints(tgContext, {pmc}, data);
90  BOOST_CHECK_NE(data[0].vector, Vector3D::Zero());
91 
92  std::cout << "Space point calculated" << std::endl;
93 }
94 
95 } // end of namespace Test
96 } // end of namespace Acts