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