From a9a58577ce95b0c976d807e2de156a38eaaa9863 Mon Sep 17 00:00:00 2001 From: Vakhtang Tsulaia <vakhtang.tsulaia@cern.ch> Date: Mon, 16 Aug 2021 16:55:27 +0000 Subject: [PATCH] Merge branch 'PhysValMonitoring_clang_tidy' into 'master' PhysValMonitoring clang-tidy related fixes See merge request atlas/athena!45799 (cherry picked from commit 73d261eb725687bb235c6c3372b4102802ec7b30) b27693a9 PhysValMonitoring clang-tidy related fixes --- .../PhysValMonitoring/src/BTagPlots.cxx | 12 +++-- .../PhysValMonitoring/src/BTagPlots.h | 8 ++-- .../PhysValMonitoring/src/KinematicsPlots.cxx | 10 ++-- .../PhysValMonitoring/src/KinematicsPlots.h | 18 ++++---- .../PhysValMonitoring/src/METPlots.cxx | 12 +++-- .../PhysValMonitoring/src/METPlots.h | 14 +++--- .../PhysValMonitoring/src/PhysValExample.cxx | 46 +++++++++---------- .../PhysValMonitoring/src/PhysValExample.h | 4 +- .../PhysValMonitoring/src/TrkAndVtxPlots.cxx | 8 ++-- .../PhysValMonitoring/src/TrkAndVtxPlots.h | 20 ++++---- 10 files changed, 82 insertions(+), 70 deletions(-) diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/BTagPlots.cxx b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/BTagPlots.cxx index b8ca1b4de8d9..10d96f247a47 100644 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/BTagPlots.cxx +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/BTagPlots.cxx @@ -1,15 +1,19 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ +#include <utility> + + + #include "BTagPlots.h" using CLHEP::GeV; namespace PhysVal{ - BTagPlots::BTagPlots(PlotBase* pParent, std::string sDir, std::string sParticleType):PlotBase(pParent, sDir), -m_sParticleType(sParticleType) + BTagPlots::BTagPlots(PlotBase* pParent, const std::string& sDir, std::string sParticleType):PlotBase(pParent, sDir), +m_sParticleType(std::move(sParticleType)) {} void BTagPlots::initializePlots(){ @@ -20,7 +24,7 @@ void BTagPlots::initializePlots(){ std::cout << "filling b-tagging plots with BS weight: " << evt->beamSpotWeight(); } - void BTagPlots::fill(unsigned int nbtag,const xAOD::EventInfo* evt){ + void BTagPlots::fill(unsigned int nbtag,const xAOD::EventInfo* evt) const{ n->Fill(nbtag,evt->beamSpotWeight()); } } diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/BTagPlots.h b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/BTagPlots.h index 6fa4e5e69398..651517767c3d 100644 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/BTagPlots.h +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/BTagPlots.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef PHYSVALMONITORING_BTagPLOTS_H @@ -14,13 +14,13 @@ namespace PhysVal{ class BTagPlots:public PlotBase { public: - BTagPlots(PlotBase* pParent, std::string sDir, std::string sParticleType); + BTagPlots(PlotBase* pParent, const std::string& sDir, std::string sParticleType); void fill(const xAOD::BTagging* btag,const xAOD::EventInfo* evt); - void fill(unsigned int nbtag,const xAOD::EventInfo* evt); + void fill(unsigned int nbtag,const xAOD::EventInfo* evt) const; // Reco only information std::string m_sParticleType; - TH1* n; + TH1* n = nullptr; private: virtual void initializePlots(); diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.cxx b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.cxx index 338999ac36b1..b43d4d93e528 100755 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.cxx +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.cxx @@ -1,15 +1,19 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ +#include <utility> + + + #include "KinematicsPlots.h" using CLHEP::GeV; namespace PhysVal{ -KinematicsPlots::KinematicsPlots(PlotBase* pParent, std::string sDir, std::string sParticleType):PlotBase(pParent, sDir), -m_sParticleType(sParticleType) +KinematicsPlots::KinematicsPlots(PlotBase* pParent, const std::string& sDir, std::string sParticleType):PlotBase(pParent, sDir), +m_sParticleType(std::move(sParticleType)) {} void KinematicsPlots::initializePlots(){ diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.h b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.h index f763590541c1..f86b6cf6970e 100755 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.h +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef PHYSVALMONITORING_KINEMATICSPLOTS_H @@ -14,7 +14,7 @@ namespace PhysVal{ class KinematicsPlots:public PlotBase { public: - KinematicsPlots(PlotBase* pParent, std::string sDir, std::string sParticleType); + KinematicsPlots(PlotBase* pParent, const std::string& sDir, std::string sParticleType); void fill(const xAOD::IParticle* part,const xAOD::EventInfo* evt); void fill(const xAOD::EventInfo* evt); @@ -23,15 +23,15 @@ class KinematicsPlots:public PlotBase { // Reco only information std::string m_sParticleType; - TH1* n; + TH1* n = nullptr; - TH1* et; - TH1* eta; - TH1* phi; + TH1* et = nullptr; + TH1* eta = nullptr; + TH1* phi = nullptr; - TH1* lead_et; - TH1* lead_eta; - TH1* lead_phi; + TH1* lead_et = nullptr; + TH1* lead_eta = nullptr; + TH1* lead_phi = nullptr; private: diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/METPlots.cxx b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/METPlots.cxx index 55d51dd29d1d..4e5b8e845a65 100644 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/METPlots.cxx +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/METPlots.cxx @@ -1,15 +1,19 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ +#include <utility> + + + #include "METPlots.h" using CLHEP::GeV; namespace PhysVal{ - METPlots::METPlots(PlotBase* pParent, std::string sDir, std::string sParticleType):PlotBase(pParent, sDir), -m_sParticleType(sParticleType) + METPlots::METPlots(PlotBase* pParent, const std::string& sDir, std::string sParticleType):PlotBase(pParent, sDir), +m_sParticleType(std::move(sParticleType)) {} void METPlots::initializePlots(){ @@ -19,7 +23,7 @@ void METPlots::initializePlots(){ met_sumet = Book1D("SumEt", "MET " + m_sParticleType + " Ex; #Sum E_{t} ;Events", 100, 0., 2000); } - void METPlots::fill(const xAOD::MissingET* met,const xAOD::EventInfo* evt){ + void METPlots::fill(const xAOD::MissingET* met,const xAOD::EventInfo* evt) const{ met_ex->Fill(met->mpx()/GeV,evt->beamSpotWeight()); met_ey->Fill(met->mpy()/GeV,evt->beamSpotWeight()); diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/METPlots.h b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/METPlots.h index 9e746cf7839f..b1e508969fee 100644 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/METPlots.h +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/METPlots.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef PHYSVALMONITORING_METPLOTS_H @@ -14,15 +14,15 @@ namespace PhysVal{ class METPlots:public PlotBase { public: - METPlots(PlotBase* pParent, std::string sDir, std::string sParticleType = "RefFinal"); - void fill(const xAOD::MissingET* met,const xAOD::EventInfo* evt); + METPlots(PlotBase* pParent, const std::string& sDir, std::string sParticleType = "RefFinal"); + void fill(const xAOD::MissingET* met,const xAOD::EventInfo* evt) const; // Reco only information std::string m_sParticleType; - TH1* met_ex; - TH1* met_ey; - TH1* met_et; - TH1* met_sumet; + TH1* met_ex = nullptr; + TH1* met_ey = nullptr; + TH1* met_et = nullptr; + TH1* met_sumet = nullptr; private: virtual void initializePlots(); diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/PhysValExample.cxx b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/PhysValExample.cxx index c3cfbf6a9624..6943cd32e4c3 100644 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/PhysValExample.cxx +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/PhysValExample.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // PhysValExample.cxx @@ -47,14 +47,14 @@ namespace PhysVal { const std::string& name, const IInterface* parent ) : ManagedMonitorToolBase( type, name, parent ), - m_jetPlots(0, "Summary/Jet/", "Jet"), - m_elecPlots(0, "Summary/Electron/", "Electron"), - m_photonPlots(0, "Summary/Photon/", "Photon"), - m_muonPlots(0, "Summary/Muon/", "Muon"), - m_tauPlots(0, "Summary/Tau/", "Tau"), - m_trkvtxPlots(0, "Summary/TrackAndVertex/"), - m_metPlots(0, "Summary/MET/", "RefFinal"), - m_btagPlots(0, "Summary/BTag/", "IP3D") + m_jetPlots(nullptr, "Summary/Jet/", "Jet"), + m_elecPlots(nullptr, "Summary/Electron/", "Electron"), + m_photonPlots(nullptr, "Summary/Photon/", "Photon"), + m_muonPlots(nullptr, "Summary/Muon/", "Muon"), + m_tauPlots(nullptr, "Summary/Tau/", "Tau"), + m_trkvtxPlots(nullptr, "Summary/TrackAndVertex/"), + m_metPlots(nullptr, "Summary/MET/", "RefFinal"), + m_btagPlots(nullptr, "Summary/BTag/", "IP3D") { declareProperty( "JetContainerName", m_jetName = "AntiKt4EMTopoJets" ); @@ -112,7 +112,7 @@ namespace PhysVal { ATH_CHECK(book(m_metPlots)); } - for (auto name : m_timingNames) { + for (const auto& name : m_timingNames) { if (name == "EVNTtoHITS") { m_timingPlots.push_back(new TH1F(("Timing" + name).c_str(), ("Timing" + name).c_str(), 10000, 0, 10000)); } else { @@ -131,14 +131,14 @@ namespace PhysVal { if (m_detailLevel < 10) return StatusCode::SUCCESS; // event Info - const xAOD::EventInfo* event(0); + const xAOD::EventInfo* event(nullptr); ATH_CHECK(evtStore()->retrieve(event, "EventInfo")); // Jets int nbtag(0); if (m_doExJet){ m_jetPlots.initializeEvent(); - const xAOD::JetContainer* jets(0); + const xAOD::JetContainer* jets(nullptr); ATH_CHECK(evtStore()->retrieve(jets, m_jetName)); for (auto jet : *jets) { m_jetPlots.fill(jet,event); @@ -153,37 +153,37 @@ namespace PhysVal { // Electrons m_elecPlots.initializeEvent(); - const xAOD::ElectronContainer* electrons(0); + const xAOD::ElectronContainer* electrons(nullptr); ATH_CHECK(evtStore()->retrieve(electrons, m_elecName)); for (auto elec : *electrons) m_elecPlots.fill(elec,event); m_elecPlots.fill(event); // Photons m_photonPlots.initializeEvent(); - const xAOD::PhotonContainer* photons(0); + const xAOD::PhotonContainer* photons(nullptr); ATH_CHECK(evtStore()->retrieve(photons, m_photonName)); for (auto photon : *photons) m_photonPlots.fill(photon,event); m_photonPlots.fill(event); // Muons m_muonPlots.initializeEvent(); - const xAOD::MuonContainer* muons(0); + const xAOD::MuonContainer* muons(nullptr); ATH_CHECK(evtStore()->retrieve(muons, m_muonName)); for (auto muon : *muons) m_muonPlots.fill(muon,event); m_muonPlots.fill(event); // Taus m_tauPlots.initializeEvent(); - const xAOD::TauJetContainer* taus(0); + const xAOD::TauJetContainer* taus(nullptr); ATH_CHECK(evtStore()->retrieve(taus, m_tauName)); for (auto tau : *taus) m_tauPlots.fill(tau,event); m_tauPlots.fill(event); // Tracks/Vertices - const xAOD::TrackParticleContainer* trks(0); + const xAOD::TrackParticleContainer* trks(nullptr); ATH_CHECK(evtStore()->retrieve(trks, m_trackName)); - const xAOD::VertexContainer* vtxs(0); + const xAOD::VertexContainer* vtxs(nullptr); ATH_CHECK(evtStore()->retrieve(vtxs, m_vertexName)); for (auto vtx : *vtxs) m_trkvtxPlots.fill(vtx,event); @@ -193,7 +193,7 @@ namespace PhysVal { if (m_doExMET){ - const xAOD::MissingETContainer* met_container (0); + const xAOD::MissingETContainer* met_container (nullptr); ATH_CHECK(evtStore()->retrieve(met_container, m_metName)); const xAOD::MissingET* met = (*met_container)["FinalClus"]; @@ -204,7 +204,7 @@ namespace PhysVal { m_metPlots.fill(met,event); } int i(0); - for (auto name : m_timingNames) { + for (const auto& name : m_timingNames) { float time; if (getTiming(name, time).isSuccess()) { m_timingPlots[i]->Fill(time,event->beamSpotWeight()); @@ -233,11 +233,11 @@ namespace PhysVal { // Protected methods: /////////////////////////////////////////////////////////////////// - StatusCode PhysValExample::getTiming(std::string name, float& recoTime) { + StatusCode PhysValExample::getTiming(const std::string& name, float& recoTime) { // Code form // m_recoInclPers - const RecoTimingObj* recTiming(0); + const RecoTimingObj* recTiming(nullptr); recoTime = 0; if (evtStore()->contains<RecoTimingObj>(name + "_timings")) { if (evtStore()->retrieve( recTiming, name + "_timings" ).isFailure()) { @@ -247,7 +247,7 @@ namespace PhysVal { bool recoInclPers(true); if (recoInclPers) { - if ((*recTiming).size() > 0) + if (!(*recTiming).empty()) recoTime=*((*recTiming).rbegin()); } else { if ((*recTiming).size() > 1) diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/PhysValExample.h b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/PhysValExample.h index f818989a0f00..6879984dc2e0 100644 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/PhysValExample.h +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/PhysValExample.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // PhysValExample.h @@ -98,7 +98,7 @@ class PhysValExample std::vector<TH1*> m_timingPlots; StatusCode book(PlotBase& plots); - StatusCode getTiming(std::string name, float& recoTime); + StatusCode getTiming(const std::string& name, float& recoTime); //Flags to determine whether to fill example jet,met,btag plots bool m_doExJet; diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/TrkAndVtxPlots.cxx b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/TrkAndVtxPlots.cxx index 1d65a52ad0e6..f5798e8f8c7a 100644 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/TrkAndVtxPlots.cxx +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/TrkAndVtxPlots.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "TrkAndVtxPlots.h" @@ -10,7 +10,7 @@ using CLHEP::GeV; namespace PhysVal{ -TrkAndVtxPlots::TrkAndVtxPlots(PlotBase* pParent, std::string sDir):PlotBase(pParent, sDir) +TrkAndVtxPlots::TrkAndVtxPlots(PlotBase* pParent, const std::string& sDir):PlotBase(pParent, sDir) {} void TrkAndVtxPlots::initializePlots(){ @@ -24,7 +24,7 @@ void TrkAndVtxPlots::initializePlots(){ mu = Book1D("mu", "Pileup; mu ;Events", 120, 0., 120); } - void TrkAndVtxPlots::fill(const xAOD::Vertex* vtx,const xAOD::EventInfo* evt){ + void TrkAndVtxPlots::fill(const xAOD::Vertex* vtx,const xAOD::EventInfo* evt) const{ vtx_x->Fill(vtx->x(),evt->beamSpotWeight()); vtx_y->Fill(vtx->y(),evt->beamSpotWeight()); @@ -36,7 +36,7 @@ void TrkAndVtxPlots::initializePlots(){ std::cout << "filling TrackAndVertex plots with BS weight: " << evt->beamSpotWeight(); } - void TrkAndVtxPlots::fill(unsigned int ntrack, unsigned int nvertex, float pileup,const xAOD::EventInfo* evt){ + void TrkAndVtxPlots::fill(unsigned int ntrack, unsigned int nvertex, float pileup,const xAOD::EventInfo* evt) const{ ntrk->Fill(ntrack,evt->beamSpotWeight()); nvtx->Fill(nvertex,evt->beamSpotWeight()); diff --git a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/TrkAndVtxPlots.h b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/TrkAndVtxPlots.h index b3f2d4039dc8..977eb925956c 100644 --- a/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/TrkAndVtxPlots.h +++ b/PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/TrkAndVtxPlots.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef PHYSVALMONITORING_TRKANDVTXPLOTS_H @@ -15,20 +15,20 @@ namespace PhysVal{ class TrkAndVtxPlots:public PlotBase { public: - TrkAndVtxPlots(PlotBase* pParent, std::string sDir); + TrkAndVtxPlots(PlotBase* pParent, const std::string& sDir); void fill(const xAOD::TrackParticle* trk,const xAOD::EventInfo* evt); - void fill(const xAOD::Vertex* vtx,const xAOD::EventInfo* evt); - void fill(unsigned int ntrack, unsigned int nvertex, float pileup = 0,const xAOD::EventInfo* evt=NULL); + void fill(const xAOD::Vertex* vtx,const xAOD::EventInfo* evt) const; + void fill(unsigned int ntrack, unsigned int nvertex, float pileup = 0,const xAOD::EventInfo* evt=NULL) const; // Reco only information - TH1* ntrk; + TH1* ntrk = nullptr; - TH1* nvtx; - TH1* vtx_x; - TH1* vtx_y; - TH1* vtx_z; + TH1* nvtx = nullptr; + TH1* vtx_x = nullptr; + TH1* vtx_y = nullptr; + TH1* vtx_z = nullptr; - TH1* mu; + TH1* mu = nullptr; private: virtual void initializePlots(); -- GitLab