ATLAS Offline Software
TrackParticleTruthCollectionCnv_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 
7 
9 
13 
14 #include "StoreGate/StoreGateSvc.h"
15 
17 
18 namespace {
19  const HepMcParticleLinkCnv_p2 particleLinkConverter;
21 }
22 
24 
27  MsgStream& msg ) const
28 {
29  trans->clear();
30 
31  if (msg.level() <= MSG::DEBUG) msg << MSG::DEBUG << "TrackParticleTruthCollectionCnv_p2::persToTrans(): PERS size = " << pers->m_entries.size() << endmsg;
32 
34 
35  for(Rec::TrackParticleTruthCollection_p2::CollectionType::const_iterator i=pers->m_entries.begin(); i!=pers->m_entries.end(); ++i) {
36  HepMcParticleLink link;
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_p2::persToTrans() DONE" << endmsg;
44 }
45 
48  MsgStream& msg ) const
49 {
50  if (msg.level() <= MSG::DEBUG) {
51  msg << MSG::DEBUG << "TrackParticleTruthCollectionCnv_p2::transToPers()" << endmsg;
52  msg << MSG::DEBUG << "TrackParticleTruthCollectionCnv_p2::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_p2::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
68  ElementLinkInt_p3 el_p;
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_p2::transToPers() DONE" << endmsg;
80 }
ElementLinkCnv_p3
Definition: ElementLinkCnv_p3.h:27
ElementLinkCnv_p3.h
This file contains the class definition for the ElementLinkCnv_p3 class.
Rec::TrackParticleTruthCollection_p2
Definition: TrackParticleTruthCollection_p2.h:16
DataLinkCnv_p1.h
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
Rec::TrackParticleTruthCollection_p2::m_trackCollectionLink
DataLink_p1 m_trackCollectionLink
Definition: TrackParticleTruthCollection_p2.h:19
TrackParticleTruthCollection.h
TrackParticleTruth::probability
float probability() const
Definition: TrackParticleTruth.h:36
TrackParticleTruthCollection::trackParticleContainerLink
DataLink< Rec::TrackParticleContainer > trackParticleContainerLink() const
Definition: TrackParticleTruthCollection.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrackParticleTruth
Definition: TrackParticleTruth.h:15
Rec::TrackParticleTruthCollection_p2::Entry
Definition: TrackParticleTruthCollection_p2.h:24
ElementLinkCnv_p1::transToPers
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
TrackParticleTruthCollection_p2.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
TrackLinkCnv_t
ElementLinkCnv_p3< ElementLink< Rec::TrackParticleContainer > > TrackLinkCnv_t
Definition: TrackParticleTruthCollectionCnv_p2.cxx:23
ElementLinkCnv_p1< ElementLink< Rec::TrackParticleContainer > >
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
TrackParticleTruthCollectionAccessor.h
Rec::TrackParticleTruthCollection_p2::m_entries
CollectionType m_entries
Definition: TrackParticleTruthCollection_p2.h:34
HepMcParticleLinkCnv_p2.h
TrackParticleTruthCollectionCnv_p2.h
TrackParticleTruthCollection
Definition: TrackParticleTruthCollection.h:18
DEBUG
#define DEBUG
Definition: page_access.h:11
TrackParticleTruthCollectionCnv_p2::transToPers
virtual void transToPers(const TrackParticleTruthCollection *transObj, Rec::TrackParticleTruthCollection_p2 *persObj, MsgStream &msg) const override
Method creating the persistent representation TrackParticleTruthCollection_p2 from its transient repr...
Definition: TrackParticleTruthCollectionCnv_p2.cxx:46
TrackParticleTruthCollectionCnv_p2::persToTrans
virtual void persToTrans(const Rec::TrackParticleTruthCollection_p2 *persObj, TrackParticleTruthCollection *transObj, MsgStream &msg) const override
Method creating the transient representation of Analysis::TrackParticleTruthCollection from its persi...
Definition: TrackParticleTruthCollectionCnv_p2.cxx:25
TrackParticleTruthCollectionAccessor::trackParticleContainerLink
static DataLink< Rec::TrackParticleContainer > & trackParticleContainerLink(TrackParticleTruthCollection *truthColl)
Definition: TrackParticleTruthCollectionAccessor.h:13
HepMcParticleLinkCnv_p2
Definition: HepMcParticleLinkCnv_p2.h:29
StoreGateSvc.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
DataLinkCnv_p1
Definition: DataLinkCnv_p1.h:23