Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace C-style arrays with std::arrays (follow-up on #43771) #43778

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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