ATLAS Offline Software
Loading...
Searching...
No Matches
TrackTruthCollectionCnv_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
5// T/P converter for TrackTruthCollection.
6// Andrei Gaponenko <agaponenko@lbl.gov>, 2007
7
9
12
15
17
19
20namespace {
21 const HepMcParticleLinkCnv_p1 particleLinkConverter;
22 const DataLinkCnv_p1<DataLink<TrackCollection> > dataLinkConverter;
23}
24
27 MsgStream& msg )
28{
29 msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p1::persToTrans(): PERS size = "<<pers->m_entries.size()<<endmsg;
30
31 dataLinkConverter.persToTrans(pers->m_trackCollectionLink, TrackTruthCollectionAccessor::trackCollectionLink(trans), msg);
32
33 for(Trk::TrackTruthCollection_p1::CollectionType::const_iterator i=pers->m_entries.begin(); i!=pers->m_entries.end(); ++i) {
35 particleLinkConverter.persToTrans(&i->particle, &link, msg);
36 trans->insert(trans->end(), std::make_pair(i->index, TrackTruth(link, i->probability, 0)) );
37 }
38
39 msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p1::persToTrans() DONE"<<endmsg;
40}
41
44 MsgStream& msg )
45{
46 msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p1::transToPers()"<<endmsg;
47 msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p1::transToPers(): input size = "<<trans->size()<<endmsg;
48
49 dataLinkConverter.transToPers(trans->trackCollectionLink(), pers->m_trackCollectionLink, msg);
50
51 pers->m_entries.resize(trans->size());
52 Trk::TrackTruthCollection_p1::CollectionType::size_type ipers(0);
53 for(TrackTruthCollection::const_iterator itrans=trans->begin(); itrans!=trans->end(); ++itrans, ++ipers) {
54 Trk::TrackTruthCollection_p1::Entry& current = pers->m_entries[ipers];
55 const TrackTruth& truth = itrans->second;
56 current.index = itrans->first.index(); // extract index from ElementLink
57 current.probability = truth.probability();
58 particleLinkConverter.transToPers(&itrans->second.particleLink(), &current.particle, msg);
59 }
60
61 msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p1::transToPers() DONE"<<endmsg;
62}
#define endmsg
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
static DataLink< TrackCollection > & trackCollectionLink(TrackTruthCollection *truthColl)
virtual void persToTrans(const Trk::TrackTruthCollection_p1 *persObj, TrackTruthCollection *transObj, MsgStream &msg)
Method creating the transient representation of Analysis::TrackTruthCollection from its persistent re...
virtual void transToPers(const TrackTruthCollection *transObj, Trk::TrackTruthCollection_p1 *persObj, MsgStream &msg)
Method creating the persistent representation TrackTruthCollection_p1 from its transient representati...
DataLink< TrackCollection > trackCollectionLink() const
MC particle associated with a reco track + the quality of match.
Definition TrackTruth.h:14
float probability() const
Definition TrackTruth.h:28
MsgStream & msg
Definition testRead.cxx:32