Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:20:55

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 ||
0023           surface->associatedDetectorElement() != nullptr) {
0024         selected.emplace_back(surface->getSharedPtr());
0025       }
0026     }
0027   }
0028 };
0029 
0030 }  // namespace
0031 
0032 ActsExamples::StructureSelector::StructureSelector(
0033     std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry)
0034     : m_trackingGeometry(std::move(trackingGeometry)) {
0035   if (!m_trackingGeometry) {
0036     throw std::runtime_error("Tracking geometry is not provided");
0037   }
0038   SensitiveGetter getter;
0039   m_trackingGeometry->visitSurfaces(getter);
0040   m_surfaceMultiSet = GeometryIdMultiset<std::shared_ptr<const Acts::Surface>>(
0041       getter.selected.begin(), getter.selected.end());
0042 }
0043 
0044 std::vector<std::shared_ptr<const Acts::Surface>>
0045 ActsExamples::StructureSelector::selectSurfaces(
0046     const Acts::GeometryIdentifier& geoId) const {
0047   auto selectedRange =
0048       selectLowestNonZeroGeometryObject(m_surfaceMultiSet, geoId);
0049   return {selectedRange.begin(), selectedRange.end()};
0050 }
0051 
0052 std::unordered_map<Acts::GeometryIdentifier, Acts::Transform3>
0053 ActsExamples::StructureSelector::selectedTransforms(
0054     const Acts::GeometryContext& gctx,
0055     const Acts::GeometryIdentifier& geoId) const {
0056   std::unordered_map<Acts::GeometryIdentifier, Acts::Transform3> transforms;
0057   auto selectedSurfaces = selectSurfaces(geoId);
0058   for (const auto& surface : selectedSurfaces) {
0059     transforms[surface->geometryId()] = surface->transform(gctx);
0060   }
0061   return transforms;
0062 }