Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KDTreeTrackingGeometryBuilderTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KDTreeTrackingGeometryBuilderTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 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 
16 #include "Acts/Geometry/Extent.hpp"
29 
30 #include <cstddef>
31 #include <memory>
32 #include <optional>
33 #include <string>
34 #include <utility>
35 #include <vector>
36 
37 namespace Acts {
38 
39 using namespace UnitLiterals;
40 
41 namespace Test {
42 
43 BOOST_AUTO_TEST_SUITE(Geometry)
44 
45 BOOST_AUTO_TEST_CASE(KDTreeTrackingGeometryBuilder_simple) {
47  CylindricalTrackingGeometry ctGeometry(tContext);
49 
50  // The collected surfaces
51  std::vector<std::shared_ptr<Surface>> layerSurfacePtrs;
52 
53  // Add a beam pipe
54  auto hTransform = Transform3::Identity();
55  layerSurfacePtrs.push_back(
56  Surface::makeShared<CylinderSurface>(hTransform, 15., 800.));
57 
58  // Pixel Surfaces
59  std::vector<ActsScalar> pLayerRadii = {32., 72., 116., 172.};
60  std::vector<std::pair<int, int>> pLayerBinning = {
61  {16, 14}, {32, 14}, {52, 14}, {78, 14}};
62  std::vector<ActsScalar> pModuleTiltPhi = {0.145, 0.145, 0.145, 0.145};
63  std::vector<ActsScalar> pModuleHalfX = {8.4, 8.4, 8.4, 8.4};
64  std::vector<ActsScalar> pModuleHalfY = {36., 36., 36., 36.};
65  std::vector<ActsScalar> pModuleThickness = {0.15, 0.15, 0.15, 0.15};
66 
67  // Fill surfaces from cylinder layers
68  for (size_t ilp = 0; ilp < pLayerRadii.size(); ++ilp) {
69  std::vector<const Surface*> layerSurfaces = ctGeometry.surfacesCylinder(
70  detectorStore, pModuleHalfX[ilp], pModuleHalfY[ilp],
71  pModuleThickness[ilp], pModuleTiltPhi[ilp], pLayerRadii[ilp], 2_mm,
72  5_mm, pLayerBinning[ilp]);
73 
74  // Make a shared version out of it
75  for (auto& sf : layerSurfaces) {
76  Surface* mutableSf = const_cast<Surface*>(sf);
77  layerSurfacePtrs.push_back(mutableSf->getSharedPtr());
78  }
79  }
80 
81  // Fill surfaces for disc layers
82  std::vector<ActsScalar> discZ = {-700., -600., 600., 700.};
83  std::vector<ActsScalar> discRadii = {60., 60., 60., 60.};
84  std::vector<int> discModules = {22, 22, 22, 22};
85 
86  std::vector<ActsScalar> dModuleHalfXMinY = {6.4, 6.4, 6.4, 6.4};
87  std::vector<ActsScalar> dModuleHalfXMaxY = {12.4, 12.4, 12.4, 12.4};
88  std::vector<ActsScalar> dModuleHalfY = {36., 36., 36., 36.};
89  std::vector<ActsScalar> dModuleTilt = {0.075, 0.075, 0.075, 0.075};
90  std::vector<ActsScalar> dModuleThickness = {0.15, 0.15, 0.15, 0.15};
91 
92  for (size_t ilp = 0; ilp < discZ.size(); ++ilp) {
93  std::vector<const Surface*> layerSurfaces = ctGeometry.surfacesRing(
94  detectorStore, dModuleHalfXMinY[ilp], dModuleHalfXMaxY[ilp],
95  dModuleHalfY[ilp], dModuleThickness[ilp], dModuleTilt[ilp],
96  discRadii[ilp], discZ[ilp], 2., discModules[ilp]);
97  for (auto& sf : layerSurfaces) {
98  Surface* mutableSf = const_cast<Surface*>(sf);
99  layerSurfacePtrs.push_back(mutableSf->getSharedPtr());
100  }
101  }
102 
103  // Make a proto detectpr description
104  Acts::ProtoVolume beamPipeContainer;
105  beamPipeContainer.name = "odd-beam-pipe";
106  beamPipeContainer.extent.set(Acts::binR, 0., 17);
107  Acts::ProtoVolume beamPipe;
108  beamPipe.name = "odd-beam-pipe-l";
109  beamPipe.extent.set(Acts::binR, 2., 16.);
111  Acts::Surface::SurfaceType::Cylinder};
113  {beamPipe}, {Acts::BinningData(Acts::open, Acts::binR, {0., 1.})}, true};
114 
115  // Pixel section
116  Acts::ProtoVolume pixelContainer;
117  pixelContainer.name = "odd-pixel";
118  pixelContainer.extent.set(Acts::binR, 18., 200);
119 
120  Acts::ProtoVolume pixelNec;
121  pixelNec.name = "odd-pixel-nec";
122  pixelNec.extent.set(Acts::binZ, -1000., -580);
123 
124  Acts::ProtoVolume pixNecD1;
125  pixNecD1.name = "odd-pixel-nec-d1";
126  pixNecD1.extent.set(Acts::binZ, -720., -680);
127  Acts::ProtoVolume pixNecD0;
128  pixNecD0.name = "odd-pixel-nec-d0";
129  pixNecD0.extent.set(Acts::binZ, -620., -580);
131  {pixNecD1, pixNecD0},
133  true};
134  for (auto& cv : pixelNec.container.value().constituentVolumes) {
135  cv.internal =
136  Acts::ProtoVolume::InternalStructure{Acts::Surface::SurfaceType::Disc};
137  }
138 
139  Acts::ProtoVolume pixelBarrel;
140  pixelBarrel.name = "odd-pixel-barrel";
141  pixelBarrel.extent.set(Acts::binZ, -580., 580);
142 
143  Acts::ProtoVolume pixBarrelL0;
144  pixBarrelL0.name = "odd-pixel-barrel-l0";
145  pixBarrelL0.extent.set(Acts::binR, 28., 48.);
146  pixBarrelL0.extent.set(Acts::binZ, -580., 580);
148  Acts::Surface::SurfaceType::Cylinder};
149  Acts::ProtoVolume pixBarrelL1;
150  pixBarrelL1.name = "odd-pixel-barrel-l1";
151  pixBarrelL1.extent.set(Acts::binR, 62., 76);
152  pixBarrelL1.extent.set(Acts::binZ, -580., 580);
154  Acts::Surface::SurfaceType::Cylinder};
155  Acts::ProtoVolume pixBarrelL2;
156  pixBarrelL2.name = "odd-pixel-barrel-l2";
157  pixBarrelL2.extent.set(Acts::binR, 100., 120.);
158  pixBarrelL2.extent.set(Acts::binZ, -580., 580);
160  Acts::Surface::SurfaceType::Cylinder};
161  Acts::ProtoVolume pixBarrelL3;
162  pixBarrelL3.name = "odd-pixel-barrel-l3";
163  pixBarrelL3.extent.set(Acts::binR, 160., 180.);
164  pixBarrelL3.extent.set(Acts::binZ, -580., 580);
166  Acts::Surface::SurfaceType::Cylinder};
167 
169  {pixBarrelL0, pixBarrelL1, pixBarrelL2, pixBarrelL3},
171  true};
172 
173  Acts::ProtoVolume pixelPec;
174  pixelPec.name = "odd-pixel-pec";
175  pixelPec.extent.set(Acts::binZ, 580., 1000.);
176 
177  Acts::ProtoVolume pixPecD0;
178  pixPecD0.name = "odd-pixel-pec-d0";
179  pixPecD0.extent.set(Acts::binZ, 580., 620);
180  Acts::ProtoVolume pixPecD1;
181  pixPecD1.name = "odd-pixel-pec-d1";
182  pixPecD1.extent.set(Acts::binZ, 680., 720);
183 
184  pixelPec.container = Acts::ProtoVolume::ContainerStructure{
185  {pixPecD0, pixPecD1},
187  true};
188  for (auto& cv : pixelPec.container.value().constituentVolumes) {
189  cv.internal =
190  Acts::ProtoVolume::InternalStructure{Acts::Surface::SurfaceType::Disc};
191  }
192 
193  pixelContainer.container = Acts::ProtoVolume::ContainerStructure{
194  {pixelNec, pixelBarrel, pixelPec},
196  {-1000., -580., 580., 1000.})}};
197 
198  Acts::ProtoVolume detectorContainer;
199  detectorContainer.name = "odd-detector";
200  detectorContainer.extent.set(Acts::binR, 0., 200);
201  detectorContainer.container = Acts::ProtoVolume::ContainerStructure{
202  {beamPipeContainer, pixelContainer},
203  {Acts::BinningData(Acts::open, Acts::binR, {0., 17.5, 200.})}};
204 
206  detector.name = "odd";
207  detector.worldVolume = detectorContainer;
208 
210 
211  // Surface array creator
212  auto surfaceArrayCreator = std::make_shared<const Acts::SurfaceArrayCreator>(
214  Acts::getDefaultLogger("SurfaceArrayCreator", logLevel));
215  // Layer Creator
217  lcConfig.surfaceArrayCreator = surfaceArrayCreator;
218  auto layerCreator = std::make_shared<Acts::LayerCreator>(
219  lcConfig, Acts::getDefaultLogger("LayerCreator", logLevel));
220  // Layer array creator
222  auto layerArrayCreator = std::make_shared<const Acts::LayerArrayCreator>(
223  lacConfig, Acts::getDefaultLogger("LayerArrayCreator", logLevel));
224  // Tracking volume array creator
226  auto tVolumeArrayCreator =
227  std::make_shared<const Acts::TrackingVolumeArrayCreator>(
228  tvacConfig,
229  Acts::getDefaultLogger("TrackingVolumeArrayCreator", logLevel));
230  // configure the cylinder volume helper
232  cvhConfig.layerArrayCreator = layerArrayCreator;
233  cvhConfig.trackingVolumeArrayCreator = tVolumeArrayCreator;
234  auto cylinderVolumeHelper =
235  std::make_shared<const Acts::CylinderVolumeHelper>(
236  cvhConfig, Acts::getDefaultLogger("CylinderVolumeHelper", logLevel));
237 
238  // The KDT tracking geometry builder
240  kdtgConfig.layerCreator = layerCreator;
241  kdtgConfig.trackingVolumeHelper = cylinderVolumeHelper;
242  // Reserve the right amount of surfaces
243  kdtgConfig.surfaces = layerSurfacePtrs;
244 
245  // Assign the proto detector
246  kdtgConfig.protoDetector = detector;
247 
248  // Make the builder
249  auto kdtTrackingGeometryBuilder = Acts::KDTreeTrackingGeometryBuilder(
250  kdtgConfig,
251  Acts::getDefaultLogger("KDTreeTrackingGeometryBuilder", logLevel));
252 
253  auto trackingGeometry = kdtTrackingGeometryBuilder.trackingGeometry(tContext);
254  BOOST_CHECK(trackingGeometry != nullptr);
255 }
256 
257 BOOST_AUTO_TEST_SUITE_END()
258 
259 } // namespace Test
260 } // namespace Acts