Skip to content

Commit

Permalink
Merge pull request #43778 from iarspider/followup-43771
Browse files Browse the repository at this point in the history
Replace C-style arrays with std::arrays (follow-up on #43771)
  • Loading branch information
cmsbuild authored Jan 30, 2024
2 parents d23804c + 7095b74 commit cd3bb3b
Showing 1 changed file with 5 additions and 51 deletions.
56 changes: 5 additions & 51 deletions L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define L1Trigger_L1CaloTrigger_Phase2L1CaloEGammaUtils

#include <ap_int.h>
#include <array>
#include <cstdio>
#include <fstream>
#include <iomanip>
Expand Down Expand Up @@ -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<linkECAL, TOWER_IN_PHI>, 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++) {
Expand Down Expand Up @@ -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<std::array<towerHCAL, TOWER_IN_PHI>, 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++) {
Expand Down Expand Up @@ -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<region3x4, N_REGIONS_PER_CARD> card3x4Regions;
std::array<towers3x4, N_REGIONS_PER_CARD> card3x4Towers;

public:
// constructor
Expand All @@ -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() {
Expand Down

0 comments on commit cd3bb3b

Please sign in to comment.