ATLAS Offline Software
TrackTruthCollectionCnv_p2.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 // Olivier Arnaez <olivier.arnaez@cern.ch>, 2015
8 
10 
13 
16 
17 #include "StoreGate/StoreGateSvc.h"
18 
20 
21 namespace {
22  const HepMcParticleLinkCnv_p2 particleLinkConverter;
23  const DataLinkCnv_p1<DataLink<TrackCollection> > dataLinkConverter;
24 }
25 
27  TrackTruthCollection* trans,
28  MsgStream& msg )
29 {
30  msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p2::persToTrans(): PERS size = "<<pers->m_entries.size()<<endmsg;
31 
32  dataLinkConverter.persToTrans(pers->m_trackCollectionLink, TrackTruthCollectionAccessor::trackCollectionLink(trans), msg);
33 
34  for(Trk::TrackTruthCollection_p2::CollectionType::const_iterator i=pers->m_entries.begin(); i!=pers->m_entries.end(); ++i) {
35  HepMcParticleLink link;
36  particleLinkConverter.persToTrans(&i->particle, &link, msg);
37  trans->insert(trans->end(), std::make_pair(i->index, TrackTruth(link, i->probability, 0)) );
38  }
39 
40  msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p2::persToTrans() DONE"<<endmsg;
41 }
42 
45  MsgStream& msg )
46 {
47  msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p2::transToPers()"<<endmsg;
48  msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p2::transToPers(): input size = "<<trans->size()<<endmsg;
49 
50  dataLinkConverter.transToPers(trans->trackCollectionLink(), pers->m_trackCollectionLink, msg);
51 
52  pers->m_entries.resize(trans->size());
53  Trk::TrackTruthCollection_p2::CollectionType::size_type ipers(0);
54  for(TrackTruthCollection::const_iterator itrans=trans->begin(); itrans!=trans->end(); ++itrans, ++ipers) {
56  const TrackTruth& truth = itrans->second;
57  current.index = itrans->first.index(); // extract index from ElementLink
58  current.probability = truth.probability();
59  particleLinkConverter.transToPers(&itrans->second.particleLink(), &current.particle, msg);
60  }
61 
62  msg<<MSG::DEBUG<<"TrackTruthCollectionCnv_p2::transToPers() DONE"<<endmsg;
63 }
TrackTruthCollectionCnv_p2::persToTrans
virtual void persToTrans(const Trk::TrackTruthCollection_p2 *persObj, TrackTruthCollection *transObj, MsgStream &msg)
Method creating the transient representation of Analysis::TrackTruthCollection from its persistent re...
Definition: TrackTruthCollectionCnv_p2.cxx:26
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
Trk::TrackTruthCollection_p2::m_entries
CollectionType m_entries
Definition: TrackTruthCollection_p2.h:39
DataLinkCnv_p1.h
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
TrackTruthCollection
Definition: TrackTruthCollection.h:21
TrackTruthCollection.h
TrackTruthCollectionAccessor::trackCollectionLink
static DataLink< TrackCollection > & trackCollectionLink(TrackTruthCollection *truthColl)
Definition: TrackTruthCollectionAccessor.h:21
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TrackTruthCollectionCnv_p2.h
Trk::TrackTruthCollection_p2::Entry
Definition: TrackTruthCollection_p2.h:29
TrackTruthCollection_p2.h
Trk::TrackTruthCollection_p2
Definition: TrackTruthCollection_p2.h:21
TrackTruthCollectionCnv_p2::transToPers
virtual void transToPers(const TrackTruthCollection *transObj, Trk::TrackTruthCollection_p2 *persObj, MsgStream &msg)
Method creating the persistent representation TrackTruthCollection_p2 from its transient representati...
Definition: TrackTruthCollectionCnv_p2.cxx:43
TrackTruth
MC particle associated with a reco track + the quality of match.
Definition: TrackTruth.h:14
HepMcParticleLinkCnv_p2.h
TrackTruthCollectionAccessor.h
TrackTruth::probability
float probability() const
Definition: TrackTruth.h:28
DEBUG
#define DEBUG
Definition: page_access.h:11
HepMcParticleLinkCnv_p2
Definition: HepMcParticleLinkCnv_p2.h:29
StoreGateSvc.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TrackTruthCollection::trackCollectionLink
DataLink< TrackCollection > trackCollectionLink() const
Definition: TrackTruthCollection.h:27
DataLinkCnv_p1
Definition: DataLinkCnv_p1.h:23
Trk::TrackTruthCollection_p2::m_trackCollectionLink
DataLink_p1 m_trackCollectionLink
Definition: TrackTruthCollection_p2.h:24