Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TelescopeDetectorElement.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TelescopeDetectorElement.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020-2021 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 
16 
17 #include <memory>
18 #include <utility>
19 #include <vector>
20 
21 namespace Acts {
22 class Surface;
23 class PlanarBounds;
24 class DiscBounds;
25 class ISurfaceMaterial;
26 } // namespace Acts
27 
28 namespace ActsExamples {
29 namespace Telescope {
30 
36  public:
39  struct ContextType {
41  unsigned int iov = 0;
42  };
43 
52  std::shared_ptr<const Acts::Transform3> transform,
53  std::shared_ptr<const Acts::PlanarBounds> pBounds, double thickness,
54  std::shared_ptr<const Acts::ISurfaceMaterial> material = nullptr);
55 
64  std::shared_ptr<const Acts::Transform3> transform,
65  std::shared_ptr<const Acts::DiscBounds> dBounds, double thickness,
66  std::shared_ptr<const Acts::ISurfaceMaterial> material = nullptr);
67 
69  ~TelescopeDetectorElement() override = default;
70 
72  const Acts::Surface& surface() const final;
73 
75  Acts::Surface& surface() final;
76 
78  double thickness() const final;
79 
85  const Acts::Transform3& transform(
86  const Acts::GeometryContext& gctx) const final;
87 
91  const Acts::Transform3& nominalTransform(
92  const Acts::GeometryContext& gctx) const;
93 
98  void addAlignedTransform(std::unique_ptr<Acts::Transform3> alignedTransform,
99  unsigned int iov);
100 
102  const std::vector<std::unique_ptr<Acts::Transform3>>& alignedTransforms()
103  const;
104 
105  private:
107  std::shared_ptr<const Acts::Transform3> m_elementTransform = nullptr;
108  // the aligned transforms
109  std::vector<std::unique_ptr<Acts::Transform3>> m_alignedTransforms = {};
111  std::shared_ptr<Acts::Surface> m_elementSurface = nullptr;
113  double m_elementThickness = 0.;
115  std::shared_ptr<const Acts::PlanarBounds> m_elementPlanarBounds = nullptr;
117  std::shared_ptr<const Acts::DiscBounds> m_elementDiscBounds = nullptr;
118 };
119 
121  return *m_elementSurface;
122 }
123 
125  return *m_elementSurface;
126 }
127 
128 inline double TelescopeDetectorElement::thickness() const {
129  return m_elementThickness;
130 }
131 
133  const Acts::GeometryContext& gctx) const {
134  // Check if a different transform than the nominal exists
135  if (!m_alignedTransforms.empty()) {
136  // cast into the right context object
137  auto alignContext = gctx.get<ContextType>();
138  return (*m_alignedTransforms[alignContext.iov].get());
139  }
140  // Return the standard transform if not found
141  return nominalTransform(gctx);
142 }
143 
145  const Acts::GeometryContext& /*gctx*/) const {
146  return *m_elementTransform;
147 }
148 
150  std::unique_ptr<Acts::Transform3> alignedTransform, unsigned int iov) {
151  // most standard case, it's just a new one:
152  auto cios = m_alignedTransforms.size();
153  for (unsigned int ic = cios; ic <= iov; ++ic) {
154  m_alignedTransforms.push_back(nullptr);
155  }
156  m_alignedTransforms[iov] = std::move(alignedTransform);
157 }
158 
159 inline const std::vector<std::unique_ptr<Acts::Transform3>>&
161  return m_alignedTransforms;
162 }
163 
164 } // namespace Telescope
165 } // namespace ActsExamples