From cbf8f78abbd948692d4f5df7996bc57b7ccee121 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Sat, 7 Dec 2024 16:50:53 +0100 Subject: [PATCH] chore: Sonar fixes after detector refactor --- .../ActsExamples/Geant4/Geant4Simulation.hpp | 2 +- .../ContextualDetector/AlignedDetector.hpp | 10 ++--- .../DD4hepDetector/src/DD4hepDetector.cpp | 38 +++++++++---------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp index 089c1c2b3cd..df9dd637eca 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp @@ -208,7 +208,7 @@ class Geant4MaterialRecording final : public Geant4SimulationBase { /// Algorithm execute method, called once per event with context /// /// @param ctx the AlgorithmContext for this event - ProcessCode execute(const ActsExamples::AlgorithmContext& ctx) const final; + ProcessCode execute(const ActsExamples::AlgorithmContext& ctx) const override; /// Readonly access to the configuration const Config& config() const final { return m_cfg; } diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp index 0859c174e5a..7a184f16fc1 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp @@ -13,8 +13,6 @@ #include "ActsExamples/DetectorCommons/Detector.hpp" #include "ActsExamples/GenericDetector/GenericDetector.hpp" -#include - namespace ActsExamples { class InternallyAlignedDetectorElement; @@ -24,11 +22,11 @@ class AlignedDetector : public Detector { public: struct Config : public GenericDetector::Config { /// Seed for the decorator random numbers. - std::size_t seed = 1324354657; + unsigned int seed = 1324354657; /// Size of a valid IOV. - std::size_t iovSize = 100; + unsigned int iovSize = 100; /// Span until garbage collection is active. - std::size_t flushSize = 200; + unsigned int flushSize = 200; /// Run the garbage collection? bool doGarbageCollection = true; /// Sigma of the in-plane misalignment @@ -46,8 +44,6 @@ class AlignedDetector : public Detector { enum class Mode { Internal, External }; Mode mode = Mode::Internal; - - std::shared_ptr materialDecorator; }; explicit AlignedDetector(const Config& cfg); diff --git a/Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp b/Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp index a411a32a028..6ad70fa7d70 100644 --- a/Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp +++ b/Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp @@ -86,8 +86,8 @@ std::unique_ptr DD4hepDetector::buildDD4hepGeometry() const { std::unique_ptr detector = dd4hep::Detector::make_unique(m_cfg.name); - for (auto& file : m_cfg.xmlFileNames) { - detector->fromCompact(file.c_str()); + for (const auto& file : m_cfg.xmlFileNames) { + detector->fromCompact(file); } detector->volumeManager(); detector->apply("DD4hepVolumeManager", 0, nullptr); @@ -106,7 +106,7 @@ void ActsExamples::sortFCChhDetElements(std::vector& det) { std::vector eCal; std::vector hCal; std::vector muon; - for (auto& detElement : det) { + for (const auto& detElement : det) { std::string detName = detElement.name(); if (detName.find("Muon") != std::string::npos) { muon.push_back(detElement); @@ -118,22 +118,22 @@ void ActsExamples::sortFCChhDetElements(std::vector& det) { tracker.push_back(detElement); } } - sort(muon.begin(), muon.end(), - [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { - return (a.id() < b.id()); - }); - sort(eCal.begin(), eCal.end(), - [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { - return (a.id() < b.id()); - }); - sort(hCal.begin(), hCal.end(), - [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { - return (a.id() < b.id()); - }); - sort(tracker.begin(), tracker.end(), - [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { - return (a.id() < b.id()); - }); + std::ranges::sort( + muon, [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { + return (a.id() < b.id()); + }); + std::ranges::sort( + eCal, [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { + return (a.id() < b.id()); + }); + std::ranges::sort( + hCal, [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { + return (a.id() < b.id()); + }); + std::ranges::sort( + tracker, [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { + return (a.id() < b.id()); + }); det.clear(); det = tracker;