ATLAS Offline Software
Loading...
Searching...
No Matches
TrackParticleAssocs.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// TrackParticleAssocs.cxx
7// Implementation file for class TrackParticleAssocs
8// Author: C.Anastopoulos
10
11// STL includes
12#include <algorithm>
13
17
19// Public methods:
21
22// Constructors
24 AssociationMap<Rec::TrackParticleContainer, Rec::TrackParticleContainer>(),
26{}
27
29 AssociationMap<Rec::TrackParticleContainer,Rec::TrackParticleContainer>(rhs),
31{}
32
33// Assignment operator:
42
44// Const methods:
46
49{
50 if ( 0 == object ) {
51 return false;
52 }
53
54 // do the underlying stores contain this object ?
55 bool contained = false;
56 for ( std::map<std::string, DataLink<TrackParticleAssocs> >::const_iterator itr = m_assocStores.begin();
57 itr != m_assocStores.end();
58 ++itr ) {
59 if ( itr->second->assocs(object, associatedElems) ) {
60 contained = true;
61 }
62 }
63
64 if ( !contained && !containsObject( object ) ) {
65 return false;
66 }
67
68 associatedElems.reserve( associatedElems.size() + getNumberOfAssociations(object) );
71 itr != endAssocs;
72 ++itr ) {
73 associatedElems.push_back( const_cast<Rec::TrackParticle*>(*itr) );
74 }
75
76 return true;
77}
78
80// Non-const methods:
82
84 {
85 const std::string& id = assocStore.dataID();
86 const std::map<std::string, DataLink<TrackParticleAssocs> >::const_iterator itr = m_assocStores.find(id);
87 if ( itr == m_assocStores.end() ) {
89 }
90 }
91
92
94TrackParticleAssocs::assocStore (const std::string& name) const
95{
96 std::map<std::string, TrackParticleAssocsLink_t>::const_iterator i =
97 m_assocStores.find (name);
98 if (i != m_assocStores.end())
99 return i->second;
101}
102
103
105{
106 return m_assocStores.size();
107}
108
109
110std::vector<DataLink<TrackParticleAssocs> > TrackParticleAssocs::getAssocStores() const
111{
112 std::vector<DataLink<TrackParticleAssocs> > ret;
113 ret.reserve (m_assocStores.size());
114 for (const auto& p : m_assocStores) {
115 ret.push_back (p.second);
116 }
117 return ret;
118}
An STL vector of pointers that by default owns its pointed-to elements.
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.
std::vector< DataLink< TrackParticleAssocs > > getAssocStores() const
Return links to all other association stores.
DataLink< TrackParticleAssocs > assocStore(const std::string &name) const
Look up an associated store. For testing.
void addAssocStore(const DataLink< TrackParticleAssocs > &assocStore)
TrackParticleAssocs()
Default constructor:
bool assocs(const Rec::TrackParticle *object, ConstDataVector< Rec::TrackParticleContainer > &associatedElems) const
Retrieve all the associated-to objects which have been associated to the given.
std::map< std::string, TrackParticleAssocsLink_t > m_assocStores
size_t nAssocStores() const
Number of associated stores.
TrackParticleAssocs & operator=(const TrackParticleAssocs &rhs)
Assignment operator:
Gaudi Tools.