Skip to content

Commit 08f930f

Browse files
authored
Merge pull request #48051 from BenjaminRS/L1TrackObjectNtupleMaker_SimVertexBugFix
[L1T] Fixing a bug where an empty SimVertex collection would crash the L1TrackObjectNtupleMaker (Phase2)
2 parents 0fd66fe + 26f9816 commit 08f930f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,8 +2391,12 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
23912391
}
23922392

23932393
if (SimVertexHandle.isValid()) {
2394-
const SimVertex simPVh = *(SimVertexHandle->begin());
2395-
m_pv_MC->push_back(simPVh.position().z());
2394+
if (!SimVertexHandle->empty()) {
2395+
const SimVertex simPVh = *(SimVertexHandle->begin());
2396+
m_pv_MC->push_back(simPVh.position().z());
2397+
} else {
2398+
edm::LogWarning("MissingCollectionEntries") << "\nWarning: SimVertex collection is empty!" << std::endl;
2399+
}
23962400
} else {
23972401
edm::LogWarning("DataNotFound") << "\nWarning: SimVertexHandle not found in the event" << std::endl;
23982402
}

0 commit comments

Comments
 (0)