Skip to content

Commit

Permalink
Add check if track angles are finite to avoid rare crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Oz Amram committed Aug 11, 2021
1 parent 0b98ed0 commit 19ed713
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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

0 comments on commit 19ed713

Please sign in to comment.