Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExternallyAlignedDetectorElement.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExternallyAlignedDetectorElement.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 
18 
19 #include <map>
20 
21 namespace ActsExamples {
22 
23 namespace Contextual {
24 
43  public:
44  struct AlignmentStore {
45  // GenericDetector identifiers are sequential
46  std::vector<Acts::Transform3> transforms;
47  size_t lastAccessed = 0;
48  };
49 
52  struct ContextType {
53  // GenericDetector identifiers are an integer sequence, so vector is fine!
54  std::shared_ptr<const AlignmentStore> alignmentStore{nullptr};
55  };
56 
58 
65  const Acts::GeometryContext& gctx) const override;
66 };
67 
69  const Acts::GeometryContext& gctx) const {
70  if (!gctx.hasValue()) { // Treating empty context => nominal alignment
72  }
73  // cast into the right context object
74  const auto& alignContext = gctx.get<ContextType>();
76 
77  if (alignContext.alignmentStore == nullptr) {
78  // geometry construction => nominal alignment
80  }
81 
82  // At this point, the alignment store should be populated
83  assert(idValue < alignContext.alignmentStore->transforms.size());
84  return alignContext.alignmentStore->transforms[idValue];
85 }
86 
87 } // end of namespace Contextual
88 } // end of namespace ActsExamples