ATLAS Offline Software
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 
17 namespace {
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) {
30  HepMcParticleLink link;
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 
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 }
PRD_MultiTruthCollectionCnv_p1::transToPers
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...
Definition: PRD_MultiTruthCollectionCnv_p1.cxx:52
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
PRD_MultiTruthCollection
A PRD is mapped onto all contributing particles.
Definition: PRD_MultiTruthCollection.h:24
PRD_MultiTruthCollectionCnv_p1::persToTrans
virtual void persToTrans(const Trk::PRD_MultiTruthCollection_p1 *persObj, PRD_MultiTruthCollection *transObj, MsgStream &msg)
Definition: PRD_MultiTruthCollectionCnv_p1.cxx:23
PRD_MultiTruthCollection_p1.h
PixelID::is_shortened_pixel_id
bool is_shortened_pixel_id(Identifier32::value_type val) const
Test if this is a valid shortened pixel channel id.
Definition: PixelID.h:516
PRD_MultiTruthCollectionCnv_p1::m_isInitialized
bool m_isInitialized
Definition: PRD_MultiTruthCollectionCnv_p1.h:48
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PRD_MultiTruthCollectionCnv_p1::m_pixId
const PixelID * m_pixId
Definition: PRD_MultiTruthCollectionCnv_p1.h:47
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
HepMcParticleLinkCnv_p1.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
HepMcParticleLinkCnv_p1
Definition: HepMcParticleLinkCnv_p1.h:33
Trk::PRD_MultiTruthCollection_p1::m_entries
CollectionType m_entries
Definition: PRD_MultiTruthCollection_p1.h:43
Trk::PRD_MultiTruthCollection_p1::Entry
Definition: PRD_MultiTruthCollection_p1.h:25
PRD_MultiTruthCollectionCnv_p1.h
DEBUG
#define DEBUG
Definition: page_access.h:11
Trk::PRD_MultiTruthCollection_p1::Entry::id
unsigned int id
Definition: PRD_MultiTruthCollection_p1.h:35
PRD_MultiTruthCollection.h
Trk::PRD_MultiTruthCollection_p1::Entry::particle
HepMcParticleLink_p1 particle
Definition: PRD_MultiTruthCollection_p1.h:36
Trk::PRD_MultiTruthCollection_p1
Definition: PRD_MultiTruthCollection_p1.h:22
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
PixelID::pixel_id_from_shortened
Identifier pixel_id_from_shortened(Identifier32::value_type val) const
Create a compact pixel id from a (fixed format) legacy pixel channel id.
Definition: PixelID.h:546
PRD_MultiTruthCollectionCnv_p1::initialize
StatusCode initialize(MsgStream &log)
Definition: PRD_MultiTruthCollectionCnv_p1.cxx:69
Identifier
Definition: IdentifierFieldParser.cxx:14