Skip to content

Commit

Permalink
Fix enums
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Aug 6, 2024
1 parent 73ddb48 commit ed15064
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
6 changes: 4 additions & 2 deletions k4GaudiPandora/include/CalorimeterHitType.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class CHT {

/** C'tor for encoding the calo type inforamtion */
CHT(CaloType c, CaloID n, Layout l, unsigned lay)
: m_type(c * fCaloType + n * fCaloID + l * fLayout + lay * fLayer) {}
// : m_type((int)c + (int)n * fCaloID + (int)l * fLayout + lay * fLayer) {}
: m_type(static_cast<int>(c) + static_cast<int>(n) * fCaloID + static_cast<int>(l) * fLayout + lay * fLayer) {}


/** calorimeter type: CHT::em , CHT::had, CHT::muon */
CaloType caloType() const { return (CaloType)(m_type % fCaloID); }
Expand Down Expand Up @@ -126,4 +128,4 @@ CHT::CaloID caloIDFromString(const std::string& name);
is found, CHT::em is returned.*/
CHT::CaloType caloTypeFromString(const std::string& name);

#endif
#endif
60 changes: 30 additions & 30 deletions k4GaudiPandora/src/CalorimeterHitType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,54 +25,54 @@ std::ostream& operator<<(std::ostream& os, const CHT& cht) {
os << " calo hit type: ";

switch (cht.caloType()) {
case CHT::em:
case CHT::CaloType::em:
os << " em, ";
break;
case CHT::had:
case CHT::CaloType::had:
os << " had, ";
break;
case CHT::muon:
case CHT::CaloType::muon:
os << " muon, ";
break;
default:
os << " - ,";
}
switch (cht.caloID()) {
case CHT::ecal:
case CHT::CaloID::ecal:
os << "ecal, ";
break;
case CHT::hcal:
case CHT::CaloID::hcal:
os << "hcal, ";
break;
case CHT::yoke:
case CHT::CaloID::yoke:
os << "yoke, ";
break;
case CHT::lcal:
case CHT::CaloID::lcal:
os << "lcal, ";
break;
case CHT::lhcal:
case CHT::CaloID::lhcal:
os << "lhcal, ";
break;
case CHT::bcal:
case CHT::CaloID::bcal:
os << "bcal, ";
break;
default:
os << " - ,";
}
switch (cht.layout()) {
case CHT::any:
case CHT::Layout::any:
os << "any, ";
break;
case CHT::ring:
case CHT::Layout::ring:
os << "ring, ";
break;
case CHT::endcap:
case CHT::Layout::endcap:
os << "endcap, ";
break;
case CHT::barrel:
case CHT::Layout::barrel:
os << "barrel, ";
break;
case CHT::plug:
case CHT::Layout::plug:
os << "plug, ";
break;
default:
Expand All @@ -90,49 +90,49 @@ CHT::Layout layoutFromString(const std::string& name) {
std::transform(str.begin(), str.end(), str.begin(), ::tolower);

if (str.find("ring") != std::string::npos)
return CHT::ring;
return CHT::Layout::ring;
if (str.find("plug") != std::string::npos)
return CHT::plug;
return CHT::Layout::plug;
if (str.find("endcap") != std::string::npos)
return CHT::endcap;
return CHT::Layout::endcap;
if (str.find("barrel") != std::string::npos)
return CHT::barrel;
return CHT::Layout::barrel;

std::cout << " not found :" << str << " in " << name << std::endl;
return CHT::any;
return CHT::Layout::any;
}

CHT::CaloID caloIDFromString(const std::string& name) {
std::string str(name);
std::transform(str.begin(), str.end(), str.begin(), ::tolower);

if (str.find("ecal") != std::string::npos)
return CHT::ecal;
return CHT::CaloID::ecal;
if (str.find("hcal") != std::string::npos)
return CHT::hcal;
return CHT::CaloID::hcal;
if (str.find("yoke") != std::string::npos)
return CHT::yoke;
return CHT::CaloID::yoke;
if (str.find("lcal") != std::string::npos)
return CHT::lcal;
return CHT::CaloID::lcal;
if (str.find("lhcal") != std::string::npos)
return CHT::lhcal;
return CHT::CaloID::lhcal;
if (str.find("bcal") != std::string::npos)
return CHT::bcal;
return CHT::CaloID::bcal;

return CHT::unknown;
return CHT::CaloID::unknown;
}

CHT::CaloType caloTypeFromString(const std::string& name) {
std::string str(name);
std::transform(str.begin(), str.end(), str.begin(), ::tolower);

if (str.find("em") != std::string::npos)
return CHT::em;
return CHT::CaloType::em;
if (str.find("had") != std::string::npos)
return CHT::had;
return CHT::CaloType::had;
if (str.find("muon") != std::string::npos)
return CHT::muon;
return CHT::CaloType::muon;

// jl: this should probably also have a separate "unknown" or "any" value?
return CHT::em;
return CHT::CaloType::em;
}

0 comments on commit ed15064

Please sign in to comment.