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