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

Use max instead if infinity which hasundefined behavior #45488

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions DataFormats/EgammaReco/interface/ElectronSeed.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ namespace reco {

unsigned int hitsMask() const;
void initTwoHitSeed(const unsigned char hitMask);
void setNegAttributes(const float dRZ2 = std::numeric_limits<float>::infinity(),
const float dPhi2 = std::numeric_limits<float>::infinity(),
const float dRZ1 = std::numeric_limits<float>::infinity(),
const float dPhi1 = std::numeric_limits<float>::infinity());
void setPosAttributes(const float dRZ2 = std::numeric_limits<float>::infinity(),
const float dPhi2 = std::numeric_limits<float>::infinity(),
const float dRZ1 = std::numeric_limits<float>::infinity(),
const float dPhi1 = std::numeric_limits<float>::infinity());
void setNegAttributes(const float dRZ2 = std::numeric_limits<float>::max(),
const float dPhi2 = std::numeric_limits<float>::max(),
const float dRZ1 = std::numeric_limits<float>::max(),
const float dPhi1 = std::numeric_limits<float>::max());
void setPosAttributes(const float dRZ2 = std::numeric_limits<float>::max(),
const float dPhi2 = std::numeric_limits<float>::max(),
const float dRZ1 = std::numeric_limits<float>::max(),
const float dPhi1 = std::numeric_limits<float>::max());

//this is a backwards compatible function designed to
//convert old format ElectronSeeds to the new format
Expand All @@ -140,7 +140,7 @@ namespace reco {
static float bestVal(float val1, float val2) { return std::abs(val1) < std::abs(val2) ? val1 : val2; }
template <typename T>
T getVal(unsigned int hitNr, T PMVars::*val) const {
return hitNr < hitInfo_.size() ? hitInfo_[hitNr].*val : std::numeric_limits<T>::infinity();
return hitNr < hitInfo_.size() ? hitInfo_[hitNr].*val : std::numeric_limits<T>::max();
}
static std::vector<unsigned int> hitNrsFromMask(unsigned int hitMask);

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/Math/interface/approx_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ constexpr float approx_logf(float x) {

//x = std::max(std::min(x,MAXNUMF),0.f);
float res = unsafe_logf<DEGREE>(x);
res = (x < MAXNUMF) ? res : std::numeric_limits<float>::infinity();
res = (x < MAXNUMF) ? res : std::numeric_limits<float>::max();
return (x > 0) ? res : std::numeric_limits<float>::quiet_NaN();
}

Expand Down
12 changes: 6 additions & 6 deletions RecoEgamma/EgammaElectronAlgos/src/ElectronSeedGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ namespace {
if ((seed.caloCluster().key() == res.caloCluster().key()) && (seed.hitsMask() == res.hitsMask()) &&
equivalent(seed, res)) {
if (positron) {
if (res.dRZPos(1) == std::numeric_limits<float>::infinity() &&
res.dRZNeg(1) != std::numeric_limits<float>::infinity()) {
if (res.dRZPos(1) == std::numeric_limits<float>::max() &&
res.dRZNeg(1) != std::numeric_limits<float>::max()) {
res.setPosAttributes(info->dRz2, info->dPhi2, info->dRz1, info->dPhi1);
seed.setNegAttributes(res.dRZNeg(1), res.dPhiNeg(1), res.dRZNeg(0), res.dPhiNeg(0));
break;
} else {
if (res.dRZPos(1) != std::numeric_limits<float>::infinity()) {
if (res.dRZPos(1) != std::numeric_limits<float>::max()) {
if (res.dRZPos(1) != seed.dRZPos(1)) {
edm::LogWarning("ElectronSeedGenerator|BadValue")
<< "this similar old seed already has another dRz2Pos"
Expand All @@ -82,13 +82,13 @@ namespace {
}
}
} else {
if (res.dRZNeg(1) == std::numeric_limits<float>::infinity() &&
res.dRZPos(1) != std::numeric_limits<float>::infinity()) {
if (res.dRZNeg(1) == std::numeric_limits<float>::max() &&
res.dRZPos(1) != std::numeric_limits<float>::max()) {
res.setNegAttributes(info->dRz2, info->dPhi2, info->dRz1, info->dPhi1);
seed.setPosAttributes(res.dRZPos(1), res.dPhiPos(1), res.dRZPos(0), res.dPhiPos(0));
break;
} else {
if (res.dRZNeg(1) != std::numeric_limits<float>::infinity()) {
if (res.dRZNeg(1) != std::numeric_limits<float>::max()) {
if (res.dRZNeg(1) != seed.dRZNeg(1)) {
edm::LogWarning("ElectronSeedGenerator|BadValue")
<< "this old seed already has another dRz2"
Expand Down