Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimpleGeometryTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SimpleGeometryTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-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/unit_test.hpp>
10 
23 
24 #include <functional>
25 #include <memory>
26 #include <string>
27 #include <utility>
28 #include <vector>
29 
30 using namespace Acts::UnitLiterals;
31 
32 namespace Acts {
33 namespace Test {
34 
35 // Create a test context
37 
41 BOOST_AUTO_TEST_CASE(SimpleGeometryTest) {
42  Logging::Level surfaceLLevel = Logging::INFO;
43  Logging::Level layerLLevel = Logging::INFO;
44  Logging::Level volumeLLevel = Logging::INFO;
45 
46  // configure surface array creator
48  auto surfaceArrayCreator = std::make_shared<const SurfaceArrayCreator>(
49  sacConfig, getDefaultLogger("SurfaceArrayCreator", surfaceLLevel));
50  // configure the layer creator that uses the surface array creator
51  LayerCreator::Config lcConfig;
52  lcConfig.surfaceArrayCreator = surfaceArrayCreator;
53  auto layerCreator = std::make_shared<const LayerCreator>(
54  lcConfig, getDefaultLogger("LayerCreator", layerLLevel));
55  // configure the layer array creator
56  LayerArrayCreator::Config lacConfig;
57  auto layerArrayCreator = std::make_shared<const LayerArrayCreator>(
58  lacConfig, getDefaultLogger("LayerArrayCreator", layerLLevel));
59 
60  // tracking volume array creator
62  auto tVolumeArrayCreator = std::make_shared<const TrackingVolumeArrayCreator>(
63  tvacConfig, getDefaultLogger("TrackingVolumeArrayCreator", volumeLLevel));
64  // configure the cylinder volume helper
66  cvhConfig.layerArrayCreator = layerArrayCreator;
67  cvhConfig.trackingVolumeArrayCreator = tVolumeArrayCreator;
68  auto cylinderVolumeHelper = std::make_shared<const CylinderVolumeHelper>(
69  cvhConfig, getDefaultLogger("CylinderVolumeHelper", volumeLLevel));
70 
71  // ----------------- build a beam pipe -----------------------------------
73  bplConfig.layerIdentification = "BeamPipe";
74  bplConfig.centralLayerRadii = std::vector<double>(1, 3_mm);
75  bplConfig.centralLayerHalflengthZ = std::vector<double>(1, 40_mm);
76  bplConfig.centralLayerThickness = std::vector<double>(1, 0.8_mm);
77  auto beamPipeBuilder = std::make_shared<const PassiveLayerBuilder>(
78  bplConfig, getDefaultLogger("BeamPipeLayerBuilder", layerLLevel));
79  // create the volume for the beam pipe
81  bpvConfig.trackingVolumeHelper = cylinderVolumeHelper;
82  bpvConfig.volumeName = "BeamPipe";
83  bpvConfig.layerBuilder = beamPipeBuilder;
84  bpvConfig.layerEnvelopeR = {1_mm, 1_mm};
85  bpvConfig.buildToRadiusZero = true;
86  bpvConfig.volumeSignature = 0;
87  auto beamPipeVolumeBuilder = std::make_shared<const CylinderVolumeBuilder>(
88  bpvConfig, getDefaultLogger("BeamPipeVolumeBuilder", volumeLLevel));
89 
90  PassiveLayerBuilder::Config layerBuilderConfig;
91  layerBuilderConfig.layerIdentification = "CentralBarrel";
92  layerBuilderConfig.centralLayerRadii = {10_mm, 20_mm, 30_mm};
93  layerBuilderConfig.centralLayerHalflengthZ = {40_mm, 40_mm, 40_mm};
94  layerBuilderConfig.centralLayerThickness = {1_mm, 1_mm, 1_mm};
95  auto layerBuilder = std::make_shared<const PassiveLayerBuilder>(
96  layerBuilderConfig,
97  getDefaultLogger("CentralBarrelBuilder", layerLLevel));
98  // create the volume for the central barrel
100  cvbConfig.trackingVolumeHelper = cylinderVolumeHelper;
101  cvbConfig.volumeName = "CentralBarrel";
102  cvbConfig.layerBuilder = layerBuilder;
103  cvbConfig.layerEnvelopeR = {1_mm, 1_mm};
104  cvbConfig.buildToRadiusZero = false;
105  cvbConfig.volumeSignature = 0;
106  auto centralVolumeBuilder = std::make_shared<const CylinderVolumeBuilder>(
107  cvbConfig, getDefaultLogger("CentralVolumeBuilder", volumeLLevel));
108 
109  // Make the TrackingGeometry Builder
111  tgbConfig.trackingVolumeBuilders.push_back(
112  [=](const auto& context, const auto& inner, const auto&) {
113  return beamPipeVolumeBuilder->trackingVolume(context, inner);
114  });
115  tgbConfig.trackingVolumeBuilders.push_back(
116  [=](const auto& context, const auto& inner, const auto&) {
117  return centralVolumeBuilder->trackingVolume(context, inner);
118  });
119  tgbConfig.trackingVolumeHelper = cylinderVolumeHelper;
120 
121  TrackingGeometryBuilder tgBuilder(tgbConfig);
122  auto tGeometry = tgBuilder.trackingGeometry(tgContext);
123 
124  BOOST_CHECK(tGeometry != nullptr);
125 }
126 } // namespace Test
127 } // namespace Acts