From 7949baaaba3ef6715662cc37191ecd1d2dac436e Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Wed, 8 May 2024 14:15:30 +0200
Subject: [PATCH] G4UserActions: Fix cppcheck warnings.

G4UserActions: Fix cppcheck warning.

Pass container by const reference, not by value.
Delete copy/assignment for class managing memory.
---
 .../G4Utilities/G4UserActions/src/LengthIntegrator.h       | 7 +++++--
 .../G4Utilities/G4UserActions/src/RadLengthAction.cxx      | 4 ++--
 Simulation/G4Utilities/G4UserActions/src/RadLengthAction.h | 4 ++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/Simulation/G4Utilities/G4UserActions/src/LengthIntegrator.h b/Simulation/G4Utilities/G4UserActions/src/LengthIntegrator.h
index d449e3df1073..73e11dc13a90 100644
--- a/Simulation/G4Utilities/G4UserActions/src/LengthIntegrator.h
+++ b/Simulation/G4Utilities/G4UserActions/src/LengthIntegrator.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef G4UserActions_LengthIntegrator_H
@@ -45,7 +45,10 @@ namespace G4UA
     public:
 
       /// Constructor takes the name of the histogram service as argument.
-    LengthIntegrator(const std::string& histSvcName, bool doHistos);
+      LengthIntegrator(const std::string& histSvcName, bool doHistos);
+
+      LengthIntegrator(const LengthIntegrator&) = delete;
+      LengthIntegrator& operator=(const LengthIntegrator&) = delete;
 
       /// Called at beginning of G4 event to cache some details about the
       /// current primary vertex and particle. Also resets some measurements.
diff --git a/Simulation/G4Utilities/G4UserActions/src/RadLengthAction.cxx b/Simulation/G4Utilities/G4UserActions/src/RadLengthAction.cxx
index dec265c5e89d..28c7b451cd23 100644
--- a/Simulation/G4Utilities/G4UserActions/src/RadLengthAction.cxx
+++ b/Simulation/G4Utilities/G4UserActions/src/RadLengthAction.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "RadLengthAction.h"
@@ -281,7 +281,7 @@ namespace G4UA
   }
 
   // how variables should be dumped in variables map
-  void RadLengthAction::fillVariables(std::vector<double> varvec, const std::string& name){
+  void RadLengthAction::fillVariables(const std::vector<double>& varvec, const std::string& name){
     // first three components should be added (deltaenergy, radlength, intlength)
     for(unsigned int i = 0; i<3; i++) variables[name].at(i) += varvec.at(i);
     // other components should be overwritten
diff --git a/Simulation/G4Utilities/G4UserActions/src/RadLengthAction.h b/Simulation/G4Utilities/G4UserActions/src/RadLengthAction.h
index 62f8f0b46987..d61bc2ee0739 100644
--- a/Simulation/G4Utilities/G4UserActions/src/RadLengthAction.h
+++ b/Simulation/G4Utilities/G4UserActions/src/RadLengthAction.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef G4UserActions_RadLengthAction_H
@@ -78,7 +78,7 @@ namespace G4UA
     ServiceHandle<ITHistSvc> m_hSvc;
 
     // methode to fill vector stored in variables map (index volume name)
-    void fillVariables(std::vector<double> varvec, const std::string& name);
+    void fillVariables(const std::vector<double>& varvec, const std::string& name);
   }; //class RadLengthAction
 
 } //namespace G4UA
-- 
GitLab