ATLAS Offline Software
Loading...
Searching...
No Matches
TrackParticleTruthCollectionCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9
13
15
17
18namespace {
19 const HepMcParticleLinkCnv_p1 particleLinkConverter;
21}
22
24
27 MsgStream& msg ) const
28{
29 trans->clear();
30
31 if (msg.level() <= MSG::DEBUG) msg << MSG::DEBUG << "TrackParticleTruthCollectionCnv_p1::persToTrans(): PERS size = " << pers->m_entries.size() << endmsg;
32
34
35 for(Rec::TrackParticleTruthCollection_p1::CollectionType::const_iterator i=pers->m_entries.begin(); i!=pers->m_entries.end(); ++i) {
37 particleLinkConverter.persToTrans(&i->particle, &link, msg);
38 // Reconstruct EL from the key of the DataLink and the saved index
40 trans->insert(trans->end(), std::make_pair(el, TrackParticleTruth(link, i->probability)) );
41 }
42
43 if (msg.level() <= MSG::DEBUG) msg << MSG::DEBUG << "TrackParticleTruthCollectionCnv_p1::persToTrans() DONE" << endmsg;
44}
45
48 MsgStream& msg ) const
49{
50 if (msg.level() <= MSG::DEBUG) {
51 msg << MSG::DEBUG << "TrackParticleTruthCollectionCnv_p1::transToPers()" << endmsg;
52 msg << MSG::DEBUG << "TrackParticleTruthCollectionCnv_p1::transToPers(): input size = " << trans->size() << endmsg;
53 }
54
55 dataLinkConverter.transToPers(trans->trackParticleContainerLink(), pers->m_trackCollectionLink, msg);
56
57 // For the map of EL keys and HepParticleLinks, we only write out
58 // pairs which were not thinned away. RDS 02/2012
59 pers->m_entries.reserve(trans->size());
60 Rec::TrackParticleTruthCollection_p1::CollectionType::size_type ipers(0);
61 TrackParticleTruthCollection::const_iterator itrans = trans->begin();
62 for( ; itrans!=trans->end(); ++itrans, ++ipers) {
64 const TrackParticleTruth& truth = itrans->second;
65 // We must first convert the element link to check whether or
66 // not it was thinned, then we write it out if it was not
67 // thinned
69 TrackLinkCnv_t elCnv_p;
70 elCnv_p.transToPers(itrans->first.link(), el_p, msg);
71 if (0 != el_p.m_SGKeyHash) {
72 entry.index = el_p.m_elementIndex; // save index from ElementLink
73 entry.probability = truth.probability();
74 particleLinkConverter.transToPers(&itrans->second.particleLink(), &entry.particle, msg);
75 pers->m_entries.push_back(entry);
76 }
77 }
78
79 if (msg.level() <= MSG::DEBUG) msg << MSG::DEBUG << "TrackParticleTruthCollectionCnv_p1::transToPers() DONE" << endmsg;
80}
#define endmsg
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
This file contains the class definition for the ElementLinkCnv_p3 class.
ElementLinkCnv_p1< ElementLink< Rec::TrackParticleContainer > > TrackLinkCnv_t
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
static DataLink< Rec::TrackParticleContainer > & trackParticleContainerLink(TrackParticleTruthCollection *truthColl)
virtual void transToPers(const TrackParticleTruthCollection *transObj, Rec::TrackParticleTruthCollection_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation TrackParticleTruthCollection_p1 from its transient repr...
virtual void persToTrans(const Rec::TrackParticleTruthCollection_p1 *persObj, TrackParticleTruthCollection *transObj, MsgStream &msg) const override
Method creating the transient representation of Analysis::TrackParticleTruthCollection from its persi...
DataLink< Rec::TrackParticleContainer > trackParticleContainerLink() const
float probability() const
MsgStream & msg
Definition testRead.cxx:32