ATLAS Offline Software
Loading...
Searching...
No Matches
AssociationObjectIterator.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
84
86#ifdef ASSOCIATIONMAP_CONTEXT
87
89{
90public:
91
95AssociationObjectIterator() : m_store(0)
96{ }
97
102AssociationObjectIterator(const store_type& theStore)
103 : m_store(&theStore)
104 , m_actual(theStore.begin())
105{ }
106
112AssociationObjectIterator(const store_type& theStore,
113 const typename store_type::const_iterator& pos)
114 : m_store(&theStore)
115 , m_actual(pos)
116{ }
117
121 m_store ( rhs.m_store ),
122 m_actual( rhs.m_actual )
123{}
124
128{
129 if ( this != &rhs ) {
130 m_store = rhs.m_store;
131 m_actual= rhs.m_actual;
132 }
133 return *this;
134}
135
138{ }
140
143
146{ return AssociationObjectIterator(*m_store); }
147
150{ return AssociationObjectIterator(*m_store, m_store->end()); }
151
152AssociationObjectIterator begin() const
153{ return AssociationObjectIterator(*m_store); }
155
157{ return AssociationObjectIterator(*m_store,m_store->end()); }
158
161{ ++m_actual; return *this; }
162
165{ --m_actual; return *this; }
166
168AssociationObjectIterator operator++()
169{
170 AssociationObjectIterator tmp(*this);
171 ++m_actual;
172 return tmp;
173}
174
176AssociationObjectIterator operator++(int) { return this->next(); }
177
179AssociationObjectIterator operator--()
180{
181 AssociationObjectIterator tmp(*this);
182 --m_actual;
183 return tmp;
184}
185
187AssociationObjectIterator operator--(int) { return this->prev(); }
189
196bool operator==(const AssociationObjectIterator& anOther) const
197{ return m_actual == anOther.m_actual; }
198// bool operator==(AssociationObjectIterator& anOther)
199// { return m_actual == anOther.m_actual; }
204bool operator!=(const AssociationObjectIterator& anOther) const
205{ return m_actual != anOther.m_actual; }
206// bool operator!=(AssociationObjectIterator& anOther)
207// { return m_actual != anOther.m_actual; }
209
220AssociationObjectIterator operator*() const { return *this; }
221
223const object_type* operator->()
224{ return this->getObject(); }
225
227const object_type* operator->() const
228{ return this->getObject(); }
229
231const object_type* first() const { return *(m_actual->first); }
233asso_iterator second() const
234{ return asso_iterator(m_actual->second,m_actual->second.begin()); }
243AssociationObjectIterator find(const object_type* objectPointer) const
244{
245 const AssociationObjectIterator lastObj = this->end();
246 AssociationObjectIterator firstObj = this->begin();
247 AssociationObjectIterator foundObj = lastObj;
248 while (firstObj != lastObj )
249 {
250 if ( firstObj.isValid() && firstObj.getObject() == objectPointer )
251 {
252 foundObj = firstObj;
253 firstObj = lastObj;
254 }
255 else
256 {
257 ++firstObj;
258 }
259 }
260 return foundObj;
261}
268const object_type* getObject() const { return this->first(); }
269
271const object_link& getObjectLink() const { return m_actual->first; }
272
273bool isValid() const { return this->m_actual->first.isValid(); }
274
276asso_iterator getFirstAssociation() const
277{
278 return asso_iterator(m_actual->second, m_actual->second.begin());
279}
280
282asso_iterator getLastAssociation() const
283{
284 return asso_iterator(m_actual->second, m_actual->second.end());
285}
286
288asso_iterator findAssociation(const asso_type* assoPointer) const
289{
290 asso_iterator assItr = asso_iterator(m_actual->second,
291 m_actual->second.begin());
292 return assItr.find(assoPointer);
293}
294
296bool containsAssociation(const asso_type* assoPointer) const
297{ return this->findAssociation(assoPointer) != this->getLastAssociation(); }
298
300size_t getNumberOfAssociations() const
301{ return m_actual->second.size(); }
302
303size_t size() const { return m_store->size(); }
304
305private:
306
307 const store_type* m_store{};
308 typename store_type::const_iterator m_actual{};
309};
310#endif
311
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
bool operator!=(const DataVector< T > &a, const DataVector< T > &b)
Based on operator==.
bool operator==(const DataVector< T > &a, const DataVector< T > &b)
Vector equality comparison.
xAOD::MissingET_v1 operator*(const xAOD::MissingET_v1 &met, float scale)
Create new MET object from source with scaled (weighted) kinematics.
object iterator for association maps (internal use only!)
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138