2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 /** @file ElementLinkCnv_p3.icc
6 * @brief This file contains the implementation for the ElementLinkCnv_p3 template methods.
7 * @author Marcin.Nowak@cern.ch
12 #include "AthLinks/ElementLink.h"
13 #include "AthenaKernel/ThinningCache.h"
14 #include "AthenaKernel/ThinningDecisionBase.h"
15 #include "AthenaKernel/getThinningCache.h"
16 //#define ELLINK_DEBUG
19 template <typename LINK_TYPE>
20 void ElementLinkCnv_p3<LINK_TYPE>::
21 transToPers(const Link_t& trans, PersLink_t& pers,
22 const SG::ThinningCache* cache,
23 [[maybe_unused]] MsgStream& msg ) const
25 if( !trans.isDefault() ) {
26 // Check for thinning.
28 const SG::ThinningDecisionBase* dec = cache->thinning (trans.key());
30 // here is the problem: in case the ElementLink was directly created w/
31 // only a pointer to the element, _and_ if the the pointed at element
32 // has been thinned away, EL::index() will throw b/c
33 // IndexingPolicy::setIndex will fail.
34 std::size_t idx = SG::ThinningDecisionBase::RemovedIdx;
37 } catch ( const SG::maybe_thinning_error& err ) {
38 // ok. that's the corner case we talked about above.
40 msg << MSG::DEBUG << "caught a maybe_thinning_error: ["
43 << "(this is an expected case of the EL-state-phase-space "
44 << "when thinning is active)"
49 // Get the updated index:
50 const std::size_t persIdx = dec->index( idx );
51 if (SG::ThinningDecisionBase::RemovedIdx == persIdx)
58 pers.m_SGKeyHash = tmp.key();
59 pers.m_elementIndex = persIdx;
62 msg << MSG::INFO << "ElementLinkCnv_p3::transToPer(): SG Container="
63 << ", Key Hash=" << pers.m_SGKeyHash
64 << ", IDX=" << pers.m_elementIndex << endmsg;
73 pers.m_SGKeyHash = tmp.key();
74 pers.m_elementIndex = tmp.index();
76 msg << MSG::INFO << "ElementLinkCnv_p3::transToPer(): SG Container="
77 << ", Key Hash=" << pers.m_SGKeyHash
78 << ", IDX=" << pers.m_elementIndex << endmsg;
84 template <typename LINK_TYPE>
85 void ElementLinkCnv_p3<LINK_TYPE>::
86 transToPers(const Link_t& trans, PersLink_t& pers,
87 MsgStream& msg ) const
89 transToPers (trans, pers,
90 SG::getThinningCache(),
95 template <typename LINK_TYPE >
96 void ElementLinkCnv_p3< LINK_TYPE >
97 ::persToTrans(const PersLink_t& pers, Link_t& trans,
98 [[maybe_unused]] MsgStream& msg) const
100 if( pers.m_SGKeyHash != 0 ) {
102 msg << MSG::DEBUG << "ElementLinkCnv_p3::PersToTrans(): SGContainer hash="
103 << pers.m_SGKeyHash << ", IDX=" << pers.m_elementIndex << endmsg;
105 trans = Link_t( (typename Link_t::sgkey_t)pers.m_SGKeyHash, pers.m_elementIndex);
109 msg << MSG::DEBUG << "ElementLinkCnv_p3::PersToTrans(): reading EL in Default state" << endmsg;
111 // set the transient ELink to the default state.
117 template <typename LINK_TYPE>
118 void ElementLinkCnv_p3<LINK_TYPE>::
119 transToPers(const Link_t* trans, PersLink_t* pers, MsgStream& msg ) const
121 return transToPers (*trans, *pers, msg);
125 template <typename LINK_TYPE >
126 void ElementLinkCnv_p3< LINK_TYPE >
127 ::persToTrans(const PersLink_t* pers, Link_t* trans, MsgStream& msg) const
129 return persToTrans (*pers, *trans, msg);