Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CubicBVHTrackingGeometry.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CubicBVHTrackingGeometry.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-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 #pragma once
10 
15 #include "Acts/Geometry/Volume.hpp"
17 
18 #include <array>
19 #include <vector>
20 
21 namespace Acts {
22 namespace Test {
23 
26 
33  CubicBVHTrackingGeometry(size_t n = 29, double hl = 1000, size_t octd = 5) {
34  Box::Size size(Acts::Vector3(2, 2, 2));
35 
36  std::shared_ptr<CuboidVolumeBounds> vbds =
37  std::make_shared<CuboidVolumeBounds>(10, 10, 10);
38 
39  double min = -hl;
40  double max = hl;
41 
42  double step = (max - min) / double(n);
43  std::vector<std::unique_ptr<const Volume>> boxVolumes;
44  std::vector<std::unique_ptr<Box>> boxStore;
45  boxStore.reserve((n + 1) * (n + 1) * (n + 1));
46 
47  std::vector<Box*> boxes;
48  boxes.reserve(boxStore.size());
49 
50  for (size_t i = 0; i <= n; i++) {
51  for (size_t j = 0; j <= n; j++) {
52  for (size_t k = 0; k <= n; k++) {
53  Vector3 pos(min + i * step, min + j * step, min + k * step);
54 
55  auto trf = Transform3(Translation3(pos));
56  auto vol = std::make_unique<AbstractVolume>(trf, vbds);
57 
58  boxVolumes.push_back(std::move(vol));
59  boxStore.push_back(
60  std::make_unique<Box>(boxVolumes.back()->boundingBox()));
61  boxes.push_back(boxStore.back().get());
62  }
63  }
64  }
65 
66  Box* top = make_octree(boxStore, boxes, octd);
67 
68  // create trackingvolume
69  // will own the volumes, so make non-owning copy first
70  volumes.reserve(boxVolumes.size());
71  for (auto& vol : boxVolumes) {
72  volumes.push_back(vol.get());
73  }
74 
75  // box like overall shape
76  auto tvBounds =
77  std::make_shared<CuboidVolumeBounds>(hl * 1.1, hl * 1.1, hl * 1.1);
78 
79  auto tv = TrackingVolume::create(Transform3::Identity(), tvBounds,
80  std::move(boxStore), std::move(boxVolumes),
81  top, nullptr, "TheVolume");
82 
83  trackingGeometry = std::make_shared<TrackingGeometry>(tv);
84  }
85  std::vector<const Volume*> volumes;
86  std::shared_ptr<TrackingGeometry> trackingGeometry;
87 };
88 
89 } // namespace Test
90 } // namespace Acts