Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-20 09:27:57

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 "ActsPlugins/Detray/DetrayJsonConverter.hpp"
0010 
0011 #include "ActsPlugins/Detray/DetraySurfaceGridPolicy.hpp"
0012 
0013 #include <memory>
0014 
0015 #include <nlohmann/json.hpp>
0016 
0017 namespace ActsPlugins {
0018 
0019 namespace {
0020 
0021 nlohmann::json encodeDetraySurfaceGridPolicy(
0022     const DetraySurfaceGridPolicy& policy,
0023     const Acts::TrackingGeometryJsonConverter& /*converter*/) {
0024   const DetraySurfaceGridConfig& cfg = policy.config();
0025   nlohmann::json j;
0026   j["kind"] = kDetraySurfaceGridPolicyJsonKind;
0027   j["vertexZHalfRange"] = cfg.vertexZHalfRange;
0028   j["minPt"] = cfg.minPt;
0029   j["bField"] = cfg.bField;
0030   j["nVertexZ"] = cfg.nVertexZ;
0031   j["nCurvature"] = cfg.nCurvature;
0032   j["maxSampleSpacing"] = cfg.maxSampleSpacing;
0033   if (cfg.numberOfBinsFactor.has_value()) {
0034     j["numberOfBinsFactor"] = *cfg.numberOfBinsFactor;
0035   }
0036   return j;
0037 }
0038 
0039 std::unique_ptr<Acts::INavigationPolicy> decodeDetraySurfaceGridPolicy(
0040     const nlohmann::json& j, const Acts::GeometryContext& gctx,
0041     const Acts::TrackingGeometryJsonConverter& /*converter*/,
0042     const Acts::TrackingVolume& volume, const Acts::Logger& logger) {
0043   DetraySurfaceGridConfig cfg;
0044   cfg.vertexZHalfRange = j.at("vertexZHalfRange").get<double>();
0045   cfg.minPt = j.at("minPt").get<double>();
0046   cfg.bField = j.at("bField").get<double>();
0047   cfg.nVertexZ = j.at("nVertexZ").get<std::size_t>();
0048   cfg.nCurvature = j.at("nCurvature").get<std::size_t>();
0049   cfg.maxSampleSpacing = j.at("maxSampleSpacing").get<double>();
0050   cfg.numberOfBinsFactor = std::nullopt;
0051   if (j.contains("numberOfBinsFactor")) {
0052     cfg.numberOfBinsFactor = j.at("numberOfBinsFactor").get<double>();
0053   }
0054   return std::make_unique<DetraySurfaceGridPolicy>(gctx, volume, logger, cfg);
0055 }
0056 
0057 }  // namespace
0058 
0059 void addDetrayNavigationPolicies(
0060     Acts::TrackingGeometryJsonConverter::Config& config) {
0061   config.encodeNavigationPolicy.registerFunction(encodeDetraySurfaceGridPolicy);
0062   config.decodeNavigationPolicy.registerKind(kDetraySurfaceGridPolicyJsonKind,
0063                                              decodeDetraySurfaceGridPolicy);
0064 }
0065 
0066 }  // namespace ActsPlugins