Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:15:17

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 "Acts/Plugins/Json/IndexedSurfacesJsonConverter.hpp"
0010 
0011 #include "Acts/Navigation/NavigationStateUpdaters.hpp"
0012 #include "Acts/Plugins/Json/GridJsonConverter.hpp"
0013 #include "Acts/Plugins/Json/IndexedGridJsonHelper.hpp"
0014 #include "Acts/Plugins/Json/UtilitiesJsonConverter.hpp"
0015 #include "Acts/Utilities/GridAxisGenerators.hpp"
0016 
0017 #include <array>
0018 #include <memory>
0019 #include <tuple>
0020 #include <vector>
0021 
0022 namespace {
0023 
0024 /// @brief  The generator struct
0025 struct IndexedSurfacesGenerator {
0026   using value_type = std::vector<std::size_t>;
0027 
0028   /// @brief  Helper function to create and connect the IndexedSurfacesNavigation
0029   ///
0030   /// @tparam grid_type the type of the grid, indicates also the dimension
0031   ///
0032   /// @param grid the grid object
0033   /// @param bv the bin value array
0034   /// @param transform the transform for the indexed surfaces inmplementaiton
0035   ///
0036   /// @return a connected InternalNavigationDelegate object
0037   template <typename grid_type>
0038   Acts::Experimental::InternalNavigationDelegate createUpdater(
0039       grid_type&& grid,
0040       const std::array<Acts::AxisDirection, grid_type::DIM>& bv,
0041       const Acts::Transform3& transform) {
0042     Acts::Experimental::IndexedSurfacesNavigation<grid_type> indexedSurfaces(
0043         std::forward<grid_type>(grid), bv, transform);
0044 
0045     // The portal delegate
0046     Acts::Experimental::AllPortalsNavigation allPortals;
0047 
0048     // The chained delegate: indexed surfaces and all portals
0049     using DelegateType =
0050         Acts::Experimental::IndexedSurfacesAllPortalsNavigation<
0051             grid_type, Acts::Experimental::IndexedSurfacesNavigation>;
0052     auto indexedSurfacesAllPortals = std::make_unique<const DelegateType>(
0053         std::tie(allPortals, indexedSurfaces));
0054 
0055     // Create the delegate and connect it
0056     Acts::Experimental::InternalNavigationDelegate nStateUpdater;
0057     nStateUpdater.connect<&DelegateType::update>(
0058         std::move(indexedSurfacesAllPortals));
0059 
0060     return nStateUpdater;
0061   }
0062 };
0063 
0064 }  // namespace
0065 
0066 Acts::Experimental::InternalNavigationDelegate
0067 Acts::IndexedSurfacesJsonConverter::fromJson(
0068     const nlohmann::json& jSurfaceNavigation) {
0069   if (!jSurfaceNavigation.is_null()) {
0070     // The return object
0071     auto sfCandidates = IndexedGridJsonHelper::generateFromJson<
0072         Experimental::InternalNavigationDelegate, IndexedSurfacesGenerator>(
0073         jSurfaceNavigation, "IndexedSurfaces");
0074     if (sfCandidates.connected()) {
0075       return sfCandidates;
0076     }
0077   }
0078   // Return the object
0079   return Experimental::tryAllPortalsAndSurfaces();
0080 }