Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:08:07

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/DetectorCommons/StructureSelector.hpp"
0010 
0011 #include "ActsExamples/Utilities/GroupBy.hpp"
0012 
0013 namespace {
0014 
0015 struct SensitiveGetter {
0016   std::vector<std::shared_ptr<const Acts::Surface>> selected;
0017   /// @brief Visitor call operator
0018   /// @param surface
0019   void operator()(const Acts::Surface* surface) {
0020     if (surface != nullptr) {
0021       auto geoId = surface->geometryId();
0022       if (geoId.sensitive() != 0u || surface->isSensitive()) {
0023         selected.emplace_back(surface->getSharedPtr());
0024       }
0025     }
0026   }
0027 };
0028 
0029 }  // namespace
0030 
0031 ActsExamples::StructureSelector::StructureSelector(
0032     std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry)
0033     : m_trackingGeometry(std::move(trackingGeometry)) {
0034   if (!m_trackingGeometry) {
0035     throw std::runtime_error("Tracking geometry is not provided");
0036   }
0037   SensitiveGetter getter;
0038   m_trackingGeometry->visitSurfaces(getter);
0039   m_surfaceMultiSet = GeometryIdMultiset<std::shared_ptr<const Acts::Surface>>(
0040       getter.selected.begin(), getter.selected.end());
0041 }
0042 
0043 std::vector<std::shared_ptr<const Acts::Surface>>
0044 ActsExamples::StructureSelector::selectSurfaces(
0045     const Acts::GeometryIdentifier& geoId) const {
0046   auto selectedRange =
0047       selectLowestNonZeroGeometryObject(m_surfaceMultiSet, geoId);
0048   return {selectedRange.begin(), selectedRange.end()};
0049 }
0050 
0051 std::unordered_map<Acts::GeometryIdentifier, Acts::Transform3>
0052 ActsExamples::StructureSelector::selectedTransforms(
0053     const Acts::GeometryContext& gctx,
0054     const Acts::GeometryIdentifier& geoId) const {
0055   std::unordered_map<Acts::GeometryIdentifier, Acts::Transform3> transforms;
0056   auto selectedSurfaces = selectSurfaces(geoId);
0057   for (const auto& surface : selectedSurfaces) {
0058     transforms[surface->geometryId()] = surface->localToGlobalTransform(gctx);
0059   }
0060   return transforms;
0061 }