Skip to content

Commit 3d04e1f

Browse files
committed
use max instead if infinity which hasundefined behavior
1 parent 6648f85 commit 3d04e1f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

DataFormats/EgammaReco/interface/ElectronSeed.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ namespace reco {
112112

113113
unsigned int hitsMask() const;
114114
void initTwoHitSeed(const unsigned char hitMask);
115-
void setNegAttributes(const float dRZ2 = std::numeric_limits<float>::infinity(),
116-
const float dPhi2 = std::numeric_limits<float>::infinity(),
117-
const float dRZ1 = std::numeric_limits<float>::infinity(),
118-
const float dPhi1 = std::numeric_limits<float>::infinity());
119-
void setPosAttributes(const float dRZ2 = std::numeric_limits<float>::infinity(),
120-
const float dPhi2 = std::numeric_limits<float>::infinity(),
121-
const float dRZ1 = std::numeric_limits<float>::infinity(),
122-
const float dPhi1 = std::numeric_limits<float>::infinity());
115+
void setNegAttributes(const float dRZ2 = std::numeric_limits<float>::max(),
116+
const float dPhi2 = std::numeric_limits<float>::max(),
117+
const float dRZ1 = std::numeric_limits<float>::max(),
118+
const float dPhi1 = std::numeric_limits<float>::max());
119+
void setPosAttributes(const float dRZ2 = std::numeric_limits<float>::max(),
120+
const float dPhi2 = std::numeric_limits<float>::max(),
121+
const float dRZ1 = std::numeric_limits<float>::max(),
122+
const float dPhi1 = std::numeric_limits<float>::max());
123123

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

DataFormats/Math/interface/approx_log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ constexpr float approx_logf(float x) {
131131

132132
//x = std::max(std::min(x,MAXNUMF),0.f);
133133
float res = unsafe_logf<DEGREE>(x);
134-
res = (x < MAXNUMF) ? res : std::numeric_limits<float>::infinity();
134+
res = (x < MAXNUMF) ? res : std::numeric_limits<float>::max();
135135
return (x > 0) ? res : std::numeric_limits<float>::quiet_NaN();
136136
}
137137

RecoEgamma/EgammaElectronAlgos/src/ElectronSeedGenerator.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ namespace {
6464
if ((seed.caloCluster().key() == res.caloCluster().key()) && (seed.hitsMask() == res.hitsMask()) &&
6565
equivalent(seed, res)) {
6666
if (positron) {
67-
if (res.dRZPos(1) == std::numeric_limits<float>::infinity() &&
68-
res.dRZNeg(1) != std::numeric_limits<float>::infinity()) {
67+
if (res.dRZPos(1) == std::numeric_limits<float>::max() &&
68+
res.dRZNeg(1) != std::numeric_limits<float>::max()) {
6969
res.setPosAttributes(info->dRz2, info->dPhi2, info->dRz1, info->dPhi1);
7070
seed.setNegAttributes(res.dRZNeg(1), res.dPhiNeg(1), res.dRZNeg(0), res.dPhiNeg(0));
7171
break;
7272
} else {
73-
if (res.dRZPos(1) != std::numeric_limits<float>::infinity()) {
73+
if (res.dRZPos(1) != std::numeric_limits<float>::max()) {
7474
if (res.dRZPos(1) != seed.dRZPos(1)) {
7575
edm::LogWarning("ElectronSeedGenerator|BadValue")
7676
<< "this similar old seed already has another dRz2Pos"
@@ -82,13 +82,13 @@ namespace {
8282
}
8383
}
8484
} else {
85-
if (res.dRZNeg(1) == std::numeric_limits<float>::infinity() &&
86-
res.dRZPos(1) != std::numeric_limits<float>::infinity()) {
85+
if (res.dRZNeg(1) == std::numeric_limits<float>::max() &&
86+
res.dRZPos(1) != std::numeric_limits<float>::max()) {
8787
res.setNegAttributes(info->dRz2, info->dPhi2, info->dRz1, info->dPhi1);
8888
seed.setPosAttributes(res.dRZPos(1), res.dPhiPos(1), res.dRZPos(0), res.dPhiPos(0));
8989
break;
9090
} else {
91-
if (res.dRZNeg(1) != std::numeric_limits<float>::infinity()) {
91+
if (res.dRZNeg(1) != std::numeric_limits<float>::max()) {
9292
if (res.dRZNeg(1) != seed.dRZNeg(1)) {
9393
edm::LogWarning("ElectronSeedGenerator|BadValue")
9494
<< "this old seed already has another dRz2"

0 commit comments

Comments
 (0)