From 8f0094c1cf795305f212b2387ae391a6ea615693 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Wed, 14 Feb 2024 13:36:29 -0500 Subject: [PATCH] xAODBTaggingEfficiency: Fix cppcheck 2.14 warnings. Pass strings by const reference, not by value. Copying values in range-for. Prefer returning const references to members rather than copies. --- .../Root/BTaggingEigenVectorRecompositionTool.cxx | 4 ++-- .../Root/BTaggingTruthTaggingTool.cxx | 6 +++--- .../xAODBTaggingEfficiency/TruthTagResults.h | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/Root/BTaggingEigenVectorRecompositionTool.cxx b/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/Root/BTaggingEigenVectorRecompositionTool.cxx index 7b7f98e32207..9b26928cea2f 100644 --- a/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/Root/BTaggingEigenVectorRecompositionTool.cxx +++ b/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/Root/BTaggingEigenVectorRecompositionTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ @@ -177,7 +177,7 @@ std::vector<float> BTaggingEigenVectorRecompositionTool::getCoefficients(const s } std::map<std::string, float> oneEVmap = fullMap[evName]; - for(std::string NPname : NPnameList){ + for(const std::string& NPname : NPnameList){ coefficients.push_back(oneEVmap[NPname]); } return coefficients; diff --git a/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/Root/BTaggingTruthTaggingTool.cxx b/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/Root/BTaggingTruthTaggingTool.cxx index 1d69be0a7671..f061b691786c 100644 --- a/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/Root/BTaggingTruthTaggingTool.cxx +++ b/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/Root/BTaggingTruthTaggingTool.cxx @@ -230,7 +230,7 @@ StatusCode BTaggingTruthTaggingTool::initialize() { if(m_OP == "Continuous"){ std::vector<float> bin_edges; bin_edges.push_back(min_cut_low); - for (auto bin_name : m_availableOP_fixCut){ + for (const std::string& bin_name : m_availableOP_fixCut){ TString cutname = m_taggerName+"/"+m_jetAuthor+"/"+bin_name+"/cutvalue"; float cutval = ((TVector*) m_inf->Get(cutname))[0](0); bin_edges.push_back(cutval); @@ -282,7 +282,7 @@ StatusCode BTaggingTruthTaggingTool::initialize() { } //FixedCut if(m_continuous) - for (auto c : m_cuts){ + for (const auto& c : m_cuts){ ATH_MSG_INFO("b-tag low: " <<c.bcut_low <<" b-tag hig: " <<c.bcut_hig <<" c-tag low: " <<c.ccut_low <<" c-tag hig: " <<c.ccut_hig <<" Added to tag bins: " <<c.is_tagbin); } @@ -811,7 +811,7 @@ StatusCode BTaggingTruthTaggingTool::getTagPermutation(TRFinfo &trfinf, std::vec trf_chosen_perm_ex = trfinf.perm_ex; trf_chosen_perm_in = trfinf.perm_in; std::string print_perm = "Permutation: "; - for(auto perm: trfinf.perm_ex){ + for(const auto& perm: trfinf.perm_ex){ for(auto is: perm) { if(is) print_perm+=std::to_string(1); else print_perm+=std::to_string(0); diff --git a/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/xAODBTaggingEfficiency/TruthTagResults.h b/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/xAODBTaggingEfficiency/TruthTagResults.h index 73ddd857ad4f..26b27715c8d5 100644 --- a/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/xAODBTaggingEfficiency/TruthTagResults.h +++ b/PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency/xAODBTaggingEfficiency/TruthTagResults.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #ifndef ANALYSISTRUTHTAGRESULTS_H @@ -61,18 +61,18 @@ namespace Analysis { } - float getEvtDirectTagSF(std::string syst_name="Nominal") + float getEvtDirectTagSF(const std::string& syst_name="Nominal") { return(map_SF[syst_name]); } - std::vector<bool> getDirectTaggedJets() + const std::vector<bool>& getDirectTaggedJets() { return(is_tagged); } - float getEventWeight(int nbtag,bool Ex,std::string syst_name="Nominal") + float getEventWeight(int nbtag,bool Ex,const std::string& syst_name="Nominal") { if(Ex) { -- GitLab