diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/HighLevelBTagAlg.cxx b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/HighLevelBTagAlg.cxx index 444b50c7a58072fb85b62a68ef00755a12a7ab26..0f88f4e5737182dfb6525c49194d7f9ce826962c 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/HighLevelBTagAlg.cxx +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/HighLevelBTagAlg.cxx @@ -68,11 +68,17 @@ namespace Analysis { StatusCode HighLevelBTagAlg::execute() { //retrieve the BTagging container SG::ReadHandle< xAOD::BTaggingContainer > h_btagContainer( m_BTagCollectionName); - SG::ReadDecorHandle<xAOD::BTaggingContainer, ElementLink< xAOD::JetContainer > > h_btagJetLinkName (m_btagJetLinkName); if (!h_btagContainer.isValid()) { ATH_MSG_ERROR( " cannot retrieve BTagging container with key " << m_BTagCollectionName.key() ); return StatusCode::FAILURE; } + + if (h_btagContainer->size() == 0) { + ATH_MSG_DEBUG("#BTAG# Empty BTagging collection"); + return StatusCode::SUCCESS; + } + + SG::ReadDecorHandle<xAOD::BTaggingContainer, ElementLink< xAOD::JetContainer > > h_btagJetLinkName (m_btagJetLinkName); if (!h_btagJetLinkName.isAvailable()) { ATH_MSG_ERROR( " cannot retrieve Jet container EL decoration with key " << m_btagJetLinkName.key() ); return StatusCode::FAILURE; diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetSecVertexingAlg.cxx b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetSecVertexingAlg.cxx index 0d22f0481711d62f1a777b0b389ae6d1e0a6dd63..486a60655e39efe9f667f34f7e1362f51ad6f694 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetSecVertexingAlg.cxx +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetSecVertexingAlg.cxx @@ -98,6 +98,31 @@ namespace Analysis { return StatusCode::FAILURE; } + SG::WriteHandle<xAOD::VertexContainer> h_BTagSVCollectionName; + SG::WriteHandle<xAOD::BTagVertexContainer> h_BTagJFVtxCollectionName; + + std::string basename = m_secVertexFinderBaseName; + /* Record the BTagging JF Vertex output container */ + if (basename == "JetFitter") { + ATH_MSG_DEBUG("#BTAG# Record the BTagging JF Vertex output container"); + h_BTagJFVtxCollectionName = SG::WriteHandle<xAOD::BTagVertexContainer>(m_BTagJFVtxCollectionName); + ATH_CHECK( h_BTagJFVtxCollectionName.record(std::make_unique<xAOD::BTagVertexContainer>(), + std::make_unique<xAOD::BTagVertexAuxContainer>()) ); + } + + /* Record the BTagging Secondary Vertex output container */ + if ((basename == "SV1") || (basename == "MSV")) { + ATH_MSG_DEBUG("#BTAG# Record the BTagging Secondary Vertex output container"); + h_BTagSVCollectionName = SG::WriteHandle<xAOD::VertexContainer>(m_BTagSVCollectionName); + ATH_CHECK( h_BTagSVCollectionName.record(std::make_unique<xAOD::VertexContainer>(), + std::make_unique<xAOD::VertexAuxContainer>()) ); + } + + if (h_JetCollectionName->size() == 0) { + ATH_MSG_DEBUG("#BTAG# Empty Jet collection"); + return StatusCode::SUCCESS; + } + SG::ReadDecorHandle<xAOD::JetContainer, std::vector<ElementLink< xAOD::TrackParticleContainer> > > h_jetParticleLinkName (m_jetParticleLinkName); if (!h_jetParticleLinkName.isAvailable()) { ATH_MSG_ERROR( " cannot retrieve jet container particle EL decoration with key " << m_jetParticleLinkName.key() ); @@ -138,7 +163,6 @@ namespace Analysis { } } - if (! primaryVertex) { ATH_MSG_DEBUG("#BTAG# No vertex labeled as VxType::PriVtx!"); xAOD::VertexContainer::const_iterator fz = h_VertexCollectionName->begin(); @@ -149,26 +173,6 @@ namespace Analysis { } const xAOD::Vertex& PrimaryVtx = *primaryVertex; - std::string basename = m_secVertexFinderBaseName; - - SG::WriteHandle<xAOD::VertexContainer> h_BTagSVCollectionName; - SG::WriteHandle<xAOD::BTagVertexContainer> h_BTagJFVtxCollectionName; - - /* Record the BTagging JF Vertex output container */ - if (basename == "JetFitter") { - ATH_MSG_DEBUG("#BTAG# Record the BTagging JF Vertex output container"); - h_BTagJFVtxCollectionName = SG::WriteHandle<xAOD::BTagVertexContainer>(m_BTagJFVtxCollectionName); - ATH_CHECK( h_BTagJFVtxCollectionName.record(std::make_unique<xAOD::BTagVertexContainer>(), - std::make_unique<xAOD::BTagVertexAuxContainer>()) ); - } - - /* Record the BTagging Secondary Vertex output container */ - if ((basename == "SV1") || (basename == "MSV")) { - ATH_MSG_DEBUG("#BTAG# Record the BTagging Secondary Vertex output container"); - h_BTagSVCollectionName = SG::WriteHandle<xAOD::VertexContainer>(m_BTagSVCollectionName); - ATH_CHECK( h_BTagSVCollectionName.record(std::make_unique<xAOD::VertexContainer>(), - std::make_unique<xAOD::VertexAuxContainer>()) ); - } Trk::VxSecVertexInfoContainer::const_iterator infoSVIter = h_VxSecVertexInfoName->begin(); for (xAOD::JetContainer::const_iterator jetIter = h_JetCollectionName->begin(); jetIter != h_JetCollectionName->end(); ++jetIter, ++infoSVIter) { diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetSecVtxFindingAlg.cxx b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetSecVtxFindingAlg.cxx index 2156aa32e257b6497069fd4f909a6b3554187805..7f1ac927e0ec7978ff905cc9e3f36558fc827251 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetSecVtxFindingAlg.cxx +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/src/JetSecVtxFindingAlg.cxx @@ -58,6 +58,15 @@ namespace Analysis { return StatusCode::FAILURE; } + /* Record the VxSecVertexInfo output container */ + SG::WriteHandle<Trk::VxSecVertexInfoContainer> h_VxSecVertexInfoName (m_VxSecVertexInfoName); + ATH_CHECK( h_VxSecVertexInfoName.record(std::make_unique<Trk::VxSecVertexInfoContainer>())); + + if (h_JetCollectionName->size() == 0) { + ATH_MSG_DEBUG("#BTAG# Empty Jet collection"); + return StatusCode::SUCCESS; + } + SG::ReadDecorHandle<xAOD::JetContainer, std::vector<ElementLink< xAOD::TrackParticleContainer> > > h_jetParticleLinkName (m_jetParticleLinkName); if (!h_jetParticleLinkName.isAvailable()) { ATH_MSG_ERROR( " cannot retrieve jet container particle EL decoration with key " << m_jetParticleLinkName.key() ); @@ -96,10 +105,6 @@ namespace Analysis { const xAOD::Vertex& PrimaryVtx = *primaryVertex; - /* Record the VxSecVertexInfo output container */ - SG::WriteHandle<Trk::VxSecVertexInfoContainer> h_VxSecVertexInfoName (m_VxSecVertexInfoName); - ATH_CHECK( h_VxSecVertexInfoName.record(std::make_unique<Trk::VxSecVertexInfoContainer>())); - for (xAOD::JetContainer::const_iterator jetIter = h_JetCollectionName->begin(); jetIter != h_JetCollectionName->end(); ++jetIter) { const xAOD::Jet& jetToTag = **jetIter;