ATLAS Offline Software
Loading...
Searching...
No Matches
PRD_MultiTruthCollectionCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// T/P converter for PRD_MultiTruthCollection.
6// Andrei Gaponenko <agaponenko@lbl.gov>, 2007
7
9
12
15
16
17namespace {
18 const HepMcParticleLinkCnv_p1 particleLinkConverter;
19}
20
21
22
25 MsgStream& msg )
26{
27 msg<<MSG::DEBUG<<"PRD_MultiTruthCollectionCnv_p1::persToTrans()"<<endmsg;
28
29 for (const Trk::PRD_MultiTruthCollection_p1::Entry& ent : pers->m_entries) {
31 particleLinkConverter.persToTrans(&ent.particle, &link, msg);
32
33 if(!m_isInitialized) {
34 if (this->initialize(msg) != StatusCode::SUCCESS) {
35 msg << MSG::FATAL << "Could not initialize PRD_MultiTruthCollectionCnv_p1 " << endmsg;
36 }
37 }
38
39 Identifier chanId;
40 if (m_pixId->is_shortened_pixel_id(ent.id)) {
41 chanId = m_pixId->pixel_id_from_shortened(ent.id);
42 }
43 else {
44 chanId = ent.id;
45 }
46 trans->insert(trans->end(), std::make_pair(chanId, link) );
47 }
48
49 msg<<MSG::DEBUG<<"PRD_MultiTruthCollectionCnv_p1::persToTrans() DONE"<<endmsg;
50}
51
54 MsgStream& msg )
55{
56 msg<<MSG::DEBUG<<"PRD_MultiTruthCollectionCnv_p1::transToPers()"<<endmsg;
57
58 pers->m_entries.reserve(trans->size());
59
60 for (const auto& p : *trans) {
62 particleLinkConverter.transToPers(&p.second, &link, msg);
63 pers->m_entries.push_back(Trk::PRD_MultiTruthCollection_p1::Entry(p.first.get_compact(), link));
64 }
65
66 msg<<MSG::DEBUG<<"PRD_MultiTruthCollectionCnv_p1::transToPers() DONE"<<endmsg;
67}
68
69StatusCode PRD_MultiTruthCollectionCnv_p1::initialize(MsgStream &/*log*/) {
70 // Do not initialize again:
71 m_isInitialized=true;
72
73 SmartIF<StoreGateSvc> detStore(Gaudi::svcLocator()->service("DetectorStore"));
74 CHECK( detStore.isValid() );
75
76 // Get the sct helper from the detector store
77 CHECK( detStore->retrieve(m_pixId, "PixelID") );
78
79 return StatusCode::SUCCESS;
80}
#define endmsg
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
virtual void transToPers(const PRD_MultiTruthCollection *transObj, Trk::PRD_MultiTruthCollection_p1 *persObj, MsgStream &msg)
Method creating the persistent representation PRD_MultiTruthCollection_p1 from its transient represen...
virtual void persToTrans(const Trk::PRD_MultiTruthCollection_p1 *persObj, PRD_MultiTruthCollection *transObj, MsgStream &msg)
A PRD is mapped onto all contributing particles.
void initialize()
MsgStream & msg
Definition testRead.cxx:32