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
19
21// Public methods:
23
24// Constructors
29
34
35// Assignment operator:
44
46// Const methods:
48
51{
52 // Make a sanity check against a null pointer
53 if ( 0 == object ) { return false; }
54
55 // do the underlying stores contain this object ?
56 bool contained = false;
57 for ( std::map<std::string, DataLink<INav4MomToTrackParticleAssocs> >::const_iterator itr(m_assocStores.begin()), itrEnd(m_assocStores.end());
58 itr != itrEnd;
59 ++itr )
60 {
61 if ( itr->second->assocs(object, associatedElems) )
62 {
63 contained = true;
64 }
65 }
66
67 if ( !contained && !containsObject( object ) )
68 {
69 return false;
70 }
71
72 associatedElems.reserve( associatedElems.size() + getNumberOfAssociations(object) );
75 itr != endAssocs;
76 ++itr )
77 {
78 associatedElems.push_back(*itr);
79 }
80
81 return true;
82}
83
84
85
86bool
89 Rec::TrackParticleContainer >::asso_link >& associatedElementLinks ) const
90{
91 if ( !objectLink.isValid() )
92 {
93 return false;
94 }
95
96 // Get the object
97 const INavigable4Momentum* object(NULL);
98 object = (*objectLink);
99 if ( object == NULL )
100 {
101 return false;
102 }
103
104 return getAssociations( object, associatedElementLinks );
105}
106
107
108
109bool
112 Rec::TrackParticleContainer >::asso_link >& associatedElementLinks ) const
113{
114 if ( 0 == object )
115 {
116 return false;
117 }
118
119 // do the underlying stores contain this object ?
120 bool contained = false;
121 for ( std::map<std::string, DataLink<INav4MomToTrackParticleAssocs> >::const_iterator itr = m_assocStores.begin();
122 itr != m_assocStores.end();
123 ++itr )
124 {
125 if ( itr->second->getAssociations( object, associatedElementLinks ) )
126 {
127 contained = true;
128 }
129 }
130
131 if ( !contained && !containsObject( object ) )
132 {
133 return false;
134 }
135
136 // check key
137 store_type::const_iterator mapEnd = m_associationMap.end();
138 store_type::const_iterator foundIter = mapEnd;
139 for ( store_type::const_iterator iMap = m_associationMap.begin();
140 iMap != mapEnd;
141 ++iMap )
142 {
143 // look for the address of the pointed-at object
144 // must dereference the ElementLink pointer
145 if ( &*(*(iMap->first)) == &*(object) )
146 {
147 foundIter = iMap;
148 break;
149 }
150 }
151 if ( foundIter == m_associationMap.end() )
152 {
153 return false;
154 }
155
156 // Now, loop over all associations and fill the vector of associations
157 associatedElementLinks.reserve( associatedElementLinks.size() +
158 getNumberOfAssociations(object) );
159 ElementLinkVector<Rec::TrackParticleContainer>::const_iterator assoItr = (foundIter->second).begin();
160 ElementLinkVector<Rec::TrackParticleContainer>::const_iterator assoItrEnd = (foundIter->second).end();
161 for ( ; assoItr != assoItrEnd; ++assoItr )
162 {
164 associatedElementLinks.push_back( assoLink );
165 }
166
167 return true;
168}
169
170
171
173// Non-const methods:
175
177{
178 const std::string& id = assocStore.dataID();
179 const std::map<std::string, DataLink<INav4MomToTrackParticleAssocs> >::const_iterator itr = m_assocStores.find(id);
180 if ( itr == m_assocStores.end() )
181 {
183 }
184}
185
187INav4MomToTrackParticleAssocs::assocStore (const std::string& name) const
188{
189 std::map<std::string, INav4MomToTrackParticleAssocsLink_t>::const_iterator i =
190 m_assocStores.find (name);
191 if (i != m_assocStores.end())
192 return i->second;
194}
195
196
198{
199 return m_assocStores.size();
200}
201
202
203std::vector<DataLink<INav4MomToTrackParticleAssocs> > INav4MomToTrackParticleAssocs::getAssocStores() const
204{
205 std::vector<DataLink<INav4MomToTrackParticleAssocs> > ret;
206 ret.reserve (m_assocStores.size());
207 for (const auto& p : m_assocStores) {
208 ret.push_back (p.second);
209 }
210 return ret;
211}
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)
Gaudi Tools.