ATLAS Offline Software
Loading...
Searching...
No Matches
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
19
21// Public methods:
23
24// Constructors/assignment
31
33// Const methods:
35
36bool
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() +
62 itr != endAssocs;
63 ++itr ) {
64 associatedElems.push_back( const_cast<INavigable4Momentum*>(*itr) );
65 }
66
67 return true;
68}
69
70
71
72bool
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
95bool
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
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
171std::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
188template <class T> DataVector_detail::RegisterDVLEltBaseInit<T> DataVector_detail::DVLEltBaseInit<T>::s_regbase;
189template class DataVector_detail::RegisterDVLEltBaseInit<IParticle> DataVector_detail::DVLEltBaseInit<IParticle>::s_regbase;
190#endif
191
An STL vector of pointers that by default owns its pointed-to elements.
asso_iterator beginAssociation(const object_type *objectPointer) const
asso_iterator endAssociation(const object_type *objectPointer) const
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ELVIterator< typename RefVector::const_iterator > const_iterator
INav4MomAssocs()
Default constructor:
std::map< std::string, INav4MomAssocsLink_t > m_assocStores
bool assocs(const INavigable4Momentum *object, ConstDataVector< INavigable4MomentumCollection > &assocs) const
Retrieve all the associated-to objects which have been associated to the given.
void addAssocStore(const DataLink< INav4MomAssocs > &assocStore)
Retrieve all the associated-to objects which have been associated to the given.
bool getAssociations(const INav4MomLink &objectLink, INav4MomLinkContainer &associatedElementLinks) const
Retrieve all the associated-to ElementLinks_to_objects which have been associated to the given.
std::vector< DataLink< INav4MomAssocs > > getAssocStores() const
Return links to all other association stores.
INav4MomAssocs & operator=(const INav4MomAssocs &rhs)
Assignment operator: