ATLAS Offline Software
Loading...
Searching...
No Matches
INav4MomToTrackParticleAssocs.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
6// INav4MomToTrackParticleAssocs.cxx
7// Implementation file for class INav4MomToTrackParticleAssocs
8// Author: Karsten Koeneke
10
11// STL includes
12#include <algorithm>
13
18#include <utility>
19
20
22// Public methods:
24
25// Constructors
30
35
36// Assignment operator:
45
46
47
50{
51 if (this != &rhs) {
52 m_associationMap = std::move(rhs.m_associationMap);
53 m_assocStores = std::move(rhs.m_assocStores);
54 }
55 return *this;
56}
57
59// Const methods:
61
64{
65 // Make a sanity check against a null pointer
66 if ( 0 == object ) { return false; }
67
68 // do the underlying stores contain this object ?
69 bool contained = false;
70 for ( std::map<std::string, DataLink<INav4MomToTrackParticleAssocs> >::const_iterator itr(m_assocStores.begin()), itrEnd(m_assocStores.end());
71 itr != itrEnd;
72 ++itr )
73 {
74 if ( itr->second->assocs(object, associatedElems) )
75 {
76 contained = true;
77 }
78 }
79
80 if ( !contained && !containsObject( object ) )
81 {
82 return false;
83 }
84
85 associatedElems.reserve( associatedElems.size() + getNumberOfAssociations(object) );
88 itr != endAssocs;
89 ++itr )
90 {
91 associatedElems.push_back(*itr);
92 }
93
94 return true;
95}
96
97
98
99bool
102 Rec::TrackParticleContainer >::asso_link >& associatedElementLinks ) const
103{
104 if ( !objectLink.isValid() )
105 {
106 return false;
107 }
108
109 // Get the object
110 const INavigable4Momentum* object(NULL);
111 object = (*objectLink);
112 if ( object == NULL )
113 {
114 return false;
115 }
116
117 return getAssociations( object, associatedElementLinks );
118}
119
120
121
122bool
125 Rec::TrackParticleContainer >::asso_link >& associatedElementLinks ) const
126{
127 if ( 0 == object )
128 {
129 return false;
130 }
131
132 // do the underlying stores contain this object ?
133 bool contained = false;
134 for ( std::map<std::string, DataLink<INav4MomToTrackParticleAssocs> >::const_iterator itr = m_assocStores.begin();
135 itr != m_assocStores.end();
136 ++itr )
137 {
138 if ( itr->second->getAssociations( object, associatedElementLinks ) )
139 {
140 contained = true;
141 }
142 }
143
144 if ( !contained && !containsObject( object ) )
145 {
146 return false;
147 }
148
149 // check key
150 store_type::const_iterator mapEnd = m_associationMap.end();
151 store_type::const_iterator foundIter = mapEnd;
152 for ( store_type::const_iterator iMap = m_associationMap.begin();
153 iMap != mapEnd;
154 ++iMap )
155 {
156 // look for the address of the pointed-at object
157 // must dereference the ElementLink pointer
158 if ( &*(*(iMap->first)) == &*(object) )
159 {
160 foundIter = iMap;
161 break;
162 }
163 }
164 if ( foundIter == m_associationMap.end() )
165 {
166 return false;
167 }
168
169 // Now, loop over all associations and fill the vector of associations
170 associatedElementLinks.reserve( associatedElementLinks.size() +
171 getNumberOfAssociations(object) );
172 ElementLinkVector<Rec::TrackParticleContainer>::const_iterator assoItr = (foundIter->second).begin();
173 ElementLinkVector<Rec::TrackParticleContainer>::const_iterator assoItrEnd = (foundIter->second).end();
174 for ( ; assoItr != assoItrEnd; ++assoItr )
175 {
177 associatedElementLinks.push_back( assoLink );
178 }
179
180 return true;
181}
182
183
184
186// Non-const methods:
188
190{
191 const std::string& id = assocStore.dataID();
192 const std::map<std::string, DataLink<INav4MomToTrackParticleAssocs> >::const_iterator itr = m_assocStores.find(id);
193 if ( itr == m_assocStores.end() )
194 {
196 }
197}
198
200INav4MomToTrackParticleAssocs::assocStore (const std::string& name) const
201{
202 std::map<std::string, INav4MomToTrackParticleAssocsLink_t>::const_iterator i =
203 m_assocStores.find (name);
204 if (i != m_assocStores.end())
205 return i->second;
207}
208
209
211{
212 return m_assocStores.size();
213}
214
215
216std::vector<DataLink<INav4MomToTrackParticleAssocs> > INav4MomToTrackParticleAssocs::getAssocStores() const
217{
218 std::vector<DataLink<INav4MomToTrackParticleAssocs> > ret;
219 ret.reserve (m_assocStores.size());
220 for (const auto& p : m_assocStores) {
221 ret.push_back (p.second);
222 }
223 return ret;
224}
An STL vector of pointers that by default owns its pointed-to elements.
DataVector< INavigable4Momentum > INavigable4MomentumCollection
asso_iterator beginAssociation(const object_type *objectPointer) const
size_t getNumberOfAssociations(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
size_t nAssocStores() const
Number of associated stores.
INav4MomToTrackParticleAssocs & operator=(const INav4MomToTrackParticleAssocs &rhs)
Assignment operator:
std::map< std::string, INav4MomToTrackParticleAssocsLink_t > m_assocStores
bool assocs(const INavigable4Momentum *object, ConstDataVector< Rec::TrackParticleContainer > &associatedElems) const
Retrieve all the associated-to objects which have been associated to the given.
bool getAssociations(const INav4MomLink &objectLink, std::vector< AssociationMap< INavigable4MomentumCollection, Rec::TrackParticleContainer >::asso_link > &associatedElementLinks) const
Retrieve all the associated-to ElementLinks_to_objects which have been associated to the given.
std::vector< DataLink< INav4MomToTrackParticleAssocs > > getAssocStores() const
Return links to all other association stores.
DataLink< INav4MomToTrackParticleAssocs > assocStore(const std::string &name) const
Look up an associated store. For testing.
void addAssocStore(const DataLink< INav4MomToTrackParticleAssocs > &assocStore)
namespace for combined reconstruction tools and interfaces