From d7bd8d0232f0f402f0e20015128a877142303f0c Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Thu, 26 Oct 2023 11:40:50 +0200 Subject: [PATCH] Apply `clang-tidy` suggestions --- root/hist/hist/FitGradBenchmarks.cxx | 2 +- root/hist/hist/TFormulaBenchmarks.cxx | 1 - root/hist/hist/THistFillBenchmarks.cxx | 2 +- root/io/io/TBufferMergerBenchmarks.cxx | 7 ++++--- root/roofit/histfactory/benchHistFactory.cxx | 2 +- root/roofit/roofit/RooFitBinnedBenchmarks.cxx | 6 +++--- root/roofit/roofit/benchCodeSquashAD.cxx | 9 +++++---- .../LoopSUSYFrame/inc/LoopSUSYFrame/GenericHelpers.h | 2 +- .../LoopSUSYFrame/inc/LoopSUSYFrame/LeptonHelpers.h | 3 ++- root/tree/dataframe/wmass/inc/getWeights.hpp | 3 +-- 10 files changed, 19 insertions(+), 18 deletions(-) diff --git a/root/hist/hist/FitGradBenchmarks.cxx b/root/hist/hist/FitGradBenchmarks.cxx index f0190f42e..d8266aa4a 100644 --- a/root/hist/hist/FitGradBenchmarks.cxx +++ b/root/hist/hist/FitGradBenchmarks.cxx @@ -60,7 +60,7 @@ class ManyGausFit { bool useCLAD = false; public: - ManyGausFit(int ng = 30, int nbins = 1000, bool clad = false, bool debLevel = 0, int seed = 1111) + ManyGausFit(int ng = 30, int nbins = 1000, bool clad = false, bool debLevel = false, int seed = 1111) { useCLAD = clad; debug = debLevel; diff --git a/root/hist/hist/TFormulaBenchmarks.cxx b/root/hist/hist/TFormulaBenchmarks.cxx index de8dc1f0f..7df4b666b 100644 --- a/root/hist/hist/TFormulaBenchmarks.cxx +++ b/root/hist/hist/TFormulaBenchmarks.cxx @@ -5,7 +5,6 @@ class TFormulaTests : public TFormula { public: TFormulaTests(TString name, TString formula): TFormula(name,formula){} - virtual ~TFormulaTests(){} Bool_t ParserNew(); Bool_t GetVarVal(); Bool_t GetParVal(); diff --git a/root/hist/hist/THistFillBenchmarks.cxx b/root/hist/hist/THistFillBenchmarks.cxx index db29ace85..fad0c17fe 100644 --- a/root/hist/hist/THistFillBenchmarks.cxx +++ b/root/hist/hist/THistFillBenchmarks.cxx @@ -125,7 +125,7 @@ static void BM_THist_FillN(benchmark::State &state) // FillN without weight hist->FillN(nbOfDataPoints, &xCoords[0], &yCoords[0], &weights[0], 1); // FillN with weights - hist->FillN(nbOfDataPoints, &xCoords[0], &yCoords[0], NULL, 1); + hist->FillN(nbOfDataPoints, &xCoords[0], &yCoords[0], nullptr, 1); } } BENCHMARK(BM_THist_FillN) -> Apply(FillArguments); diff --git a/root/io/io/TBufferMergerBenchmarks.cxx b/root/io/io/TBufferMergerBenchmarks.cxx index 0fd8095fb..57b935737 100644 --- a/root/io/io/TBufferMergerBenchmarks.cxx +++ b/root/io/io/TBufferMergerBenchmarks.cxx @@ -6,6 +6,7 @@ #include "benchmark/benchmark.h" +#include #include #include #include @@ -23,7 +24,7 @@ static void BM_TBufferFile_CreateEmpty(benchmark::State &state) { const char *filename = "empty.root"; for (auto _ : state) { - TBufferMerger m(std::unique_ptr(new TMemFile(filename, "RECREATE"))); + TBufferMerger m(std::make_unique(filename, "RECREATE")); } } BENCHMARK(BM_TBufferFile_CreateEmpty)->Unit(benchmark::kMicrosecond); @@ -37,7 +38,7 @@ static void BM_TBufferFile_GetFile(benchmark::State &state) // FIXME: We should have a way to pass an externally constructed file or stream to // TFile*, this would allow us to create in-memory files and avoid killing disks // when we benchmark IO. - Merger = new TBufferMerger(std::unique_ptr(new TMemFile("virtual_file.root", "RECREATE"))); + Merger = new TBufferMerger(std::make_unique("virtual_file.root", "RECREATE")); } for (auto _ : state) { // Run the test as normal. @@ -89,7 +90,7 @@ static void BM_TBufferFile_FillTreeWithRandomData(benchmark::State &state) ROOT::EnableThreadSafety(); if (state.thread_index() == 0) { // Setup code here. - Merger = new TBufferMerger(std::unique_ptr(new TMemFile("virtual_file.root", "RECREATE"))); + Merger = new TBufferMerger(std::make_unique("virtual_file.root", "RECREATE")); } long size; int flush = state.range(0); diff --git a/root/roofit/histfactory/benchHistFactory.cxx b/root/roofit/histfactory/benchHistFactory.cxx index eee3b5996..4a9b82e71 100644 --- a/root/roofit/histfactory/benchHistFactory.cxx +++ b/root/roofit/histfactory/benchHistFactory.cxx @@ -40,7 +40,7 @@ class TestData { RooMinimizer m(*nll); m.setPrintLevel(-1); m.setStrategy(0); - m.setLoggingToDataSet(1); + m.setLoggingToDataSet(true); m.minimize("Minuit2"); diff --git a/root/roofit/roofit/RooFitBinnedBenchmarks.cxx b/root/roofit/roofit/RooFitBinnedBenchmarks.cxx index 35dc001c4..06c60f171 100644 --- a/root/roofit/roofit/RooFitBinnedBenchmarks.cxx +++ b/root/roofit/roofit/RooFitBinnedBenchmarks.cxx @@ -158,7 +158,7 @@ static void BM_RooFit_BinnedTestMigrad(benchmark::State &state) RooMinimizer m(*nll); m.setPrintLevel(-1); m.setStrategy(0); - m.setProfile(0); + m.setProfile(false); m.setLogFile("benchmigradnchannellog"); for (auto _ : state) { m.migrad(); @@ -190,7 +190,7 @@ static void BM_RooFit_BinnedTestHesse(benchmark::State &state) RooMinimizer m(*nll); m.setPrintLevel(-1); m.setStrategy(0); - m.setProfile(0); + m.setProfile(false); m.setLogFile("benchhessenchannellog"); m.migrad(); w->loadSnapshot("no_fit"); @@ -227,7 +227,7 @@ static void BM_RooFit_BinnedTestMinos(benchmark::State &state) RooMinimizer m(*nll); m.setPrintLevel(-1); m.setStrategy(0); - m.setProfile(0); + m.setProfile(false); m.setLogFile("benchhessenchannellog"); m.migrad(); m.hesse(); diff --git a/root/roofit/roofit/benchCodeSquashAD.cxx b/root/roofit/roofit/benchCodeSquashAD.cxx index efe10c527..426b4e700 100644 --- a/root/roofit/roofit/benchCodeSquashAD.cxx +++ b/root/roofit/roofit/benchCodeSquashAD.cxx @@ -28,6 +28,7 @@ #include "benchmark/benchmark.h" #include +#include static int counter = 0; @@ -125,13 +126,13 @@ static void BM_RooFuncWrapper_ManyParams_Minimization(benchmark::State &state) int code = state.range(0); if (code == RooFitADBenchmarksUtils::backend::Reference) { - m.reset(new RooMinimizer(*nllRef)); + m = std::make_unique(*nllRef); } else if (code == RooFitADBenchmarksUtils::backend::CodeSquashNumDiff) { - m.reset(new RooMinimizer(*nllFuncNoGrad)); + m = std::make_unique(*nllFuncNoGrad); } else if (code == RooFitADBenchmarksUtils::backend::BatchMode) { - m.reset(new RooMinimizer(*nllRefBatch)); + m = std::make_unique(*nllRefBatch); } else if (code == RooFitADBenchmarksUtils::backend::CodeSquashAD) { - m.reset(new RooMinimizer(*nllFunc)); + m = std::make_unique(*nllFunc); } for (auto _ : state) { diff --git a/root/tree/dataframe/LoopSUSYFrame/inc/LoopSUSYFrame/GenericHelpers.h b/root/tree/dataframe/LoopSUSYFrame/inc/LoopSUSYFrame/GenericHelpers.h index e862690ce..d65bff601 100644 --- a/root/tree/dataframe/LoopSUSYFrame/inc/LoopSUSYFrame/GenericHelpers.h +++ b/root/tree/dataframe/LoopSUSYFrame/inc/LoopSUSYFrame/GenericHelpers.h @@ -697,7 +697,7 @@ inline auto minDPhiDRLepJet(const bool showDR=false) if (showDR) vDiff.push_back(lep.DeltaR(jet)); else vDiff.push_back(std::abs(lep.DeltaPhi(jet))); } - if(vDiff.size()>0) minVal = *std::min_element(vDiff.begin(),vDiff.end()); + if(!vDiff.empty()) minVal = *std::min_element(vDiff.begin(),vDiff.end()); return minVal; }; } diff --git a/root/tree/dataframe/LoopSUSYFrame/inc/LoopSUSYFrame/LeptonHelpers.h b/root/tree/dataframe/LoopSUSYFrame/inc/LoopSUSYFrame/LeptonHelpers.h index 5df2666ef..a432f59ff 100644 --- a/root/tree/dataframe/LoopSUSYFrame/inc/LoopSUSYFrame/LeptonHelpers.h +++ b/root/tree/dataframe/LoopSUSYFrame/inc/LoopSUSYFrame/LeptonHelpers.h @@ -628,7 +628,8 @@ inline auto GetXMLFF_Eta_Pt(const std::vector ele_systList, const std:: FFvalues["fakeWeight_statDown"] = -99.; std::vector allSyst; - for (const auto &syst : ele_systList) allSyst.push_back(syst); + allSyst.reserve(ele_systList.size()); + for (const auto &syst : ele_systList) allSyst.push_back(syst); for(const auto &muSys: muon_systList){ bool exist = false; for(const auto &syst : allSyst){ diff --git a/root/tree/dataframe/wmass/inc/getWeights.hpp b/root/tree/dataframe/wmass/inc/getWeights.hpp index 1714b8f75..432f56e43 100644 --- a/root/tree/dataframe/wmass/inc/getWeights.hpp +++ b/root/tree/dataframe/wmass/inc/getWeights.hpp @@ -32,7 +32,6 @@ class getWeights : public Module { public: - ~getWeights() {}; RNode run(RNode) override; std::vector> getTH1() override; std::vector> getTH2() override; @@ -46,4 +45,4 @@ class getWeights : public Module { }; -#endif \ No newline at end of file +#endif