Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:10:18

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp"
0010 
0011 #include "Acts/Navigation/DetectorVolumeFinders.hpp"
0012 #include "Acts/Navigation/DetectorVolumeUpdaters.hpp"
0013 #include "Acts/Plugins/Json/GridJsonConverter.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 /// @brief  The generator struct
0024 struct IndexedVolumesGenerator {
0025   using value_type = std::size_t;
0026 
0027   /// @brief  Helper function to create and connect the IndexedVolumesImpl
0028   ///
0029   /// @tparam grid_type the type of the grid, indicates also the dimension
0030   ///
0031   /// @param grid the grid object
0032   /// @param bv the bin value array
0033   /// @param transform the transform for the indexed volumes inmplementaiton
0034   ///
0035   /// @return a connected DetectorVolumeUpdater object
0036   template <typename grid_type>
0037   Acts::Experimental::DetectorVolumeUpdater createUpdater(
0038       grid_type&& grid,
0039       const std::array<Acts::BinningValue, grid_type::DIM>& bv,
0040       const Acts::Transform3& transform) {
0041     using IndexedDetectorVolumesImpl = Acts::Experimental::IndexedUpdaterImpl<
0042         grid_type, Acts::Experimental::IndexedDetectorVolumeExtractor,
0043         Acts::Experimental::DetectorVolumeFiller>;
0044 
0045     auto indexedDetectorVolumeImpl =
0046         std::make_unique<const IndexedDetectorVolumesImpl>(std::move(grid), bv,
0047                                                            transform);
0048 
0049     // Create the delegate and connect it
0050     Acts::Experimental::DetectorVolumeUpdater vFinder;
0051     vFinder.connect<&IndexedDetectorVolumesImpl::update>(
0052         std::move(indexedDetectorVolumeImpl));
0053     return vFinder;
0054   }
0055 };
0056 
0057 }  // namespace
0058 
0059 Acts::Experimental::SurfaceCandidatesUpdater
0060 Acts::DetectorVolumeFinderJsonConverter::fromJson(
0061     const nlohmann::json& jVolumeFinder) {
0062   // The return object
0063   auto vFinder = IndexedGridJsonHelper::generateFromJson<
0064       Experimental::DetectorVolumeUpdater, IndexedVolumesGenerator>(
0065       jVolumeFinder, "IndexedVolumes");
0066   if (vFinder.connected()) {
0067     return vFinder;
0068   }
0069   // Return
0070   return Experimental::tryRootVolumes();
0071 }