ATLAS Offline Software
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 
16 #include "StoreGate/StoreGateSvc.h"
17 
19 
20 namespace {
21  const HepMcParticleLinkCnv_p1 particleLinkConverter;
22  const DataLinkCnv_p1<DataLink<TrackCollection> > dataLinkConverter;
23 }
24 
26  TrackTruthCollection* trans,
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) {
34  HepMcParticleLink link;
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) {
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 }
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
DataLinkCnv_p1.h
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
TrackTruthCollectionCnv_p1::persToTrans
virtual void persToTrans(const Trk::TrackTruthCollection_p1 *persObj, TrackTruthCollection *transObj, MsgStream &msg)
Method creating the transient representation of Analysis::TrackTruthCollection from its persistent re...
Definition: TrackTruthCollectionCnv_p1.cxx:25
Trk::TrackTruthCollection_p1::m_entries
CollectionType m_entries
Definition: TrackTruthCollection_p1.h:39
TrackTruthCollection
Definition: TrackTruthCollection.h:21
Trk::TrackTruthCollection_p1
Definition: TrackTruthCollection_p1.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
TrackTruthCollection_p1.h
Trk::TrackTruthCollection_p1::Entry
Definition: TrackTruthCollection_p1.h:29
HepMcParticleLinkCnv_p1.h
TrackTruthCollectionCnv_p1::transToPers
virtual void transToPers(const TrackTruthCollection *transObj, Trk::TrackTruthCollection_p1 *persObj, MsgStream &msg)
Method creating the persistent representation TrackTruthCollection_p1 from its transient representati...
Definition: TrackTruthCollectionCnv_p1.cxx:42
HepMcParticleLinkCnv_p1
Definition: HepMcParticleLinkCnv_p1.h:33
TrackTruth
MC particle associated with a reco track + the quality of match.
Definition: TrackTruth.h:14
TrackTruthCollectionCnv_p1.h
TrackTruthCollectionAccessor.h
TrackTruth::probability
float probability() const
Definition: TrackTruth.h:28
DEBUG
#define DEBUG
Definition: page_access.h:11
Trk::TrackTruthCollection_p1::m_trackCollectionLink
DataLink_p1 m_trackCollectionLink
Definition: TrackTruthCollection_p1.h:24
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