Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingGeometry.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackingGeometry.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-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 
10 
16 
17 #include <algorithm>
18 #include <cstddef>
19 #include <vector>
20 
22  const MutableTrackingVolumePtr& highestVolume,
23  const IMaterialDecorator* materialDecorator,
24  const GeometryIdentifierHook& hook, const Logger& logger)
25  : m_world(highestVolume),
26  m_beam(Surface::makeShared<PerigeeSurface>(Vector3::Zero())) {
27  // Close the geometry: assign geometryID and successively the material
28  size_t volumeID = 0;
29  highestVolume->closeGeometry(materialDecorator, m_volumesById, volumeID, hook,
30  logger);
31  m_volumesById.rehash(0);
32  // fill surface lookup container
33  m_world->visitSurfaces([this](const Acts::Surface* srf) {
34  if (srf != nullptr) {
35  m_surfacesById[srf->geometryId()] = srf;
36  }
37  });
38  m_surfacesById.rehash(0);
39 }
40 
42 
44  const GeometryContext& gctx, const Acts::Vector3& gp) const {
45  const TrackingVolume* searchVolume = m_world.get();
46  const TrackingVolume* currentVolume = nullptr;
47  while (currentVolume != searchVolume && (searchVolume != nullptr)) {
48  currentVolume = searchVolume;
49  searchVolume = searchVolume->lowestTrackingVolume(gctx, gp);
50  }
51  return currentVolume;
52 }
53 
55  const {
56  return m_world.get();
57 }
58 
59 const std::shared_ptr<const Acts::TrackingVolume>&
61  return m_world;
62 }
63 
65  const GeometryContext& gctx, const Acts::Vector3& gp) const {
66  const TrackingVolume* lowestVol = (lowestTrackingVolume(gctx, gp));
67  return lowestVol->associatedLayer(gctx, gp);
68 }
69 
71  std::shared_ptr<const PerigeeSurface> beam) {
72  m_beam = std::move(beam);
73 }
74 
76  return m_beam.get();
77 }
78 
80  GeometryIdentifier id) const {
81  auto vol = m_volumesById.find(id);
82  if (vol == m_volumesById.end()) {
83  return nullptr;
84  }
85  return vol->second;
86 }
87 
89  GeometryIdentifier id) const {
90  auto srf = m_surfacesById.find(id);
91  if (srf == m_surfacesById.end()) {
92  return nullptr;
93  }
94  return srf->second;
95 }