ATLAS Offline Software
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 
15 #include "EventKernel/IParticle.h"
17 
19 // Public methods:
21 
22 // Constructors
25  m_assocStores()
26 {}
27 
30  m_assocStores( rhs.m_assocStores )
31 {}
32 
33 // Assignment operator:
35 {
36  if ( this != &rhs ) {
39  }
40  return *this;
41 }
42 
44 // Const methods:
46 
48  ConstDataVector<Rec::TrackParticleContainer>& associatedElems ) const
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 
94 TrackParticleAssocs::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 
110 std::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 }
AssociationMap< Rec::TrackParticleContainer, Rec::TrackParticleContainer >::containsObject
bool containsObject(const object_type *theObject) const
testing if object is in store
Definition: AssociationMap.h:144
AssociationMap< Rec::TrackParticleContainer, Rec::TrackParticleContainer >::endAssociation
asso_iterator endAssociation(const object_type *objectPointer) const
end iterator for associations
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
AssociationMap< Rec::TrackParticleContainer, Rec::TrackParticleContainer >::getNumberOfAssociations
size_t getNumberOfAssociations(const object_type *objectPointer) const
Definition: AssociationMap.h:196
AthCUDAExamples::TrackParticleContainer
vecmem::edm::container< TrackParticleInterface, vecmem::edm::type::vector< float >, vecmem::edm::type::vector< float >, vecmem::edm::type::vector< float > > TrackParticleContainer
SoA, GPU friendly TrackParticleContainer.
Definition: Control/AthenaExamples/AthExCUDA/src/TrackParticleContainer.h:46
AssociationMap< Rec::TrackParticleContainer, Rec::TrackParticleContainer >::beginAssociation
asso_iterator beginAssociation(const object_type *objectPointer) const
begin iterator for associations
TrackParticleAssocs::assocs
bool assocs(const Rec::TrackParticle *object, ConstDataVector< Rec::TrackParticleContainer > &associatedElems) const
Retrieve all the associated-to objects which have been associated to the given.
Definition: TrackParticleAssocs.cxx:47
AssociationMap
templated base class for a look-up map for associations
Definition: AssociationMap.h:39
IParticle.h
TrackParticleAssocs.h
TrackParticleAssocs::assocStore
DataLink< TrackParticleAssocs > assocStore(const std::string &name) const
Look up an associated store. For testing.
Definition: TrackParticleAssocs.cxx:94
lumiFormat.i
int i
Definition: lumiFormat.py:92
Rec
Name: MuonSpContainer.h Package : offline/Reconstruction/MuonIdentification/muonEvent.
Definition: FakeTrackBuilder.h:10
ret
T ret(T t)
Definition: rootspy.cxx:260
TrackParticleAssocs::addAssocStore
void addAssocStore(const DataLink< TrackParticleAssocs > &assocStore)
Definition: TrackParticleAssocs.cxx:83
TrackParticleAssocs
Definition: TrackParticleAssocs.h:28
TrackParticleAssocs::m_assocStores
std::map< std::string, TrackParticleAssocsLink_t > m_assocStores
Definition: TrackParticleAssocs.h:97
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TrackParticleAssocs::TrackParticleAssocs
TrackParticleAssocs()
Default constructor:
Definition: TrackParticleAssocs.cxx:23
TrackParticleAssocs::getAssocStores
std::vector< DataLink< TrackParticleAssocs > > getAssocStores() const
Return links to all other association stores.
Definition: TrackParticleAssocs.cxx:110
Rec::TrackParticle
Definition: Reconstruction/Particle/Particle/TrackParticle.h:47
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
TrackParticleAssocs::operator=
TrackParticleAssocs & operator=(const TrackParticleAssocs &rhs)
Assignment operator:
Definition: TrackParticleAssocs.cxx:34
AssociationMap< Rec::TrackParticleContainer, Rec::TrackParticleContainer >::asso_iterator
AssociationVectorIterator asso_iterator
association iterator type
Definition: AssociationMap.h:81
TrackParticleAssocs::nAssocStores
size_t nAssocStores() const
Number of associated stores.
Definition: TrackParticleAssocs.cxx:104