From d841f500b01a04c29fefdf57a27e06cf28a1dcec Mon Sep 17 00:00:00 2001
From: Shaun Roe <shaun.roe@cern.ch>
Date: Mon, 23 Jan 2023 12:51:02 +0100
Subject: [PATCH] solve cppcheck/clang defect

---
 .../TrigT1/L1CaloFEX/L1CaloFEXSim/src/gFEXFPGA.cxx | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/Trigger/TrigT1/L1CaloFEX/L1CaloFEXSim/src/gFEXFPGA.cxx b/Trigger/TrigT1/L1CaloFEX/L1CaloFEXSim/src/gFEXFPGA.cxx
index 3a0f40c8542..9789366fc16 100644
--- a/Trigger/TrigT1/L1CaloFEX/L1CaloFEXSim/src/gFEXFPGA.cxx
+++ b/Trigger/TrigT1/L1CaloFEX/L1CaloFEXSim/src/gFEXFPGA.cxx
@@ -16,7 +16,8 @@
 #include "GaudiKernel/ISvcLocator.h"
 #include "StoreGate/WriteHandle.h"
 #include "StoreGate/ReadHandle.h"
-#include <vector>
+#include <array>
+#include <algorithm>
 
 
 namespace LVL1 {
@@ -129,11 +130,8 @@ namespace LVL1 {
       uint32_t gFEXtowerID = 0;
 
       // Assign ID based on FPGA (FPGA-A 0->0; FPGA-B 1->10000, FPGA-C 2->20000) and gTower number assigned as per firmware convention
-      if (Fpga == 0){
-         gFEXtowerID = gFEXtowerID;
-      }
-      else if (Fpga == 1){
-         gFEXtowerID = gFEXtowerID + 10000;
+      if (Fpga == 1){
+         gFEXtowerID +=10000;
       }
 
       SG::ReadHandle<gTowerContainer> gFEXFPGA_gTowerContainer(m_gFEXFPGA_gTowerContainerKey/*,ctx*/);
@@ -260,13 +258,13 @@ void gFEXFPGA::getEtaPhi ( float &Eta, float &Phi, int iEta, int iPhi) const{
    float s_centralPhiWidth = (2*M_PI)/32; //In central region, gFex has 32 bins in phi
    float s_forwardPhiWidth = (2*M_PI)/16; //In forward region, gFex has 16 bins in phi (before rearranging bins)
 
-   const std::vector<float> s_EtaCenter = { -4.7, -4.2, -3.7, -3.4, -3.2, -3, 
+   constexpr std::array<float, 40> s_EtaCenter = { -4.7, -4.2, -3.7, -3.4, -3.2, -3, 
                                             -2.8, -2.6, -2.35, -2.1, -1.9, -1.7, -1.5, -1.3, -1.1, -0.9,  
                                             -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9, 1.1,                                                 
                                             1.3, 1.5, 1.7, 1.9, 2.1, 2.35, 2.6, 2.8, 3.0,
                                             3.2, 3.4, 3.7, 4.2, 4.7};
 
-   Eta = s_EtaCenter[iEta]; 
+   Eta = s_EtaCenter.at(iEta); 
 
    float Phi_gFex = -99;
    if (( iEta <= 3 ) || ( (iEta >= 36) )){
-- 
GitLab