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/DetectorVolumeFinderJsonConverter.hpp"
0010 
0011 #include "Acts/Navigation/DetectorVolumeFinders.hpp"
0012 #include "Acts/Navigation/NavigationDelegates.hpp"
0013 #include "Acts/Navigation/PortalNavigation.hpp"
0014 #include "Acts/Plugins/Json/GridJsonConverter.hpp"
0015 #include "Acts/Plugins/Json/UtilitiesJsonConverter.hpp"
0016 #include "Acts/Utilities/GridAxisGenerators.hpp"
0017 
0018 #include <array>
0019 #include <memory>
0020 #include <tuple>
0021 #include <vector>
0022 
0023 namespace {
0024 /// @brief  The generator struct
0025 struct IndexedVolumesGenerator {
0026   using value_type = std::size_t;
0027 
0028   /// @brief  Helper function to create and connect the IndexedVolumesImpl
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 volumes inmplementaiton
0035   ///
0036   /// @return a connected ExternalNavigationDelegate object
0037   template <typename grid_type>
0038   Acts::Experimental::ExternalNavigationDelegate createUpdater(
0039       grid_type&& grid,
0040       const std::array<Acts::AxisDirection, grid_type::DIM>& bv,
0041       const Acts::Transform3& transform) {
0042     using IndexedDetectorVolumesImpl =
0043         Acts::Experimental::IndexedGridNavigation<
0044             Acts::Experimental::IExternalNavigation, grid_type,
0045             Acts::Experimental::IndexedDetectorVolumeExtractor,
0046             Acts::Experimental::DetectorVolumeFiller>;
0047 
0048     auto indexedDetectorVolumeImpl =
0049         std::make_unique<const IndexedDetectorVolumesImpl>(
0050             std::forward<grid_type>(grid), bv, transform);
0051 
0052     // Create the delegate and connect it
0053     Acts::Experimental::ExternalNavigationDelegate vFinder;
0054     vFinder.connect<&IndexedDetectorVolumesImpl::update>(
0055         std::move(indexedDetectorVolumeImpl));
0056     return vFinder;
0057   }
0058 };
0059 
0060 }  // namespace
0061 
0062 Acts::Experimental::ExternalNavigationDelegate
0063 Acts::DetectorVolumeFinderJsonConverter::fromJson(
0064     const nlohmann::json& jVolumeFinder) {
0065   // The return object
0066   auto vFinder = IndexedGridJsonHelper::generateFromJson<
0067       Experimental::ExternalNavigationDelegate, IndexedVolumesGenerator>(
0068       jVolumeFinder, "IndexedVolumes");
0069   if (vFinder.connected()) {
0070     return vFinder;
0071   }
0072   // Return
0073   return Experimental::tryRootVolumes();
0074 }