Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:15:17

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 "Acts/Plugins/Json/AmbiguityConfigJsonConverter.hpp"
0010 
0011 #include "Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp"
0012 #include "Acts/Plugins/Json/ActsJson.hpp"
0013 
0014 namespace Acts {
0015 
0016 void from_json(const nlohmann::json& j, ConfigPair& p) {
0017   std::vector<ScoreBasedAmbiguityResolution::DetectorConfig> detectorConfigs;
0018   std::map<std::size_t, std::size_t> volumeMap;
0019 
0020   for (auto& [key, value] : j.items()) {
0021     ScoreBasedAmbiguityResolution::DetectorConfig detectorConfig;
0022 
0023     std::size_t detectorId = std::stoi(key);
0024 
0025     detectorConfig.hitsScoreWeight = value["hitsScoreWeight"];
0026     detectorConfig.holesScoreWeight = value["holesScoreWeight"];
0027     detectorConfig.outliersScoreWeight = value["outliersScoreWeight"];
0028     detectorConfig.otherScoreWeight = value["otherScoreWeight"];
0029 
0030     detectorConfig.minHits = value["minHits"];
0031     detectorConfig.maxHits = value["maxHits"];
0032     detectorConfig.maxHoles = value["maxHoles"];
0033     detectorConfig.maxOutliers = value["maxOutliers"];
0034     detectorConfig.maxSharedHits = value["maxSharedHits"];
0035 
0036     detectorConfig.sharedHitsFlag = value["sharedHitsFlag"];
0037 
0038     const std::vector<double>& goodHits = value["goodHits"];
0039     const std::vector<double>& goodHoles = value["goodHoles"];
0040 
0041     const std::vector<double>& fakeHits = value["fakeHits"];
0042     const std::vector<double>& fakeHoles = value["fakeHoles"];
0043 
0044     if (goodHits.size() != fakeHits.size()) {
0045       throw std::invalid_argument("goodHits and FakeHits size mismatch");
0046     }
0047 
0048     for (std::size_t i = 0; i < goodHits.size(); i++) {
0049       detectorConfig.factorHits.push_back(goodHits[i] / fakeHits[i]);
0050     }
0051 
0052     if (goodHoles.size() != fakeHoles.size()) {
0053       throw std::invalid_argument("goodHoles and FakeHoles size mismatch");
0054     }
0055 
0056     for (std::size_t i = 0; i < goodHoles.size(); i++) {
0057       detectorConfig.factorHoles.push_back(goodHoles[i] / fakeHoles[i]);
0058     }
0059 
0060     detectorConfigs.push_back(detectorConfig);
0061 
0062     std::vector<std::size_t> volumesIds = value["volumesIds"];
0063     for (auto volumeId : volumesIds) {
0064       volumeMap[volumeId] = detectorId;
0065     }
0066   }
0067   p = std::make_pair(volumeMap, detectorConfigs);
0068 }
0069 
0070 }  // namespace Acts