Skip to content

Commit

Permalink
Merge pull request #37766 from Dr15Jones/vertexException
Browse files Browse the repository at this point in the history
Add more context to Vertex exceptions
  • Loading branch information
cmsbuild committed May 3, 2022
2 parents 7d74e52 + 6b46824 commit c135871
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DataFormats/VertexReco/src/Vertex.cc
Expand Up @@ -83,7 +83,7 @@ TrackBaseRef Vertex::originalTrack(const Track& refTrack) const {
throw cms::Exception("Vertex") << "No refitted tracks stored in vertex\n";
std::vector<Track>::const_iterator it = find_if(refittedTracks_.begin(), refittedTracks_.end(), TrackEqual(refTrack));
if (it == refittedTracks_.end())
throw cms::Exception("Vertex") << "Refitted track not found in list\n";
throw cms::Exception("Vertex") << "Refitted track not found in list.\n pt used for comparison: " << refTrack.pt();
size_t pos = it - refittedTracks_.begin();
return tracks_[pos];
}
Expand Down
9 changes: 2 additions & 7 deletions RecoVertex/VertexPrimitives/interface/VertexException.h
Expand Up @@ -11,13 +11,8 @@

class VertexException : public cms::Exception {
public:
VertexException() throw() : cms::Exception("VertexException") {}
VertexException(const std::string& message) throw() : cms::Exception("VertexException"), theMessage(message) {}
~VertexException() throw() override {}
const char* what() const throw() override { return theMessage.c_str(); }

private:
std::string theMessage;
VertexException() : cms::Exception("VertexException") {}
explicit VertexException(const std::string& message) : cms::Exception("VertexException", message) {}
};

#endif
11 changes: 7 additions & 4 deletions RecoVertex/VertexPrimitives/src/TransientVertex.cc
Expand Up @@ -280,20 +280,23 @@ AlgebraicMatrix33 TransientVertex::tkToTkCovariance(const TransientTrack& t1, co

TransientTrack TransientVertex::originalTrack(const TransientTrack& refTrack) const {
if (theRefittedTracks.empty())
throw VertexException("No refitted tracks stored in vertex");
throw VertexException("TransientVertex::requested No refitted tracks stored in vertex");
std::vector<TransientTrack>::const_iterator it = find(theRefittedTracks.begin(), theRefittedTracks.end(), refTrack);
if (it == theRefittedTracks.end())
throw VertexException("Refitted track not found in list");
throw VertexException(
"TransientVertex::requested Refitted track not found in list.\n address used for comparison: ")
<< refTrack.basicTransientTrack();
size_t pos = it - theRefittedTracks.begin();
return theOriginalTracks[pos];
}

TransientTrack TransientVertex::refittedTrack(const TransientTrack& track) const {
if (theRefittedTracks.empty())
throw VertexException("No refitted tracks stored in vertex");
throw VertexException("TransientVertex::requested No refitted tracks stored in vertex");
std::vector<TransientTrack>::const_iterator it = find(theOriginalTracks.begin(), theOriginalTracks.end(), track);
if (it == theOriginalTracks.end())
throw VertexException("Track not found in list");
throw VertexException("transientVertex::requested Track not found in list.\n address used for comparison: ")
<< track.basicTransientTrack();
size_t pos = it - theOriginalTracks.begin();
return theRefittedTracks[pos];
}
Expand Down

0 comments on commit c135871

Please sign in to comment.