ATLAS Offline Software
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
27  m_assocStores()
28 {}
29 
32  m_assocStores( rhs.m_assocStores )
33 {}
34 
35 // Assignment operator:
37 {
38  if ( this != &rhs ) {
41  }
42  return *this;
43 }
44 
46 // Const methods:
48 
50  ConstDataVector<Rec::TrackParticleContainer>& associatedElems ) const
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 
86 bool
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 
109 bool
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) );
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 
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 
203 std::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 }
AssociationMap< INavigable4MomentumCollection, Rec::TrackParticleContainer >::containsObject
bool containsObject(const object_type *theObject) const
testing if object is in store
Definition: AssociationMap.h:144
INav4MomToTrackParticleAssocs
Definition: INav4MomToTrackParticleAssocs.h:35
AssociationMap< INavigable4MomentumCollection, Rec::TrackParticleContainer >::endAssociation
asso_iterator endAssociation(const object_type *objectPointer) const
end iterator for associations
INav4MomToTrackParticleAssocs::addAssocStore
void addAssocStore(const DataLink< INav4MomToTrackParticleAssocs > &assocStore)
Definition: INav4MomToTrackParticleAssocs.cxx:176
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
AssociationMap< INavigable4MomentumCollection, Rec::TrackParticleContainer >::getNumberOfAssociations
size_t getNumberOfAssociations(const object_type *objectPointer) const
Definition: AssociationMap.h:196
INav4MomToTrackParticleAssocs::INav4MomToTrackParticleAssocs
INav4MomToTrackParticleAssocs()
Default constructor:
Definition: INav4MomToTrackParticleAssocs.cxx:25
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
INavigable4Momentum.h
AssociationMap< INavigable4MomentumCollection, Rec::TrackParticleContainer >::beginAssociation
asso_iterator beginAssociation(const object_type *objectPointer) const
begin iterator for associations
INav4MomToTrackParticleAssocs::operator=
INav4MomToTrackParticleAssocs & operator=(const INav4MomToTrackParticleAssocs &rhs)
Assignment operator:
Definition: INav4MomToTrackParticleAssocs.cxx:36
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
AssociationMap
templated base class for a look-up map for associations
Definition: AssociationMap.h:39
atn_test_sgProducerConsumerDataPool_jobOptions.end
end
Definition: atn_test_sgProducerConsumerDataPool_jobOptions.py:25
INav4MomToTrackParticleAssocs::nAssocStores
size_t nAssocStores() const
Number of associated stores.
Definition: INav4MomToTrackParticleAssocs.cxx:197
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
INavigable4MomentumCollection.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
INav4MomToTrackParticleAssocs::m_assocStores
std::map< std::string, INav4MomToTrackParticleAssocsLink_t > m_assocStores
Definition: INav4MomToTrackParticleAssocs.h:116
ElementLinkVector
ElementLinkVector implementation for standalone ROOT.
Definition: AthLinks/ElementLinkVector.h:27
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Rec::TrackParticleContainer
Definition: Reconstruction/Particle/Particle/TrackParticleContainer.h:33
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
INav4MomToTrackParticleAssocs::getAssocStores
std::vector< DataLink< INav4MomToTrackParticleAssocs > > getAssocStores() const
Return links to all other association stores.
Definition: INav4MomToTrackParticleAssocs.cxx:203
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
INav4MomToTrackParticleAssocs::assocs
bool assocs(const INavigable4Momentum *object, ConstDataVector< Rec::TrackParticleContainer > &associatedElems) const
Retrieve all the associated-to objects which have been associated to the given.
Definition: INav4MomToTrackParticleAssocs.cxx:49
INavigable4Momentum
Definition: INavigable4Momentum.h:21
INav4MomToTrackParticleAssocs.h
pickleTool.object
object
Definition: pickleTool.py:30
AssociationMap< INavigable4MomentumCollection, Rec::TrackParticleContainer >::asso_iterator
AssociationVectorIterator asso_iterator
association iterator type
Definition: AssociationMap.h:81
AssociationMap< INavigable4MomentumCollection, Rec::TrackParticleContainer >::m_associationMap
store_type m_associationMap
internal store
Definition: AssociationMap.h:208
INav4MomToTrackParticleAssocs::getAssociations
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.
Definition: INav4MomToTrackParticleAssocs.cxx:87
INav4MomToTrackParticleAssocs::assocStore
DataLink< INav4MomToTrackParticleAssocs > assocStore(const std::string &name) const
Look up an associated store. For testing.
Definition: INav4MomToTrackParticleAssocs.cxx:187