From cb7425483970277fe33a2edde98a54136e71b70c Mon Sep 17 00:00:00 2001 From: Arthur Hennequin <arthur.hennequin@cern.ch> Date: Thu, 20 Mar 2025 11:52:17 +0100 Subject: [PATCH] Adapt to rapidyaml switch --- .../src/SelectiveElectronMatchAlg.cpp | 20 +++++++++---------- .../CaloFutureReco/src/CaloCorrectionBase.cpp | 10 ++++------ .../CaloFutureReco/src/CaloCorrectionBase.h | 2 +- .../src/ClusterCovarianceMatrixTool.cpp | 4 +--- .../src/SubClusterSelectorTool.cpp | 4 +--- Tr/PatPV/src/PVOfflineTool.cpp | 4 +--- Tr/PrKalmanFilter/src/KalmanFilterTool.cpp | 2 +- 7 files changed, 18 insertions(+), 28 deletions(-) diff --git a/CaloFuture/CaloFuturePIDs/src/SelectiveElectronMatchAlg.cpp b/CaloFuture/CaloFuturePIDs/src/SelectiveElectronMatchAlg.cpp index e3f95028b46..0aeefc606f2 100644 --- a/CaloFuture/CaloFuturePIDs/src/SelectiveElectronMatchAlg.cpp +++ b/CaloFuture/CaloFuturePIDs/src/SelectiveElectronMatchAlg.cpp @@ -17,8 +17,6 @@ #include "Magnet/DeMagnet.h" #include "SelectiveMatchUtils.h" -#include <yaml-cpp/yaml.h> - /** @class SelectiveElectronMatchAlg SelectiveElectronMatchAlg.h * * Matches tracks with local electron hypos in and around calo cell @@ -62,13 +60,13 @@ namespace LHCb::Calo { public: electronXcorrections() = default; // needed by DD4hep even if unused ! - electronXcorrections( YAML::Node const& c ) - : alphaPOut{ c["alphaPOut"].as<std::array<double, 4>>() } - , alphaNOut{ c["alphaNOut"].as<std::array<double, 4>>() } - , alphaPMid{ c["alphaPMid"].as<std::array<double, 4>>() } - , alphaNMid{ c["alphaNMid"].as<std::array<double, 4>>() } - , alphaPInn{ c["alphaPInn"].as<std::array<double, 4>>() } - , alphaNInn{ c["alphaNInn"].as<std::array<double, 4>>() } {} + electronXcorrections( nlohmann::json const& c ) + : alphaPOut{ c["alphaPOut"].get<std::array<double, 4>>() } + , alphaNOut{ c["alphaNOut"].get<std::array<double, 4>>() } + , alphaPMid{ c["alphaPMid"].get<std::array<double, 4>>() } + , alphaNMid{ c["alphaNMid"].get<std::array<double, 4>>() } + , alphaPInn{ c["alphaPInn"].get<std::array<double, 4>>() } + , alphaNInn{ c["alphaNInn"].get<std::array<double, 4>>() } {} const std::array<double, 4>& operator()( const int area, const int charge, const int polarity ) const { bool qpolarity = charge * polarity > 0; @@ -186,8 +184,8 @@ namespace LHCb::Calo { // ============================================================================ StatusCode SelectiveElectronMatchAlg::initialize() { auto sc = Transformer::initialize().andThen( [&] { - addConditionDerivation<electronXcorrections( YAML::Node const& )>( { m_xcorrectionlocation.value() }, - inputLocation<electronXcorrections>() ); + addConditionDerivation<electronXcorrections( nlohmann::json const& )>( { m_xcorrectionlocation.value() }, + inputLocation<electronXcorrections>() ); } ); return sc; } diff --git a/CaloFuture/CaloFutureReco/src/CaloCorrectionBase.cpp b/CaloFuture/CaloFutureReco/src/CaloCorrectionBase.cpp index 418cf44d125..d7a9f04a09b 100644 --- a/CaloFuture/CaloFutureReco/src/CaloCorrectionBase.cpp +++ b/CaloFuture/CaloFutureReco/src/CaloCorrectionBase.cpp @@ -13,8 +13,6 @@ #include "Core/FloatComparison.h" #include "Event/ProtoParticle.h" -#include <yaml-cpp/yaml.h> - using namespace LHCb::Math::Approx; namespace Gaudi::Parsers { @@ -121,12 +119,12 @@ namespace LHCb::Calo::Correction { StatusCode Base::initialize() { return ConditionAccessorHolder::initialize().andThen( [&]() -> StatusCode { if ( m_hypos.empty() ) return Error( "Empty vector of allowed Calorimeter Hypotheses!" ); - addConditionDerivation( { m_conditionName }, m_params.key(), [&]( YAML::Node const& cond ) { + addConditionDerivation( { m_conditionName }, m_params.key(), [&]( nlohmann::json const& cond ) { Parameters params; - for ( auto it = cond.begin(); it != cond.end(); it++ ) { - auto type = accept( it->first.as<std::string>() ); + for ( auto& [key, val] : cond.items() ) { + auto type = accept( key ); if ( !type ) continue; - const auto& parVec = it->second.as<std::vector<double>>(); + const auto& parVec = val.get<std::vector<double>>(); if ( parVec.size() < 2 ) { error() << " # of parameters is insufficient!!" << endmsg; continue; diff --git a/CaloFuture/CaloFutureReco/src/CaloCorrectionBase.h b/CaloFuture/CaloFutureReco/src/CaloCorrectionBase.h index 758b43b45c5..cebd8ea3c52 100644 --- a/CaloFuture/CaloFutureReco/src/CaloCorrectionBase.h +++ b/CaloFuture/CaloFutureReco/src/CaloCorrectionBase.h @@ -247,7 +247,7 @@ namespace LHCb::Calo::Correction { ConditionAccessor<Parameters> m_params{ this, name() + "-Parameters" }; void constructParams( Functions&, const LHCb::span<const double> ); - Parameters constructParams( YAML::Node const& ); + Parameters constructParams( nlohmann::json const& ); public: // required by clients to retrieve internal condition m_param diff --git a/CaloFuture/CaloFutureReco/src/ClusterCovarianceMatrixTool.cpp b/CaloFuture/CaloFutureReco/src/ClusterCovarianceMatrixTool.cpp index 36fb5eba008..f639414c1fe 100644 --- a/CaloFuture/CaloFutureReco/src/ClusterCovarianceMatrixTool.cpp +++ b/CaloFuture/CaloFutureReco/src/ClusterCovarianceMatrixTool.cpp @@ -10,8 +10,6 @@ \*****************************************************************************/ #include "ClusterCovarianceMatrixTool.h" -#include <yaml-cpp/yaml.h> - /** @file * * Implementation file for class FutureClusterCovarianceMatrixTool @@ -55,7 +53,7 @@ namespace LHCb::Calo { // depends on m_conditionName so that calls to m_dbAccessor give proper results addConditionDerivation( { m_conditionName, m_dbAccessor->getParamConditionPath() }, m_parameters.key(), - [&]( YAML::Node const&, Correction::Parameters const& baseParams ) { return getParams( baseParams ); } ); + [&]( nlohmann::json const&, Correction::Parameters const& baseParams ) { return getParams( baseParams ); } ); return StatusCode::SUCCESS; } ); } diff --git a/CaloFuture/CaloFutureReco/src/SubClusterSelectorTool.cpp b/CaloFuture/CaloFutureReco/src/SubClusterSelectorTool.cpp index 62806e4d5ea..ae6fcf8b870 100644 --- a/CaloFuture/CaloFutureReco/src/SubClusterSelectorTool.cpp +++ b/CaloFuture/CaloFutureReco/src/SubClusterSelectorTool.cpp @@ -12,8 +12,6 @@ #include "fmt/format.h" -#include <yaml-cpp/yaml.h> - //----------------------------------------------------------------------------- // Implementation file for class : SubClusterSelectorTool // @@ -46,7 +44,7 @@ namespace LHCb::Calo { // depends on m_condition so that calls to m_dbAccessor give proper results addConditionDerivation( { m_condition, m_dbAccessor->getParamConditionPath() }, m_tags.key(), - [&]( YAML::Node const&, Correction::Parameters const& baseParams ) { return getParams( baseParams ); } ); + [&]( nlohmann::json const&, Correction::Parameters const& baseParams ) { return getParams( baseParams ); } ); return StatusCode::SUCCESS; } ); } diff --git a/Tr/PatPV/src/PVOfflineTool.cpp b/Tr/PatPV/src/PVOfflineTool.cpp index 8303ae727ce..b26f033b2d7 100644 --- a/Tr/PatPV/src/PVOfflineTool.cpp +++ b/Tr/PatPV/src/PVOfflineTool.cpp @@ -30,8 +30,6 @@ #include <string> #include <vector> -#include <yaml-cpp/yaml.h> - class PVOfflineTool : public extends<LHCb::DetDesc::ConditionAccessorHolder<GaudiTool>, IPVOfflineTool> { public: // Standard constructor @@ -243,7 +241,7 @@ StatusCode PVOfflineTool::initialize() { { LHCb::standard_geometry_top, LHCb::Det::VP::det_path }, m_ir.key() ); #else if ( Gaudi::Utils::CheckData<Condition>()( this->detSvc(), LHCb::Conditions::InteractionRegion::ConditionPath ) ) { - addConditionDerivation<LHCb::Conditions::InteractionRegion( const YAML::Node& )>( + addConditionDerivation<LHCb::Conditions::InteractionRegion( const nlohmann::json& )>( { LHCb::Conditions::InteractionRegion::ConditionPath }, m_ir.key() ); } else { addConditionDerivation<LHCb::Conditions::InteractionRegion( const DeVP& vp )>( { LHCb::Det::VP::det_path }, diff --git a/Tr/PrKalmanFilter/src/KalmanFilterTool.cpp b/Tr/PrKalmanFilter/src/KalmanFilterTool.cpp index e8e41b54122..cfacb6922e6 100644 --- a/Tr/PrKalmanFilter/src/KalmanFilterTool.cpp +++ b/Tr/PrKalmanFilter/src/KalmanFilterTool.cpp @@ -629,7 +629,7 @@ namespace LHCb::Pr { #else if ( auto* detSvc = this->service( "DetectorDataSvc" ).get(); Gaudi::Utils::CheckData<Condition>()( dynamic_cast<IDataProviderSvc*>( detSvc ), LHCb::Conditions::InteractionRegion::ConditionPath ) ) { - addConditionDerivation<LHCb::Conditions::InteractionRegion( const YAML::Node& )>( + addConditionDerivation<LHCb::Conditions::InteractionRegion( const nlohmann::json& )>( { LHCb::Conditions::InteractionRegion::ConditionPath }, inputLocation<Conditions::InteractionRegion>() ); } else { addConditionDerivation<Conditions::InteractionRegion( const DeVP& vp )>( -- GitLab