From 7b03dfa1b29685d9511637dd925c279c70eb98fe Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Sun, 11 Apr 2021 17:04:38 -0400 Subject: [PATCH 1/3] egammaMVACalibAnalysis: Fix cppcheck warning. Redundant pointer comparison. --- .../egammaMVACalibAnalysis/Root/egammaMVATool.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PhysicsAnalysis/ElectronPhotonID/egammaMVACalibAnalysis/Root/egammaMVATool.cxx b/PhysicsAnalysis/ElectronPhotonID/egammaMVACalibAnalysis/Root/egammaMVATool.cxx index 64696cf52e50..65edf22b5435 100644 --- a/PhysicsAnalysis/ElectronPhotonID/egammaMVACalibAnalysis/Root/egammaMVATool.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/egammaMVACalibAnalysis/Root/egammaMVATool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "egammaMVACalibAnalysis/egammaMVATool.h" @@ -101,7 +101,6 @@ std::set<std::string> egammaMVATool::guess_variables(const std::string& filename TFile f(filename.c_str()); std::unique_ptr<TObjArray> formulae(dynamic_cast<TObjArray*>(f.Get("formulae"))); formulae->SetOwner(true); // by default TObjArray doesn't own elements - if (not formulae) { ATH_MSG_FATAL("cannot find formulae in " << filename); } // TODO: use regex parsing (regex supported only in gcc 4.9, TPRegexp sucks) const std::vector<std::string> all_possible_variables = { -- GitLab From c2153d627845a2fa32b790db0d8cb0135de2f826 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Sun, 11 Apr 2021 17:12:14 -0400 Subject: [PATCH 2/3] ElectronPhotonFourMomentumCorrection: Fix cppcheck warnings. Pass large objects by const reference, not by value. --- .../EgammaCalibrationAndSmearingTool.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h index 4a63d1d01069..0790e9ab2999 100644 --- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h +++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ @@ -187,7 +187,7 @@ private: return AbsEtaCaloPredicateFactory(edges.first, edges.second); } - const std::vector<EgammaPredicate> AbsEtaCaloPredicatesFactory(const std::vector<std::pair<double, double>> edges) const + const std::vector<EgammaPredicate> AbsEtaCaloPredicatesFactory(const std::vector<std::pair<double, double>>& edges) const { std::vector<EgammaPredicate> result; result.reserve(edges.size()); @@ -197,7 +197,7 @@ private: return result; } - const std::vector<EgammaPredicate> AbsEtaCaloPredicatesFactory(const std::vector<double> edges) const + const std::vector<EgammaPredicate> AbsEtaCaloPredicatesFactory(const std::vector<double>& edges) const { std::vector<EgammaPredicate> result; result.reserve(edges.size() - 1); -- GitLab From 78fef3c6ca1de0d65162d36b7e62f4e2b2e187a9 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Sun, 11 Apr 2021 17:20:15 -0400 Subject: [PATCH 3/3] LArCellRec: Fix cppcheck warnings. Avoid postincrement for iterator classes. --- LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx | 10 ++-------- LArCalorimeter/LArCellRec/src/LArNoisyROAlg.cxx | 6 +++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx b/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx index 14f1e9cb9aa5..0d473b90bae3 100644 --- a/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx +++ b/LArCalorimeter/LArCellRec/src/LArBadFebMaskingTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /******************************************************************** @@ -167,18 +167,12 @@ StatusCode LArBadFebMaskingTool::process (CaloCellContainer* theCont, // loop over all Febs - std::vector<HWIdentifier>::const_iterator feb = m_onlineID->feb_begin(); - std::vector<HWIdentifier>::const_iterator feb_end = m_onlineID->feb_end(); - - - for ( ; feb != feb_end; feb++) { - + for (HWIdentifier febId : m_onlineID->feb_range()) { bool toMask1 = false; // mask because of bad error bool inError = false; // mask because Feb listed in database as being to mask bool isDead = false; // set to true if Feb is deadAll or deadReadout // for debug - HWIdentifier febId = (*feb); unsigned int ifeb = febId.get_identifier32().get_compact(); ATH_MSG_DEBUG (" process Feb: " << ifeb); diff --git a/LArCalorimeter/LArCellRec/src/LArNoisyROAlg.cxx b/LArCalorimeter/LArCellRec/src/LArNoisyROAlg.cxx index 229b68642987..0920fde705f7 100644 --- a/LArCalorimeter/LArCellRec/src/LArNoisyROAlg.cxx +++ b/LArCalorimeter/LArCellRec/src/LArNoisyROAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ @@ -54,7 +54,7 @@ StatusCode LArNoisyROAlg::execute (const EventContext& ctx) const SG::ReadCondHandle<LArBadFebCont> badHdl(m_knownBadFEBsVecKey, ctx); const LArBadFebCont* badCont=*badHdl; if(badCont) { - for(LArBadFebCont::BadChanVec::const_iterator i = badCont->begin(); i!=badCont->end(); i++) { + for(LArBadFebCont::BadChanVec::const_iterator i = badCont->begin(); i!=badCont->end(); ++i) { bf.insert(i->first); } if(bf.size() == 0) { @@ -69,7 +69,7 @@ StatusCode LArNoisyROAlg::execute (const EventContext& ctx) const SG::ReadCondHandle<LArBadFebCont> MNBHdl(m_knownMNBFEBsVecKey, ctx); const LArBadFebCont* MNBCont=*MNBHdl; if(MNBCont) { - for(LArBadFebCont::BadChanVec::const_iterator i = MNBCont->begin(); i!=MNBCont->end(); i++) { + for(LArBadFebCont::BadChanVec::const_iterator i = MNBCont->begin(); i!=MNBCont->end(); ++i) { MNBfeb.push_back(HWIdentifier(i->first)); } if(MNBfeb.size() == 0) { -- GitLab