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

Fix rare crash in pixel template interpolation #34846

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CondFormats/SiPixelTransient/src/SiPixelTemplate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
#include "CondFormats/SiPixelTransient/interface/SimplePixel.h"
#include "FWCore/Utilities/interface/FileInPath.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/isFinite.h"
#define LOGERROR(x) LogError(x)
#define LOGINFO(x) LogInfo(x)
#define LOGWARNING(x) LogWarning(x)
Expand Down Expand Up @@ -1392,6 +1393,12 @@ bool SiPixelTemplate::interpolate(int id, float cotalpha, float cotbeta, float l
throw cms::Exception("DataCorrupt")
<< "SiPixelTemplate::interpolate can't find needed template ID = " << id << std::endl;
}

//check for nan's
if (!edm::isFinite(cotalpha) || !edm::isFinite(cotbeta)) {
success_ = false;
return success_;
}
#else
assert(index_id_ >= 0 && index_id_ < (int)thePixelTemp_.size());
#endif
Expand Down
7 changes: 7 additions & 0 deletions CondFormats/SiPixelTransient/src/SiPixelTemplate2D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "CondFormats/SiPixelTransient/interface/SiPixelTemplate2D.h"
#include "FWCore/Utilities/interface/FileInPath.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/isFinite.h"
#define LOGERROR(x) LogError(x)
#define LOGINFO(x) LogInfo(x)
#define ENDL " "
Expand Down Expand Up @@ -679,6 +680,12 @@ bool SiPixelTemplate2D::interpolate(int id, float cotalpha, float cotbeta, float
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
throw cms::Exception("DataCorrupt")
<< "SiPixelTemplate2D::illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;

//check for nan's
if (!edm::isFinite(cotalpha) || !edm::isFinite(cotbeta)) {
success_ = false;
return success_;
}
#else
std::cout << "SiPixelTemplate:2D:illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
#endif
Expand Down