EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CubicTrackingGeometry.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CubicTrackingGeometry.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 
11 // Workaround for building on clang+libstdc++
13 
30 #include "Acts/Utilities/Units.hpp"
31 
32 #include <functional>
33 #include <vector>
34 
35 namespace Acts {
36 namespace Test {
37 
42  CubicTrackingGeometry(std::reference_wrapper<const GeometryContext> gctx)
43  : geoContext(gctx) {
44  using namespace UnitLiterals;
45 
46  // Construct the rotation
47  double rotationAngle = 90_degree;
48  Vector3D xPos(cos(rotationAngle), 0., sin(rotationAngle));
49  Vector3D yPos(0., 1., 0.);
50  Vector3D zPos(-sin(rotationAngle), 0., cos(rotationAngle));
51  rotation.col(0) = xPos;
52  rotation.col(1) = yPos;
53  rotation.col(2) = zPos;
54 
55  // Boundaries of the surfaces
56  rBounds =
57  std::make_shared<const RectangleBounds>(RectangleBounds(0.5_m, 0.5_m));
58 
59  // Material of the surfaces
60  MaterialSlab matProp(makeBeryllium(), 0.5_mm);
61  surfaceMaterial = std::make_shared<HomogeneousSurfaceMaterial>(matProp);
62  }
63 
65  std::shared_ptr<const TrackingGeometry> operator()() {
66  using namespace UnitLiterals;
67 
68  // Set translation vectors
69  double eps = 1_mm;
70  std::vector<Vector3D> translations;
71  translations.push_back({-2_m, 0., 0.});
72  translations.push_back({-1_m, 0., 0.});
73  translations.push_back({1_m - eps, 0., 0.});
74  translations.push_back({1_m + eps, 0., 0.});
75  translations.push_back({2_m - eps, 0., 0.});
76  translations.push_back({2_m + eps, 0., 0.});
77 
78  // Construct surfaces
79  std::array<std::shared_ptr<const Surface>, 6> surfaces;
80  unsigned int i;
81  for (i = 0; i < translations.size(); i++) {
82  Transform3D trafo(Transform3D::Identity() * rotation);
83  trafo.translation() = translations[i];
84  // Create the detector element
85  auto detElement = std::make_unique<const DetectorElementStub>(
86  trafo, rBounds, 1._um, surfaceMaterial);
87  // And remember the surface
88  surfaces[i] = detElement->surface().getSharedPtr();
89  // Add it to the event store
90  detectorStore.push_back(std::move(detElement));
91  }
92 
93  // Construct layers
94  std::array<LayerPtr, 6> layers;
95  for (i = 0; i < 6; i++) {
96  Transform3D trafo(Transform3D::Identity() * rotation);
97  trafo.translation() = translations[i];
98 
99  std::unique_ptr<SurfaceArray> surArray(new SurfaceArray(surfaces[i]));
100 
101  layers[i] =
102  PlaneLayer::create(trafo, rBounds, std::move(surArray), 1._mm);
103 
104  auto mutableSurface = const_cast<Surface*>(surfaces[i].get());
105  mutableSurface->associateLayer(*layers[i]);
106  }
107 
108  // Build volume for surfaces with negative x-values
109  Transform3D trafoVol1(Transform3D::Identity());
110  trafoVol1.translation() = Vector3D(-1.5_m, 0., 0.);
111 
112  auto boundsVol =
113  std::make_shared<const CuboidVolumeBounds>(1.5_m, 0.5_m, 0.5_m);
114 
115  LayerArrayCreator::Config lacConfig;
116  LayerArrayCreator layArrCreator(
117  lacConfig, getDefaultLogger("LayerArrayCreator", Logging::INFO));
118 
119  LayerVector layVec;
120  layVec.push_back(layers[0]);
121  layVec.push_back(layers[1]);
122  std::unique_ptr<const LayerArray> layArr1(layArrCreator.layerArray(
123  geoContext, layVec, -2_m - 1._mm, -1._m + 1._mm, BinningType::arbitrary,
125 
126  auto trackVolume1 =
127  TrackingVolume::create(trafoVol1, boundsVol, nullptr,
128  std::move(layArr1), nullptr, {}, "Volume 1");
129 
130  // Build volume for surfaces with positive x-values
131  Transform3D trafoVol2(Transform3D::Identity());
132  trafoVol2.translation() = Vector3D(1.5_m, 0., 0.);
133 
134  layVec.clear();
135  for (i = 2; i < 6; i++)
136  layVec.push_back(layers[i]);
137  std::unique_ptr<const LayerArray> layArr2(
138  layArrCreator.layerArray(geoContext, layVec, 1._m - 2._mm, 2._m + 2._mm,
140 
141  auto trackVolume2 =
142  TrackingVolume::create(trafoVol2, boundsVol, nullptr,
143  std::move(layArr2), nullptr, {}, "Volume 2");
144 
145  // Glue volumes
146  trackVolume2->glueTrackingVolume(
147  geoContext, BoundarySurfaceFace::negativeFaceYZ, trackVolume1.get(),
149 
150  trackVolume1->glueTrackingVolume(
151  geoContext, BoundarySurfaceFace::positiveFaceYZ, trackVolume2.get(),
153 
154  // Build world volume
155  Transform3D trafoWorld(Transform3D::Identity());
156  trafoWorld.translation() = Vector3D(0., 0., 0.);
157 
158  auto worldVol =
159  std::make_shared<const CuboidVolumeBounds>(3._m, 0.5_m, 0.5_m);
160 
161  std::vector<std::pair<TrackingVolumePtr, Vector3D>> tapVec;
162 
163  tapVec.push_back(std::make_pair(trackVolume1, Vector3D(-1.5_m, 0., 0.)));
164  tapVec.push_back(std::make_pair(trackVolume2, Vector3D(1.5_m, 0., 0.)));
165 
166  std::vector<float> binBoundaries = {-3._m, 0., 3._m};
167 
168  BinningData binData(BinningOption::open, BinningValue::binX, binBoundaries);
169  std::unique_ptr<const BinUtility> bu(new BinUtility(binData));
170 
171  std::shared_ptr<const TrackingVolumeArray> trVolArr(
172  new BinnedArrayXD<TrackingVolumePtr>(tapVec, std::move(bu)));
173 
174  MutableTrackingVolumePtr mtvpWorld(
175  TrackingVolume::create(trafoWorld, worldVol, trVolArr, "World"));
176 
177  // Build and return tracking geometry
178  return std::shared_ptr<TrackingGeometry>(
179  new Acts::TrackingGeometry(mtvpWorld));
180  }
181 
182  RotationMatrix3D rotation = RotationMatrix3D::Identity();
183  std::shared_ptr<const RectangleBounds> rBounds = nullptr;
184  std::shared_ptr<const ISurfaceMaterial> surfaceMaterial = nullptr;
185 
186  std::vector<std::unique_ptr<const DetectorElementStub>> detectorStore = {};
187 
188  std::reference_wrapper<const GeometryContext> geoContext;
189 };
190 } // namespace Test
191 } // namespace Acts