Skip to content

Commit

Permalink
Merge pull request #45488 from smuzaffar/141x-max-to-infinity
Browse files Browse the repository at this point in the history
Use max instead if infinity which hasundefined behavior
  • Loading branch information
cmsbuild authored Jul 18, 2024
2 parents 4be3c51 + 3d04e1f commit a18756f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
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

0 comments on commit a18756f

Please sign in to comment.