ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
NavFourMom
src
INav4MomAssocs.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// INav4MomAssocs.cxx
7
// Implementation file for class INav4MomAssocs
8
// Author: S.Binet<binet@cern.ch>
10
11
12
// STL includes
13
#include <algorithm>
14
15
// NavFourMom includes
16
#include "
NavFourMom/INav4MomAssocs.h
"
17
#include "
EventKernel/IParticle.h
"
18
#include "
AthContainers/DataVector.h
"
19
21
// Public methods:
23
24
// Constructors/assignment
26
INav4MomAssocs::INav4MomAssocs
() =
default
;
27
INav4MomAssocs::INav4MomAssocs
(
const
INav4MomAssocs
& rhs ) =
default
;
28
INav4MomAssocs::INav4MomAssocs
(
INav4MomAssocs
&& rhs ) =
default
;
29
INav4MomAssocs
&
INav4MomAssocs::operator=
(
const
INav4MomAssocs
& rhs ) =
default
;
30
INav4MomAssocs
&
INav4MomAssocs::operator=
(
INav4MomAssocs
&& rhs ) =
default
;
31
33
// Const methods:
35
36
bool
37
INav4MomAssocs::assocs
(
const
INavigable4Momentum
*
object
,
38
ConstDataVector<INavigable4MomentumCollection>
& associatedElems )
const
39
{
40
if
( 0 ==
object
) {
41
return
false
;
42
}
43
44
// do the underlying stores contain this object ?
45
bool
contained =
false
;
46
for
( std::map<std::string,
DataLink<INav4MomAssocs>
>
::const_iterator
itr =
m_assocStores
.begin();
47
itr !=
m_assocStores
.end();
48
++itr ) {
49
if
( itr->second->assocs(
object
, associatedElems) ) {
50
contained =
true
;
51
}
52
}
53
54
if
( !contained && !
containsObject
(
object
) ) {
55
return
false
;
56
}
57
58
associatedElems.reserve( associatedElems.size() +
59
getNumberOfAssociations
(
object
) );
60
INav4MomAssocs::asso_iterator
endAssocs =
endAssociation
(
object
);
61
for
(
INav4MomAssocs::asso_iterator
itr =
beginAssociation
(
object
);
62
itr != endAssocs;
63
++itr ) {
64
associatedElems.
push_back
(
const_cast<
INavigable4Momentum
*
>
(*itr) );
65
}
66
67
return
true
;
68
}
69
70
71
72
bool
73
INav4MomAssocs::getAssociations
(
const
INav4MomLink
& objectLink,
74
INav4MomLinkContainer
& associatedElementLinks )
const
75
{
76
if
( !objectLink.
isValid
() )
77
{
78
return
false
;
79
}
80
81
// Get the object
82
const
INavigable4Momentum
* object(NULL);
83
object
= (*objectLink);
84
if
(
object
== NULL )
85
{
86
return
false
;
87
}
88
89
return
getAssociations
(
object
, associatedElementLinks );
90
}
91
92
93
94
95
bool
96
INav4MomAssocs::getAssociations
(
const
INavigable4Momentum
*
object
,
97
INav4MomLinkContainer
& associatedElementLinks )
const
98
{
99
if
( 0 ==
object
)
100
{
101
return
false
;
102
}
103
104
// do the underlying stores contain this object ?
105
bool
contained =
false
;
106
for
( std::map<std::string,
DataLink<INav4MomAssocs>
>
::const_iterator
itr =
m_assocStores
.begin();
107
itr !=
m_assocStores
.end();
108
++itr )
109
{
110
if
( itr->second->getAssociations(
object
, associatedElementLinks ) )
111
{
112
contained =
true
;
113
}
114
}
115
116
if
( !contained && !
containsObject
(
object
) )
117
{
118
return
false
;
119
}
120
121
// check key
122
store_type::const_iterator mapEnd =
m_associationMap
.end();
123
store_type::const_iterator foundIter = mapEnd;
124
for
( store_type::const_iterator iMap =
m_associationMap
.begin();
125
iMap != mapEnd;
126
++iMap )
127
{
128
// look for the address of the pointed-at object
129
// must dereference the ElementLink pointer
130
if
( &*(*(iMap->first)) == &*(
object
) )
131
{
132
foundIter = iMap;
133
break
;
134
}
135
}
136
if
( foundIter ==
m_associationMap
.end() )
137
{
138
return
false
;
139
}
140
141
// Now, loop over all associations and fill the vector of associations
142
associatedElementLinks.reserve( associatedElementLinks.size() +
143
getNumberOfAssociations
(
object
) );
144
ElementLinkVector<INavigable4MomentumCollection>::const_iterator
assoItr = (foundIter->second).begin();
145
ElementLinkVector<INavigable4MomentumCollection>::const_iterator
assoItrEnd = (foundIter->second).end();
146
for
( ; assoItr != assoItrEnd; ++assoItr )
147
{
148
const
INav4MomLink
assoLink = (*assoItr);
149
associatedElementLinks.push_back( assoLink );
150
}
151
152
return
true
;
153
}
154
155
156
158
// Non-const methods:
160
161
void
INav4MomAssocs::addAssocStore
(
const
DataLink<INav4MomAssocs>
& assocStore )
162
{
163
const
std::string&
id
= assocStore.
dataID
();
164
const
std::map<std::string, DataLink<INav4MomAssocs> >
::const_iterator
itr =
m_assocStores
.find(
id
);
165
if
( itr !=
m_assocStores
.end() ) {
166
m_assocStores
[id] = assocStore;
167
}
168
}
169
170
171
std::vector<DataLink<INav4MomAssocs> >
INav4MomAssocs::getAssocStores
()
const
172
{
173
std::vector<DataLink<INav4MomAssocs> > ret;
174
ret.reserve (
m_assocStores
.size());
175
for
(
const
auto
& p :
m_assocStores
) {
176
ret.push_back (p.second);
177
}
178
return
ret;
179
}
180
181
182
#ifdef __APPLE__
184
// Static template members:
186
// This is only necessary for MacOSX where there's a bug in the linker that causes duplicate symbols if
187
// the static templates for the same concrete type are instantiated in two different .cxx files
188
template
<
class
T> DataVector_detail::RegisterDVLEltBaseInit<T> DataVector_detail::DVLEltBaseInit<T>::s_regbase;
189
template
class
DataVector_detail::RegisterDVLEltBaseInit<IParticle> DataVector_detail::DVLEltBaseInit<IParticle>::s_regbase;
190
#endif
191
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
IParticle.h
INav4MomAssocs.h
INav4MomLink
ElementLink< INavigable4MomentumCollection > INav4MomLink
Definition
INav4MomLink.h:18
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::beginAssociation
asso_iterator beginAssociation(const object_type *objectPointer) const
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::m_associationMap
store_type m_associationMap
Definition
AssociationMap.h:207
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::getNumberOfAssociations
size_t getNumberOfAssociations(const object_type *objectPointer) const
Definition
AssociationMap.h:195
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::asso_iterator
AssociationVectorIterator asso_iterator
Definition
AssociationMap.h:81
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::endAssociation
asso_iterator endAssociation(const object_type *objectPointer) const
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::containsObject
bool containsObject(const object_type *theObject) const
Definition
AssociationMap.h:143
const_iterator
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataLink
Object reference supporting deferred reading from StoreGate.
Definition
AthLinks/DataLink.h:93
DataLink::dataID
const ID_type & dataID() const
Get the key that we reference, as a string.
ElementLinkVector::const_iterator
ELVIterator< typename RefVector::const_iterator > const_iterator
Definition
AthLinks/ElementLinkVector.h:128
ElementLink::isValid
bool isValid() const
Check if the element can be found.
INav4MomAssocs
Definition
INav4MomAssocs.h:33
INav4MomAssocs::INav4MomAssocs
INav4MomAssocs()
Default constructor:
INav4MomAssocs::m_assocStores
std::map< std::string, INav4MomAssocsLink_t > m_assocStores
Definition
INav4MomAssocs.h:134
INav4MomAssocs::assocs
bool assocs(const INavigable4Momentum *object, ConstDataVector< INavigable4MomentumCollection > &assocs) const
Retrieve all the associated-to objects which have been associated to the given.
Definition
INav4MomAssocs.cxx:37
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::getAssociations
bool getAssociations(const INav4MomLink &objectLink, INav4MomLinkContainer &associatedElementLinks) const
Retrieve all the associated-to ElementLinks_to_objects which have been associated to the given.
Definition
INav4MomAssocs.cxx:73
INav4MomAssocs::getAssocStores
std::vector< DataLink< INav4MomAssocs > > getAssocStores() const
Return links to all other association stores.
Definition
INav4MomAssocs.cxx:171
INav4MomAssocs::operator=
INav4MomAssocs & operator=(const INav4MomAssocs &rhs)
Assignment operator:
INav4MomLinkContainer
INav4MomLinkContainer.h.
Definition
INav4MomLinkContainer.h:28
INavigable4Momentum
Definition
INavigable4Momentum.h:21
Generated on
for ATLAS Offline Software by
1.17.0