Skip to content

Commit c2ad54f

Browse files
authored
Merge pull request cms-sw#43282 from yuanchao/from-CMSSW_13_3_0_pre3_vertex
remove try/catch clause on accessing vertex collection
2 parents a85f1ca + b17589c commit c2ad54f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Alignment/OfflineValidation/plugins/PrimaryVertexValidation.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,10 @@ void PrimaryVertexValidation::analyze(const edm::Event& iEvent, const edm::Event
282282

283283
//edm::Handle<VertexCollection> vertices;
284284
edm::Handle<std::vector<Vertex>> vertices;
285-
286-
try {
287-
vertices = iEvent.getHandle(theVertexCollectionToken_);
288-
} catch (cms::Exception& er) {
289-
LogTrace("PrimaryVertexValidation") << "caught std::exception " << er.what() << std::endl;
285+
vertices = iEvent.getHandle(theVertexCollectionToken_);
286+
if (!vertices.isValid()) {
287+
edm::LogError("PrimaryVertexValidation") << "Vertex collection handle is not valid. Aborting!" << std::endl;
288+
return;
290289
}
291290

292291
std::vector<Vertex> vsorted = *(vertices);
@@ -295,7 +294,6 @@ void PrimaryVertexValidation::analyze(const edm::Event& iEvent, const edm::Event
295294
std::sort(vsorted.begin(), vsorted.end(), PrimaryVertexValidation::vtxSort);
296295

297296
// skip events with no PV, this should not happen
298-
299297
if (vsorted.empty())
300298
return;
301299

0 commit comments

Comments
 (0)