File indexing completed on 2025-10-25 07:56:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Navigation/DetectorVolumeFinders.hpp"
0012 #include "Acts/Navigation/NavigationDelegates.hpp"
0013 #include "Acts/Navigation/PortalNavigation.hpp"
0014 #include "Acts/Utilities/AxisDefinitions.hpp"
0015 #include "Acts/Utilities/Grid.hpp"
0016 #include "ActsPlugins/Json/DetrayJsonHelper.hpp"
0017 #include "ActsPlugins/Json/IndexedGridJsonHelper.hpp"
0018
0019 #include <vector>
0020
0021 namespace Acts::DetectorVolumeFinderJsonConverter {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 template <typename instance_type>
0032 void convert(nlohmann::json& jIndexedVolumes,
0033 const Experimental::ExternalNavigationDelegate& delegate,
0034 bool detray, [[maybe_unused]] const instance_type& refInstance) {
0035 using GridType = typename instance_type::template grid_type<std::size_t>;
0036
0037 using DelegateType = Experimental::IndexedGridNavigation<
0038 Experimental::IExternalNavigation, GridType,
0039 Experimental::IndexedDetectorVolumeExtractor,
0040 Experimental::DetectorVolumeFiller>;
0041
0042 const auto* instance = delegate.instance();
0043 auto castedDelegate = dynamic_cast<const DelegateType*>(instance);
0044 if (castedDelegate != nullptr) {
0045 jIndexedVolumes = IndexedGridJsonHelper::convertImpl<DelegateType>(
0046 *castedDelegate, detray, false);
0047 if (detray) {
0048 jIndexedVolumes["volume_link"] = 1;
0049 nlohmann::json jAccLink;
0050 jAccLink["type"] =
0051 DetrayJsonHelper::accelerationLink(castedDelegate->casts);
0052 jAccLink["index"] = 0;
0053 jIndexedVolumes["acc_link"] = jAccLink;
0054 } else {
0055 jIndexedVolumes["type"] = "IndexedVolumes";
0056 }
0057 }
0058 }
0059
0060
0061
0062
0063
0064
0065 template <typename... Args>
0066 void unrollConvert(nlohmann::json& jIndexedVolumes,
0067 const Experimental::ExternalNavigationDelegate& delegate,
0068 bool detray, TypeList<Args...> ) {
0069 (convert(jIndexedVolumes, delegate, detray, Args{}), ...);
0070 }
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 static inline nlohmann::json toJson(
0084 const Experimental::ExternalNavigationDelegate& delegate,
0085 bool detray = false) {
0086
0087 nlohmann::json jIndexedVolumes;
0088 unrollConvert(jIndexedVolumes, delegate, detray,
0089 GridAxisGenerators::PossibleAxes{});
0090
0091 return jIndexedVolumes;
0092 }
0093
0094
0095
0096
0097
0098
0099 Experimental::ExternalNavigationDelegate fromJson(
0100 const nlohmann::json& jVolumeFinder);
0101
0102 }