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

Remove deprecated usages of isnan or isinf #33418

Merged
merged 3 commits into from Apr 21, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CalibCalorimetry/HcalAlgos/interface/HcalPulseShapes.h
Expand Up @@ -7,6 +7,7 @@
#include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShape.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Utilities/interface/isFinite.h"
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"

Expand Down Expand Up @@ -62,7 +63,7 @@ class HcalPulseShapes {
for (unsigned i = 0; i < 2 * nbin - 1; ++i) {
for (unsigned j = 0; j < std::min(i + 1, nbin); ++j) {
double tmp = f1(j) * f2(i - j);
if (std::isnan(tmp) or std::isinf(tmp))
if (edm::isNotFinite(tmp))
continue;
result[i] += tmp;
}
Expand Down
3 changes: 2 additions & 1 deletion DQMOffline/Muon/src/GEMEfficiencyHarvester.cc
@@ -1,6 +1,7 @@
#include "DQMOffline/Muon/interface/GEMEfficiencyHarvester.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/isFinite.h"

#include "TEfficiency.h"

Expand Down Expand Up @@ -365,7 +366,7 @@ void GEMEfficiencyHarvester::doResolution(DQMStore::IBooker& ibooker,
// FIXME
// `GetSkewness` seems to returns nan when its histogram has no entry..
const double skewness = hist->GetSkewness();
if (not std::isnan(skewness))
if (edm::isFinite(skewness))
h_skewness->SetBinContent(xbin, ybin, skewness);

h_mean->SetBinError(xbin, ybin, hist->GetMeanError());
Expand Down
Expand Up @@ -28,6 +28,7 @@ Description: [one line class summary]
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/isFinite.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHit.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHitContainer.h"
Expand Down Expand Up @@ -319,7 +320,6 @@ bool CTPPSFastTrackingProducer::SearchTrack(int i,
double& X2d,
double& Y2d) {
// Given 1 hit in Tracker1 and 1 hit in Tracker2 try to make a track with Hector
double theta = 0.;
xi = 0;
t = 0;
partP = 0;
Expand Down Expand Up @@ -360,8 +360,7 @@ bool CTPPSFastTrackingProducer::SearchTrack(int i,
thx *= -Direction; // invert to the CMS ref frame

// Protect for unphysical results
if (std::isnan(eloss) || std::isinf(eloss) || std::isnan(thx) || std::isinf(thx) || std::isnan(thy) ||
std::isinf(thy))
if (edm::isNotFinite(eloss) || edm::isNotFinite(thx) || edm::isNotFinite(thy))
return false;
//

Expand All @@ -378,18 +377,17 @@ bool CTPPSFastTrackingProducer::SearchTrack(int i,
return false;
//
// Calculate the reconstructed track parameters
theta = sqrt(thx * thx + thy * thy) * urad;
double theta = sqrt(thx * thx + thy * thy) * urad;
xi = eloss / fBeamEnergy;
double energy = fBeamEnergy * (1. - xi);
partP = sqrt(energy * energy - PPSTools::ProtonMassSQ);
t = -2. * (PPSTools::ProtonMassSQ - fBeamEnergy * energy + fBeamMomentum * partP * cos(theta));
pt = sqrt(pow(partP * thx * urad, 2) + pow(partP * thy * urad, 2));
pt = partP * theta;
perrotta marked this conversation as resolved.
Show resolved Hide resolved
if (xi < 0. || xi > 1. || t < 0. || t > 10. || pt <= 0.) {
xi = 0.;
t = 0.;
partP = 0.;
pt = 0.;
theta = 0.;
x0 = 0.;
y0 = 0.;
return false; // unphysical values
Expand All @@ -416,7 +414,7 @@ void CTPPSFastTrackingProducer::ReconstructArm(
y2 *= mm_to_um;
pps_station->setPositions(x1, y1, x2, y2);
double energy = pps_station->getE(AM); // dummy call needed to calculate some Hector internal parameter
if (std::isnan(energy) || std::isinf(energy))
if (edm::isNotFinite(energy))
return;
tx = pps_station->getTXIP(); // change orientation to CMS
ty = pps_station->getTYIP();
Expand Down
13 changes: 6 additions & 7 deletions RecoBTag/FeatureTools/src/deep_helpers.cc
@@ -1,5 +1,6 @@
#include "RecoBTag/FeatureTools/interface/deep_helpers.h"
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include "FWCore/Utilities/interface/isFinite.h"

namespace btagbtvdeep {

Expand All @@ -18,13 +19,11 @@ namespace btagbtvdeep {

// remove infs and NaNs with value (adapted from DeepNTuples)
const float catch_infs(const float in, const float replace_value) {
if (in == in) { // check if NaN
if (std::isinf(in))
return replace_value;
else if (in < -1e32 || in > 1e32)
return replace_value;
return in;
}
if (edm::isNotFinite(in))
return replace_value;
else if (in < -1e32 || in > 1e32)
return replace_value;
return in;
return replace_value;
}

Expand Down
3 changes: 2 additions & 1 deletion RecoParticleFlow/PFProducer/src/MLPFModel.cc
@@ -1,5 +1,6 @@
#include "RecoParticleFlow/PFProducer/interface/MLPFModel.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/isFinite.h"
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlockElementSuperCluster.h"
Expand Down Expand Up @@ -148,7 +149,7 @@ namespace reco::mlpf {
float normalize(float in) {
if (std::abs(in) > 1e4f) {
return 0.0;
} else if (std::isnan(in)) {
} else if (edm::isNotFinite(in)) {
return 0.0;
}
return in;
Expand Down
Expand Up @@ -2,6 +2,7 @@
#include "RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h"
#include "RecoPixelVertexing/PixelTriplets/interface/CosmicLayerTriplets.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/isFinite.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
#include "RecoTracker/TkSeedGenerator/interface/FastHelix.h"
void SeedGeneratorForCosmics::init(const SiStripRecHit2DCollection& collstereo,
Expand Down Expand Up @@ -117,8 +118,8 @@ bool SeedGeneratorForCosmics::seeds(TrajectorySeedCollection& output,
FastHelix helix(inner, middle, outer, magfield->nominalValue(), &(*magfield));
GlobalVector gv = helix.stateAtVertex().momentum();
float ch = helix.stateAtVertex().charge();
float Mom = sqrt(gv.x() * gv.x() + gv.y() * gv.y() + gv.z() * gv.z());
if (Mom > 1000 || std::isnan(Mom))
float mom2 = gv.x() * gv.x() + gv.y() * gv.y() + gv.z() * gv.z();
if (mom2 > 1e06f || edm::isNotFinite(mom2))
continue; // ChangedByDaniele

if (gv.y() > 0) {
Expand Down