ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
EventCommonTPCnv
src
INav4MomAssocsCnv_p1.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// INav4MomAssocsCnv_p1.cxx
8
// Implementation file for class INav4MomAssocsCnv_p1
9
// Author: S.Binet<binet@cern.ch>
11
12
13
// STL includes
14
15
// Framework includes
16
#include "GaudiKernel/MsgStream.h"
17
#include "
StoreGate/StoreGateSvc.h
"
18
19
// NavFourMom includes
20
#include "
NavFourMom/INav4MomAssocs.h
"
21
22
// EventCommonTPCnv includes
23
#include "
EventCommonTPCnv/INav4MomAssocsCnv_p1.h
"
24
25
26
void
27
INav4MomAssocsCnv_p1::persToTrans
(
const
INav4MomAssocs_p1
* persObj,
28
INav4MomAssocs
* transObj,
29
MsgStream &log )
const
30
{
31
*transObj =
INav4MomAssocs
();
32
33
log << MSG::DEBUG
34
<<
"Loading INav4MomAssocs from persistent state..."
35
<<
endmsg
;
36
if
( 0 ==
m_storeGate
) {
37
log << MSG::ERROR
38
<<
"NULL pointer to StoreGateSvc !!"
<<
endmsg
39
<<
"Cannot do anything !!"
<<
endmsg
;
40
throw
std::runtime_error(
"NULL pointer to StoreGateSvc !!"
);
41
}
42
43
// retrieve underlying association stores
44
for
( std::vector<std::string>::const_iterator itr = persObj->
m_assocStores
.begin();
45
itr != persObj->
m_assocStores
.end();
46
++itr ) {
47
DataLink<INav4MomAssocs>
link( *itr );
48
if
( !link.isValid() ) {
49
log << MSG::WARNING
50
<<
"Could not build DataLink<INav4MomAssocs> from ["
51
<< *itr
52
<<
"] !!"
53
<<
endmsg
;
54
}
else
{
55
transObj->
addAssocStore
(link);
56
}
57
}
58
59
std::map<std::string,const INavigable4MomentumCollection*> collections;
60
61
for
( INav4MomAssocs_p1::ElemLinkVect_t::const_iterator asso = persObj->
m_assocs
.begin();
62
asso != persObj->
m_assocs
.end();
63
++asso ) {
64
65
const
std::pair<std::string,unsigned int>& objLink = asso->first;
66
const
std::pair<std::string,unsigned int>& assLink = asso->second;
67
68
const
std::string& objKey = objLink.first;
69
const
std::string& assKey = assLink.first;
70
71
log << MSG::DEBUG <<
"\tobjLink="
<< objKey <<
", "
<< objLink.second <<
endmsg
;
72
log << MSG::DEBUG <<
"\tassLink="
<< assKey <<
", "
<< assLink.second <<
endmsg
;
73
74
if
( collections.find(objKey) == collections.end() ) {
75
const
INavigable4MomentumCollection
* coll =
nullptr
;
76
collections[objKey] = 0;
77
if
(
m_storeGate
->retrieve( coll, objKey ).isFailure() ||
78
nullptr
== coll ) {
79
log << MSG::ERROR
80
<<
"Could not retrieve INavigable4MomentumCollection at : "
81
<< objKey
82
<<
endmsg
;
83
throw
std::runtime_error(
"Could not retrieve an INavigable4MomentumCollection"
);
84
}
else
{
85
log << MSG::DEBUG
86
<<
"Successfully retrieve INav4MomCollection at : "
87
<< objKey
88
<<
endmsg
;
89
}
90
collections[objKey] = coll;
91
}
92
93
if
( collections.find(assKey) == collections.end() ) {
94
const
INavigable4MomentumCollection
* coll =
nullptr
;
95
if
(
m_storeGate
->retrieve( coll, assKey ).isFailure() ||
96
nullptr
== coll ) {
97
log << MSG::ERROR
98
<<
"Could not retrieve INavigable4MomentumCollection at : "
99
<< assKey
100
<<
endmsg
;
101
throw
std::runtime_error(
"Could not retrieve an INavigable4MomentumCollection"
);
102
}
else
{
103
log << MSG::DEBUG
104
<<
"Successfully retrieve INav4MomCollection at : "
105
<< assKey
106
<<
endmsg
;
107
}
108
collections[assKey] = coll;
109
}
110
111
transObj->
addAssociation
( collections[objKey], objLink.second,
112
collections[assKey], assLink.second );
113
114
}
115
116
log << MSG::DEBUG
117
<<
"Loaded INav4MomAssocs from persistent state [OK]"
118
<<
endmsg
;
119
return
;
120
}
121
122
void
123
INav4MomAssocsCnv_p1::transToPers
(
const
INav4MomAssocs
* transObj,
124
INav4MomAssocs_p1
* persObj,
125
MsgStream &log )
const
126
{
127
log << MSG::DEBUG
128
<<
"Creating persistent state of INav4MomAssocs..."
129
<<
endmsg
;
130
131
// first store the underlying association stores
132
for
(
const
DataLink<INav4MomAssocs>
& l : transObj->
getAssocStores
()) {
133
persObj->
m_assocStores
.push_back( l.dataID() );
134
}
135
136
INav4MomAssocs::object_iterator
begObj = transObj->
beginObject
();
137
INav4MomAssocs::object_iterator
endObj = transObj->
endObject
();
138
for
(; begObj != endObj; ++begObj)
139
{
140
const
INav4MomAssocs::object_link
& key = begObj.getObjectLink();
141
INav4MomAssocs_p1::Elem_t
keyElem (key.dataID(), key.index());
142
INav4MomAssocs::asso_iterator
begAsso = begObj.getFirstAssociation();
143
INav4MomAssocs::asso_iterator
endAsso = begObj.getLastAssociation();
144
for
(; begAsso != endAsso; ++begAsso) {
145
const
INav4MomAssocs::asso_link
asso = begAsso.getLink();
146
INav4MomAssocs_p1::Elem_t
assoElem (asso.
dataID
(), asso.
index
());
147
const
INav4MomAssocs_p1::ElemLink_t
association( keyElem, assoElem );
148
persObj->
m_assocs
.emplace_back( keyElem, assoElem );
149
}
150
}
151
152
log << MSG::DEBUG
153
<<
"Created persistent state of INav4MomAssocs [OK]"
154
<<
endmsg
;
155
return
;
156
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
INav4MomAssocs
INav4MomAssocs
Definition
EventCommonTPCnv.cxx:32
INav4MomAssocsCnv_p1.h
INav4MomAssocs.h
INavigable4MomentumCollection
DataVector< INavigable4Momentum > INavigable4MomentumCollection
Definition
INavigable4MomentumCollection.h:22
StoreGateSvc.h
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::object_iterator
AssociationObjectIterator object_iterator
Definition
AssociationMap.h:84
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::asso_link
ElementLink< asso_container_type > asso_link
Definition
AssociationMap.h:60
AssociationMap::endObject
object_iterator endObject() const
end iterator for objects
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::asso_iterator
AssociationVectorIterator asso_iterator
Definition
AssociationMap.h:81
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::object_link
ElementLink< object_container_type > object_link
Definition
AssociationMap.h:50
AssociationMap::addAssociation
void addAssociation(const object_container_type *objectContainer, const object_index_type &objectIndex, const asso_container_type *assoContainer, const asso_index_type &assoIndex)
AssociationMap::beginObject
object_iterator beginObject() const
begin iterator for objects
DataLink
Object reference supporting deferred reading from StoreGate.
Definition
AthLinks/DataLink.h:93
ElementLink::dataID
const ID_type & dataID() const
Get the key that we reference, as a string.
ElementLink::index
index_type index() const
Get the index of the element inside of its container.
Definition
A/AthLinks/ElementLink.h:164
INav4MomAssocsCnv_p1::transToPers
virtual void transToPers(const INav4MomAssocs *transObj, INav4MomAssocs_p1 *persObj, MsgStream &log) const override
Method creating the persistent representation INav4MomAssocs_p1 from its transient representation INa...
Definition
INav4MomAssocsCnv_p1.cxx:123
INav4MomAssocsCnv_p1::m_storeGate
StoreGateSvc * m_storeGate
Pointer to the StoreGateSvc: we need this as we'll have to fetch the INav4MomAssocs which is the pare...
Definition
INav4MomAssocsCnv_p1.h:76
INav4MomAssocsCnv_p1::persToTrans
virtual void persToTrans(const INav4MomAssocs_p1 *persObj, INav4MomAssocs *transObj, MsgStream &log) const override
Method creating the transient representation of INav4MomAssocs from its persistent representation INa...
Definition
INav4MomAssocsCnv_p1.cxx:27
INav4MomAssocs_p1
Definition
INav4MomAssocs_p1.h:24
INav4MomAssocs_p1::ElemLink_t
std::pair< Elem_t, Elem_t > ElemLink_t
Definition
INav4MomAssocs_p1.h:39
INav4MomAssocs_p1::m_assocs
ElemLinkVect_t m_assocs
Definition
INav4MomAssocs_p1.h:70
INav4MomAssocs_p1::m_assocStores
INav4MomStores_t m_assocStores
Definition
INav4MomAssocs_p1.h:71
INav4MomAssocs_p1::Elem_t
std::pair< std::string, unsigned int > Elem_t
Definition
INav4MomAssocs_p1.h:38
INav4MomAssocs
Definition
INav4MomAssocs.h:33
INav4MomAssocs::addAssocStore
void addAssocStore(const DataLink< INav4MomAssocs > &assocStore)
Retrieve all the associated-to objects which have been associated to the given.
Definition
INav4MomAssocs.cxx:161
INav4MomAssocs::getAssocStores
std::vector< DataLink< INav4MomAssocs > > getAssocStores() const
Return links to all other association stores.
Definition
INav4MomAssocs.cxx:171
Generated on
for ATLAS Offline Software by
1.17.0