ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlignedDetectorElement.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AlignedDetectorElement.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 #include <memory>
12 
20 
21 namespace FW {
22 
23 namespace Contextual {
24 
38  public:
41  struct ContextType {
43  unsigned int iov = 0;
44  };
45 
49  template <typename... Args>
50  AlignedDetectorElement(Args&&... args)
51  : Generic::GenericDetectorElement(std::forward<Args>(args)...) {}
52 
59  const Acts::GeometryContext& gctx) const final override;
60 
65  const Acts::GeometryContext& gctx) const;
66 
71  void addAlignedTransform(std::unique_ptr<Acts::Transform3D> alignedTransform,
72  unsigned int iov);
73 
75  const std::vector<std::unique_ptr<Acts::Transform3D>>& alignedTransforms()
76  const;
77 
78  private:
79  std::vector<std::unique_ptr<Acts::Transform3D>> m_alignedTransforms;
80 };
81 
83  const Acts::GeometryContext& gctx) const {
84  // Check if a different transform than the nominal exists
85  if (m_alignedTransforms.size()) {
86  // cast into the right context object
87  auto alignContext = std::any_cast<ContextType>(gctx);
88  return (*m_alignedTransforms[alignContext.iov].get());
89  }
90  // Return the standard transform if not found
91  return nominalTransform(gctx);
92 }
93 
95  const Acts::GeometryContext& gctx) const {
97 }
98 
100  std::unique_ptr<Acts::Transform3D> alignedTransform, unsigned int iov) {
101  // most standard case, it's just a new one:
102  auto cios = m_alignedTransforms.size();
103  for (unsigned int ic = cios; ic <= iov; ++ic) {
104  m_alignedTransforms.push_back(nullptr);
105  }
106  m_alignedTransforms[iov] = std::move(alignedTransform);
107 }
108 
109 inline const std::vector<std::unique_ptr<Acts::Transform3D>>&
111  return m_alignedTransforms;
112 }
113 
114 } // end of namespace Contextual
115 } // end of namespace FW