Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:42

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2021-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 #pragma once
0010 
0011 #include "Acts/Plugins/Json/ActsJson.hpp"
0012 #include "Acts/Utilities/BinUtility.hpp"
0013 #include "Acts/Utilities/BinningData.hpp"
0014 #include "Acts/Utilities/BinningType.hpp"
0015 #include "Acts/Utilities/RangeXD.hpp"
0016 
0017 #include <nlohmann/json.hpp>
0018 
0019 // Custom Json encoder/decoders. Naming is mandated by nlohmann::json and thus
0020 // can not match our naming guidelines.
0021 
0022 namespace Acts {
0023 class BinningData;
0024 
0025 void to_json(nlohmann::json& j, const BinningData& bd);
0026 
0027 void from_json(const nlohmann::json& j, BinningData& bd);
0028 
0029 void to_json(nlohmann::json& j, const BinUtility& bu);
0030 
0031 void from_json(const nlohmann::json& j, BinUtility& bu);
0032 
0033 template <typename Type>
0034 void to_json(nlohmann::json& j, const Range1D<Type>& r) {
0035   j["min"] = r.min();
0036   j["max"] = r.max();
0037 }
0038 
0039 template <typename Type>
0040 void from_json(const nlohmann::json& j, Range1D<Type>& r) {
0041   r.setMin(static_cast<Type>(j["min"]));
0042   r.setMax(static_cast<Type>(j["max"]));
0043 }
0044 
0045 NLOHMANN_JSON_SERIALIZE_ENUM(BinningValue, {{BinningValue::binX, "binX"},
0046                                             {BinningValue::binY, "binY"},
0047                                             {BinningValue::binZ, "binZ"},
0048                                             {BinningValue::binR, "binR"},
0049                                             {BinningValue::binPhi, "binPhi"},
0050                                             {BinningValue::binRPhi, "binRPhi"},
0051                                             {BinningValue::binH, "binH"},
0052                                             {BinningValue::binEta, "binEta"},
0053                                             {BinningValue::binMag, "binMag"}})
0054 
0055 }  // namespace Acts