Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-09 08:30:23

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/Json/GbtsConfigJsonConverter.hpp"
0010 
0011 #include "ActsPlugins/Json/detail/JsonIo.hpp"
0012 
0013 void Acts::Experimental::to_json(nlohmann::json& j,
0014                                  const GbtsLayerConnection& connection) {
0015   j["outer"] = connection.src;
0016   j["inner"] = connection.dst;
0017 }
0018 
0019 void Acts::Experimental::from_json(const nlohmann::json& j,
0020                                    GbtsLayerConnection& connection) {
0021   connection.src = j.at("outer").get<GbtsExperimentLayerId>();
0022   connection.dst = j.at("inner").get<GbtsExperimentLayerId>();
0023 }
0024 
0025 void Acts::Experimental::to_json(nlohmann::json& j,
0026                                  const GbtsLayerConfig& layer) {
0027   j["id"] = layer.id;
0028   j["type"] = layer.type;
0029   j["technology"] = layer.technology;
0030   j["surfaces"] = layer.surfaces;
0031 }
0032 
0033 void Acts::Experimental::from_json(const nlohmann::json& j,
0034                                    GbtsLayerConfig& layer) {
0035   layer.id = j.at("id").get<GbtsExperimentLayerId>();
0036   layer.type = j.at("type").get<GbtsLayerType>();
0037   layer.technology = j.at("technology").get<GbtsLayerTechnology>();
0038   layer.surfaces = j.at("surfaces").get<std::vector<GeometryIdentifier>>();
0039 }
0040 
0041 void Acts::Experimental::to_json(nlohmann::json& j,
0042                                  const GbtsTauBounds& bounds) {
0043   j["minTau"] = bounds.minTau;
0044   j["maxTau"] = bounds.maxTau;
0045   j["minTauNearEdge"] = bounds.minTauNearEdge;
0046   j["maxTauNearEdge"] = bounds.maxTauNearEdge;
0047 }
0048 
0049 void Acts::Experimental::from_json(const nlohmann::json& j,
0050                                    GbtsTauBounds& bounds) {
0051   bounds.minTau = j.at("minTau").get<float>();
0052   bounds.maxTau = j.at("maxTau").get<float>();
0053   bounds.minTauNearEdge = j.at("minTauNearEdge").get<float>();
0054   bounds.maxTauNearEdge = j.at("maxTauNearEdge").get<float>();
0055 }
0056 
0057 std::vector<Acts::Experimental::GbtsLayerConfig>
0058 Acts::Experimental::readGbtsLayers(const std::filesystem::path& path) {
0059   return Acts::detail::readJsonFile(path)
0060       .at("layers")
0061       .get<std::vector<GbtsLayerConfig>>();
0062 }
0063 
0064 std::vector<Acts::Experimental::GbtsLayerConnection>
0065 Acts::Experimental::readGbtsConnections(const std::filesystem::path& path) {
0066   return Acts::detail::readJsonFile(path)
0067       .at("connections")
0068       .get<std::vector<GbtsLayerConnection>>();
0069 }
0070 
0071 void Acts::Experimental::writeGbtsConnections(
0072     const std::filesystem::path& path,
0073     const std::vector<GbtsLayerConnection>& connections) {
0074   Acts::detail::writeJsonFile(
0075       path, nlohmann::json{{"connections", connections}}, 4, 0);
0076 }
0077 
0078 Acts::Experimental::GbtsTauLookupTable
0079 Acts::Experimental::readGbtsTauLookupTable(const std::filesystem::path& path) {
0080   return Acts::detail::readJsonFile(path)
0081       .at("tauLookupTable")
0082       .get<GbtsTauLookupTable>();
0083 }