Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 0 additions & 14 deletions Geometry/HGCalCommonData/interface/HGCalTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,6 @@ class HGCalTypes {
static constexpr int32_t faccell_ = 100;
static constexpr int32_t faccelltype_ = 10000;
static constexpr int32_t faccell6_ = 1000;
static constexpr int32_t layerType_[7] = {HGCalTypes::WaferCenter,
HGCalTypes::WaferCenterB,
HGCalTypes::WaferCenterR,
HGCalTypes::CornerCenterYp,
HGCalTypes::CornerCenterYm,
HGCalTypes::CornerCenterXp,
HGCalTypes::CornerCenterXm};
static constexpr std::string layerTypes_[7] = {
"Center", "CenterB", "CenterYp", "CenterYm", "CenterR", "CenterXp", "CenterXm"};
static constexpr std::string waferType_[4] = {"HD120", "LD200", "LD300", "HD200"};
static constexpr std::string waferTypeX_[27] = {
"Full", "Five", "ChopTwo", "ChopTwoM", "Half", "Semi", "Semi2", "Three", "Half2",
"Five2", "Unknown10", "LDTop", "LDBottom", "LDLeft", "LDRight", "LDFive", "LDThree", "Unknown17",
"Unknown18", "Unknown19", "Unknown20", "HDTop", "HDBottom", "HDLeft", "HDRight", "HDFive", "Out"};
};

#endif
24 changes: 20 additions & 4 deletions Geometry/HGCalCommonData/src/HGCalTypes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,31 @@ int32_t HGCalTypes::getUnpackedCellType6(int id) { return (id / faccell6_); }
int32_t HGCalTypes::getUnpackedCell6(int id) { return (id % faccell6_); }

int32_t HGCalTypes::layerType(int type) {
return ((type >= 0) && (type < 7)) ? HGCalTypes::layerType_[type] : HGCalTypes::WaferCenter;
static constexpr int32_t layerTypeX[7] = {HGCalTypes::WaferCenter,
HGCalTypes::WaferCenterB,
HGCalTypes::WaferCenterR,
HGCalTypes::CornerCenterYp,
HGCalTypes::CornerCenterYm,
HGCalTypes::CornerCenterXp,
HGCalTypes::CornerCenterXm};
return ((type >= 0) && (type < 7)) ? layerTypeX[type] : HGCalTypes::WaferCenter;
}

std::string HGCalTypes::layerTypeX(int32_t type) { return layerTypes_[HGCalTypes::layerType(type)]; }
std::string HGCalTypes::layerTypeX(int32_t type) {
static constexpr std::string layerTypes[7] = {
"Center", "CenterB", "CenterYp", "CenterYm", "CenterR", "CenterXp", "CenterXm"};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::string can not be used as constexpr like this even if it compiles. The constexpr-ness of std::string means that it can be used in constexpr functions. constexpr std::string objects outside of constexpr functions are IIRC undefined behavior (or "program is ill-formed, no diagnostic required", or similar).

return layerTypes[layerType(type)];
}

std::string HGCalTypes::waferType(int32_t type) {
return (((type >= 0) && (type < 4)) ? HGCalTypes::waferType_[type] : "Undefined");
static constexpr std::string waferType[4] = {"HD120", "LD200", "LD300", "HD200"};
return (((type >= 0) && (type < 4)) ? waferType[type] : "Undefined");
}

std::string HGCalTypes::waferTypeX(int32_t type) {
return (((type >= 0) && (type < 27)) ? HGCalTypes::waferTypeX_[type] : "UnknownXX");
static constexpr std::string waferTypeX[27] = {
"Full", "Five", "ChopTwo", "ChopTwoM", "Half", "Semi", "Semi2", "Three", "Half2",
"Five2", "Unknown10", "LDTop", "LDBottom", "LDLeft", "LDRight", "LDFive", "LDThree", "Unknown17",
"Unknown18", "Unknown19", "Unknown20", "HDTop", "HDBottom", "HDLeft", "HDRight", "HDFive", "Out"};
return (((type >= 0) && (type < 27)) ? waferTypeX[type] : "UnknownXX");
}