forked from sPHENIX-Collaboration/acts
/
CylinderLayerTests.cpp
99 lines (87 loc) · 3.93 KB
/
CylinderLayerTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// This file is part of the Acts project.
//
// Copyright (C) 2017-2018 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <boost/test/data/test_case.hpp>
#include <boost/test/tools/output_test_stream.hpp>
#include <boost/test/unit_test.hpp>
#include "Acts/Geometry/CuboidVolumeBounds.hpp"
#include "Acts/Geometry/CylinderLayer.hpp"
#include "Acts/Geometry/GenericApproachDescriptor.hpp"
#include "Acts/Geometry/SurfaceArrayCreator.hpp"
#include "Acts/Surfaces/CylinderBounds.hpp"
#include "Acts/Surfaces/PlaneSurface.hpp"
#include "Acts/Surfaces/RectangleBounds.hpp"
#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
#include "Acts/Utilities/Definitions.hpp"
#include "LayerStub.hpp"
using boost::test_tools::output_test_stream;
namespace utf = boost::unit_test;
namespace Acts {
namespace Test {
// Create a test context
GeometryContext tgContext = GeometryContext();
namespace Layers {
BOOST_AUTO_TEST_SUITE(Layers)
/// Unit test for creating compliant/non-compliant CylinderLayer object
BOOST_AUTO_TEST_CASE(CylinderLayerConstruction) {
// default constructor, copy and assignment are all deleted
// minimally need a Transform3D and a PlanarBounds object (e.g.
// CylinderBounds) to construct
Translation3D translation{0., 1., 2.};
auto pTransform = Transform3D(translation);
double radius(0.5), halfz(10.);
auto pCylinder = std::make_shared<const CylinderBounds>(radius, halfz);
auto pCylinderLayer =
CylinderLayer::create(pTransform, pCylinder, nullptr, 1.);
BOOST_CHECK_EQUAL(pCylinderLayer->layerType(), LayerType::passive);
// next level: need an array of Surfaces;
// bounds object, rectangle type
auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
/// Construction
const std::vector<std::shared_ptr<const Surface>> aSurfaces{
Surface::makeShared<PlaneSurface>(Transform3D::Identity(), rBounds),
Surface::makeShared<PlaneSurface>(Transform3D::Identity(), rBounds)};
const double thickness(1.0);
auto pCylinderLayerFromSurfaces =
CylinderLayer::create(pTransform, pCylinder, nullptr, thickness);
BOOST_CHECK_EQUAL(pCylinderLayerFromSurfaces->layerType(),
LayerType::passive);
// construct with thickness:
auto pCylinderLayerWithThickness =
CylinderLayer::create(pTransform, pCylinder, nullptr, thickness);
CHECK_CLOSE_REL(pCylinderLayerWithThickness->thickness(), thickness, 1e-6);
// with an approach descriptor...
std::unique_ptr<ApproachDescriptor> ad(
new GenericApproachDescriptor(aSurfaces));
auto adPtr = ad.get();
auto pCylinderLayerWithApproachDescriptor = CylinderLayer::create(
pTransform, pCylinder, nullptr, thickness, std::move(ad));
BOOST_CHECK_EQUAL(pCylinderLayerWithApproachDescriptor->approachDescriptor(),
adPtr);
// with the layerType specified...
auto pCylinderLayerWithLayerType =
CylinderLayer::create(pTransform, pCylinder, nullptr, thickness,
std::move(ad), LayerType::passive);
BOOST_CHECK_EQUAL(pCylinderLayerWithLayerType->layerType(),
LayerType::passive);
}
/// Unit test for testing Layer properties
BOOST_AUTO_TEST_CASE(CylinderLayerProperties /*, *utf::expected_failures(1)*/) {
Translation3D translation{0., 1., 2.};
auto pTransform = Transform3D(translation);
double radius(0.5), halfz(10.);
auto pCylinder = std::make_shared<const CylinderBounds>(radius, halfz);
auto pCylinderLayer =
CylinderLayer::create(pTransform, pCylinder, nullptr, 1.);
// auto planeSurface = pCylinderLayer->surfaceRepresentation();
BOOST_CHECK_EQUAL(pCylinderLayer->surfaceRepresentation().name(),
std::string("Acts::CylinderSurface"));
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace Layers
} // namespace Test
} // namespace Acts