From 2a2477d84add1145cd3937b4e2887a2071c40496 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Sun, 14 Jan 2024 21:14:32 -0500 Subject: [PATCH] TrigGlobalEfficiencyCorrection: Fix cppcheck warnings. Member/argument ambiguity. Fix empty throw. Prefer to initialize vector member in an initialization list. Avoid (false-positive) warning about using an uninitialized variable by writing the initialization more compactly. --- .../TrigGlobalEfficiencyCorrectionTool.h | 4 ++-- .../TrigGlobalEfficiencyCorrection/Trigger.h | 4 ++-- .../util/TrigGlobEffCorrValidation.cxx | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrectionTool.h b/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrectionTool.h index 09d476020d4f..e2d84da91411 100644 --- a/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrectionTool.h +++ b/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrectionTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ // contact: jmaurer@cern.ch @@ -84,7 +84,7 @@ private: SG::AuxElement::ConstAccessor<char> decorator; std::size_t hash; bool suffixed; - TagDecorator(const std::string& name, std::size_t hash, bool suffixed) : decorator(name), hash(hash), suffixed(suffixed) {} + TagDecorator(const std::string& name, std::size_t the_hash, bool suffixed) : decorator(name), hash(the_hash), suffixed(suffixed) {} }; struct CachedRanking { diff --git a/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrection/Trigger.h b/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrection/Trigger.h index 649e17303393..1da9c42b3d6f 100644 --- a/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrection/Trigger.h +++ b/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/TrigGlobalEfficiencyCorrection/Trigger.h @@ -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 */ // contact: jmaurer@cern.ch @@ -69,7 +69,7 @@ public: template<typename Array> void loadLegs(const ImportData::TrigDef& src, Array& dest) { - if(src.type != m_type) throw; /// can't be thrown due to bad user action -- only in case of a bug in the Calculator class + if(src.type != m_type) throw std::runtime_error ("Calculator bug"); /// can't be thrown due to bad user action -- only in case of a bug in the Calculator class std::fill(dest.begin(), dest.end(), 0); if(m_type==TT_2E_MU_SYM || m_type==TT_2E_G_SYM || m_type==TT_2MU_G_SYM) /// special case needed to skip the duplicated leg for 2X_Y triggers { diff --git a/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/util/TrigGlobEffCorrValidation.cxx b/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/util/TrigGlobEffCorrValidation.cxx index 1647bcbfe593..86923febd566 100644 --- a/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/util/TrigGlobEffCorrValidation.cxx +++ b/Trigger/TrigAnalysis/TrigGlobalEfficiencyCorrection/util/TrigGlobEffCorrValidation.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 */ // contact: jmaurer@cern.ch @@ -135,7 +135,7 @@ struct Config double expectedEfficiencyTolerance = 1e-6; bool debug = false; - Config(const char* name) : testName(name) { leptonPtValues = {30e4f}; } + Config(const char* name) : testName(name), leptonPtValues {30e4f} { } Config& setTriggers(const std::string& t) { triggers = t; return *this; } Config& setLeptonPDF(unsigned nmin, unsigned nmax, std::initializer_list<float> ptvalues) { @@ -567,8 +567,7 @@ bool run_test(const Config& cfg, int toy_to_debug) std::vector<const xAOD::Muon*> muons; std::vector<const xAOD::Photon*> photons; std::vector<const xAOD::IParticle*> particles; - double sum_eff = 0., sum_eff_toys[nToySamples]; - std::fill(std::begin(sum_eff_toys), std::end(sum_eff_toys), 0.); + double sum_eff = 0., sum_eff_toys[nToySamples] = {0}; for(int toy=0; toy<nToysPerTest; ++toy) { do -- GitLab