From 886ae91d68fe77f0e7657b5f15ff9b22180e53bf Mon Sep 17 00:00:00 2001 From: Ivan Razumov Date: Wed, 24 Jan 2024 09:59:43 +0100 Subject: [PATCH 1/2] Replace C-style arrays with std::arrays (follow-up on comments in #43771) --- .../interface/Phase2L1CaloEGammaUtils.h | 56 ++----------------- 1 file changed, 5 insertions(+), 51 deletions(-) diff --git a/L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h b/L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h index e6e2f15d43d3c..8e88fcaba8e89 100644 --- a/L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h +++ b/L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h @@ -5,6 +5,7 @@ #define L1Trigger_L1CaloTrigger_Phase2L1CaloEGammaUtils #include +#include #include #include #include @@ -389,28 +390,12 @@ namespace p2eg { class region3x4 { private: int idx_ = -1; - linkECAL linksECAL[TOWER_IN_ETA][TOWER_IN_PHI]; // 3x4 in towers + std::array < std::array, TOWER_IN_ETA > linksECAL; // 3x4 in towers public: // constructor region3x4() { idx_ = -1; } - // copy constructor - region3x4(const region3x4& other) { - idx_ = other.idx_; - for (int i = 0; i < TOWER_IN_ETA; i++) { - for (int j = 0; j < TOWER_IN_PHI; j++) { - linksECAL[i][j] = other.linksECAL[i][j]; - } - } - } - - // overload operator= to use copy constructor - region3x4 operator=(const region3x4& other) { - const region3x4& newRegion(other); - return newRegion; - }; - // set members inline void zeroOut() { for (int i = 0; i < TOWER_IN_ETA; i++) { @@ -464,28 +449,12 @@ namespace p2eg { class towers3x4 { private: int idx_ = -1; - towerHCAL towersHCAL[TOWER_IN_ETA][TOWER_IN_PHI]; // 3x4 in towers + std::array, TOWER_IN_ETA> towersHCAL; // 3x4 in towers public: // constructor towers3x4() { idx_ = -1; }; - // copy constructor - towers3x4(const towers3x4& other) { - idx_ = other.idx_; - for (int i = 0; i < TOWER_IN_ETA; i++) { - for (int j = 0; j < TOWER_IN_PHI; j++) { - towersHCAL[i][j] = other.towersHCAL[i][j]; - } - }; - }; - - // overload operator= to use copy constructor - towers3x4 operator=(const towers3x4& other) { - const towers3x4& newTowers3x4(other); - return newTowers3x4; - }; - // set members inline void zeroOut() { for (int i = 0; i < TOWER_IN_ETA; i++) { @@ -514,8 +483,8 @@ namespace p2eg { class card { private: int idx_ = -1; - region3x4 card3x4Regions[N_REGIONS_PER_CARD]; - towers3x4 card3x4Towers[N_REGIONS_PER_CARD]; + std::array card3x4Regions; + std::array card3x4Towers; public: // constructor @@ -529,21 +498,6 @@ namespace p2eg { } }; - // copy constructor - card(const card& other) { - idx_ = other.idx_; - for (int i = 0; i < N_REGIONS_PER_CARD; i++) { - card3x4Regions[i] = other.card3x4Regions[i]; - card3x4Towers[i] = other.card3x4Towers[i]; - } - }; - - // overload operator= to use copy constructor - card operator=(const card& other) { - const card& newCard(other); - return newCard; - }; - // set members inline void setIdx(int idx) { idx_ = idx; }; inline void zeroOut() { From 7095b74d3292340d29b4d93f4e1856869eaa064d Mon Sep 17 00:00:00 2001 From: Ivan Razumov Date: Wed, 24 Jan 2024 14:23:11 +0100 Subject: [PATCH 2/2] Code-format --- L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h b/L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h index 8e88fcaba8e89..6504ae2dbb816 100644 --- a/L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h +++ b/L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h @@ -390,7 +390,7 @@ namespace p2eg { class region3x4 { private: int idx_ = -1; - std::array < std::array, TOWER_IN_ETA > linksECAL; // 3x4 in towers + std::array, TOWER_IN_ETA> linksECAL; // 3x4 in towers public: // constructor