diff --git a/Event/LinkerEvent/src/LinksByKey.cpp b/Event/LinkerEvent/src/LinksByKey.cpp index 814d430412341fd7718eef1892283d9e6c73900c..92d2a7f868676c4c8f0ed64a9e0a389a2ce5217b 100755 --- a/Event/LinkerEvent/src/LinksByKey.cpp +++ b/Event/LinkerEvent/src/LinksByKey.cpp @@ -145,7 +145,7 @@ bool LHCb::LinksByKey::firstReference( int key, const DataObject* container, LHC linkID = link->ID(); } - int index; + int index{0}; if ( findIndex( key, index ) ) { reference = m_linkReference[m_keyIndex[index].second]; if ( 0 <= linkID ) { diff --git a/Sim/SimComponents/src/MCReconstructible.h b/Sim/SimComponents/src/MCReconstructible.h index 92ee7399b73151a017d0d633a238ff1b54b71a23..70d356f197f60492f78c78a1fd28b48aef536787 100644 --- a/Sim/SimComponents/src/MCReconstructible.h +++ b/Sim/SimComponents/src/MCReconstructible.h @@ -87,10 +87,10 @@ private: // methods /// get the MCTrackInfo object inline MCTrackInfo& mcTkInfo() const { - if ( UNLIKELY( !m_tkInfo ) ) { - m_tkInfo = std::make_unique<MCTrackInfo>( evtSvc(), msgSvc() ); - if ( !m_tkInfo ) { Exception( "Failed to load MCTrackInfo" ); } - } + auto cEvt = Gaudi::Hive::currentContext().evt(); + if (currentEvtContextID == cEvt && m_tkInfo) return *m_tkInfo; + currentEvtContextID = cEvt; + m_tkInfo = std::make_unique<MCTrackInfo>( evtSvc(), msgSvc() ); return *m_tkInfo; } @@ -111,6 +111,7 @@ private: // data /// Pointer to MCTrackInfo object mutable std::unique_ptr<MCTrackInfo> m_tkInfo; + mutable uint64_t currentEvtContextID{0}; /// MCParticle selector IMCParticleSelector* m_mcSel = nullptr;