ATLAS Offline Software
Tracking
TrkEventCnv
TrkTruthTPCnv
src
PRD_MultiTruthCollectionCnv_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 PRD_MultiTruthCollection.
6
// Andrei Gaponenko <agaponenko@lbl.gov>, 2007
7
8
#include "
TrkTruthTPCnv/PRD_MultiTruthCollectionCnv_p1.h
"
9
10
#include "
TrkTruthTPCnv/PRD_MultiTruthCollection_p1.h
"
11
#include "
TrkTruthData/PRD_MultiTruthCollection.h
"
12
13
#include "
GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p1.h
"
14
15
16
namespace
{
17
const
HepMcParticleLinkCnv_p1
particleLinkConverter;
18
}
19
20
21
22
void
PRD_MultiTruthCollectionCnv_p1::persToTrans
(
const
Trk::PRD_MultiTruthCollection_p1
* pers,
23
PRD_MultiTruthCollection
* trans,
24
MsgStream&
msg
)
25
{
26
msg
<<
MSG::DEBUG
<<
"PRD_MultiTruthCollectionCnv_p1::persToTrans()"
<<
endmsg
;
27
28
for
(
const
Trk::PRD_MultiTruthCollection_p1::Entry
& ent : pers->
m_entries
) {
29
HepMcParticleLink
link;
30
particleLinkConverter.persToTrans(&ent.
particle
, &link,
msg
);
31
32
if
(!
m_isInitialized
) {
33
if
(this->
initialize
(msg) != StatusCode::SUCCESS) {
34
msg
<<
MSG::FATAL
<<
"Could not initialize PRD_MultiTruthCollectionCnv_p1 "
<<
endmsg
;
35
}
36
}
37
38
Identifier
chanId;
39
if
(
m_pixId
->
is_shortened_pixel_id
(ent.
id
)) {
40
chanId =
m_pixId
->
pixel_id_from_shortened
(ent.
id
);
41
}
42
else
{
43
chanId = ent.
id
;
44
}
45
trans->insert(trans->end(), std::make_pair(chanId, link) );
46
}
47
48
msg
<<
MSG::DEBUG
<<
"PRD_MultiTruthCollectionCnv_p1::persToTrans() DONE"
<<
endmsg
;
49
}
50
51
void
PRD_MultiTruthCollectionCnv_p1::transToPers
(
const
PRD_MultiTruthCollection
* trans,
52
Trk::PRD_MultiTruthCollection_p1
* pers,
53
MsgStream&
msg
)
54
{
55
msg
<<
MSG::DEBUG
<<
"PRD_MultiTruthCollectionCnv_p1::transToPers()"
<<
endmsg
;
56
57
pers->
m_entries
.reserve(trans->size());
58
59
for
(
const
auto
&
p
: *trans) {
60
HepMcParticleLink_p1
link;
61
particleLinkConverter.transToPers(&
p
.second, &link,
msg
);
62
pers->
m_entries
.push_back(
Trk::PRD_MultiTruthCollection_p1::Entry
(
p
.first.get_compact(), link));
63
}
64
65
msg
<<
MSG::DEBUG
<<
"PRD_MultiTruthCollectionCnv_p1::transToPers() DONE"
<<
endmsg
;
66
}
67
68
StatusCode
PRD_MultiTruthCollectionCnv_p1::initialize
(MsgStream &
log
) {
69
// Do not initialize again:
70
m_isInitialized
=
true
;
71
72
// Get Storegate, ID helpers, and so on
73
ISvcLocator* svcLocator = Gaudi::svcLocator();
74
// get StoreGate service
75
StatusCode
sc
= svcLocator->service(
"StoreGateSvc"
,
m_storeGate
);
76
if
(
sc
.isFailure()) {
77
log
<<
MSG::FATAL
<<
"StoreGate service not found !"
<<
endmsg
;
78
return
StatusCode::FAILURE;
79
}
80
81
// get DetectorStore service
82
StoreGateSvc
*
detStore
;
83
sc
= svcLocator->service(
"DetectorStore"
,
detStore
);
84
if
(
sc
.isFailure()) {
85
log
<<
MSG::FATAL
<<
"DetectorStore service not found !"
<<
endmsg
;
86
return
StatusCode::FAILURE;
87
}
88
// else {
89
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Found DetectorStore." << endmsg;
90
// }
91
92
// Get the sct helper from the detector store
93
sc
=
detStore
->retrieve(
m_pixId
,
"PixelID"
);
94
if
(
sc
.isFailure()) {
95
log
<<
MSG::FATAL
<<
"Could not get PixelID helper !"
<<
endmsg
;
96
return
StatusCode::FAILURE;
97
}
98
99
100
// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Converter initialized." << endmsg;
101
return
StatusCode::SUCCESS;
102
}
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:51
python.PerfMonSerializer.p
def p
Definition:
PerfMonSerializer.py:743
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:22
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
AthenaPoolTestRead.sc
sc
Definition:
AthenaPoolTestRead.py:27
PRD_MultiTruthCollectionCnv_p1::m_storeGate
StoreGateSvc * m_storeGate
Definition:
PRD_MultiTruthCollectionCnv_p1.h:48
PRD_MultiTruthCollectionCnv_p1::m_isInitialized
bool m_isInitialized
Definition:
PRD_MultiTruthCollectionCnv_p1.h:49
HepMcParticleLink
a link optimized in size for a GenParticle in a McEventCollection
Definition:
HepMcParticleLink.h:71
StoreGateSvc
The Athena Transient Store API.
Definition:
StoreGateSvc.h:128
Identifier
Definition:
DetectorDescription/Identifier/Identifier/Identifier.h:32
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
python.PyKernel.detStore
detStore
Definition:
PyKernel.py:41
HepMcParticleLink_p1
Definition:
HepMcParticleLink_p1.h:21
HepMcParticleLinkCnv_p1.h
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
python.CaloCondTools.log
log
Definition:
CaloCondTools.py:20
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:68
Generated on Tue Jul 2 2024 21:24:45 for ATLAS Offline Software by
1.8.18