diff --git a/InnerDetector/InDetValidation/InDetPhysValMonitoring/src/InDetPhysValMonitoringTool.cxx b/InnerDetector/InDetValidation/InDetPhysValMonitoring/src/InDetPhysValMonitoringTool.cxx index b73cfa845f4bcde9a71194a2f5542a69e952787f..7c873dc9e911721684092be5aee6cc76794bf5f9 100644 --- a/InnerDetector/InDetValidation/InDetPhysValMonitoring/src/InDetPhysValMonitoringTool.cxx +++ b/InnerDetector/InDetValidation/InDetPhysValMonitoring/src/InDetPhysValMonitoringTool.cxx @@ -497,10 +497,11 @@ const std::vector<const xAOD::TruthParticle*> InDetPhysValMonitoringTool::getTruthParticles() { // truthParticles.clear(); std::vector<const xAOD::TruthParticle*> tempVec {}; - if (m_truthParticleName.key().empty()) { - return tempVec; - } if (m_pileupSwitch == "All") { + + if (m_truthParticleName.key().empty()) { + return tempVec; + } SG::ReadHandle<xAOD::TruthParticleContainer> truthParticleContainer( m_truthParticleName); if (not truthParticleContainer.isValid()) { return tempVec; @@ -518,7 +519,9 @@ InDetPhysValMonitoringTool::getTruthParticles() { const auto& links = event->truthParticleLinks(); tempVec.reserve(event->nTruthParticles()); for (const auto& link : links) { - tempVec.push_back(*link); + if (link.isValid()){ + tempVec.push_back(*link); + } } } } else if (m_pileupSwitch == "PileUp") {