ATLAS Offline Software
INav4MomAssocs.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // INav4MomAssocs.cxx
7 // Implementation file for class INav4MomAssocs
8 // Author: S.Binet<binet@cern.ch>
10 
11 
12 // STL includes
13 #include <algorithm>
14 
15 // NavFourMom includes
17 #include "EventKernel/IParticle.h"
19 
21 // Public methods:
23 
24 // Constructors
29  m_assocStores()
30 {}
31 
35  m_assocStores( rhs.m_assocStores )
36 {}
37 
38 // Assignment operator:
40 {
41  if ( this != &rhs ) {
43  INavigable4MomentumCollection >::operator=(rhs);
45  }
46  return *this;
47 }
48 
50 // Const methods:
52 
53 bool
55  ConstDataVector<INavigable4MomentumCollection>& associatedElems ) const
56 {
57  if ( 0 == object ) {
58  return false;
59  }
60 
61  // do the underlying stores contain this object ?
62  bool contained = false;
63  for ( std::map<std::string, DataLink<INav4MomAssocs> >::const_iterator itr = m_assocStores.begin();
64  itr != m_assocStores.end();
65  ++itr ) {
66  if ( itr->second->assocs(object, associatedElems) ) {
67  contained = true;
68  }
69  }
70 
71  if ( !contained && !containsObject( object ) ) {
72  return false;
73  }
74 
75  associatedElems.reserve( associatedElems.size() +
76  getNumberOfAssociations(object) );
77  INav4MomAssocs::asso_iterator endAssocs = endAssociation( object );
78  for ( INav4MomAssocs::asso_iterator itr = beginAssociation( object );
79  itr != endAssocs;
80  ++itr ) {
81  associatedElems.push_back( const_cast<INavigable4Momentum*>(*itr) );
82  }
83 
84  return true;
85 }
86 
87 
88 
89 bool
91  INav4MomLinkContainer& associatedElementLinks ) const
92 {
93  if ( !objectLink.isValid() )
94  {
95  return false;
96  }
97 
98  // Get the object
99  const INavigable4Momentum* object(NULL);
100  object = (*objectLink);
101  if ( object == NULL )
102  {
103  return false;
104  }
105 
106  return getAssociations( object, associatedElementLinks );
107 }
108 
109 
110 
111 
112 bool
114  INav4MomLinkContainer& associatedElementLinks ) const
115 {
116  if ( 0 == object )
117  {
118  return false;
119  }
120 
121  // do the underlying stores contain this object ?
122  bool contained = false;
123  for ( std::map<std::string, DataLink<INav4MomAssocs> >::const_iterator itr = m_assocStores.begin();
124  itr != m_assocStores.end();
125  ++itr )
126  {
127  if ( itr->second->getAssociations( object, associatedElementLinks ) )
128  {
129  contained = true;
130  }
131  }
132 
133  if ( !contained && !containsObject( object ) )
134  {
135  return false;
136  }
137 
138  // check key
139  store_type::const_iterator mapEnd = m_associationMap.end();
140  store_type::const_iterator foundIter = mapEnd;
141  for ( store_type::const_iterator iMap = m_associationMap.begin();
142  iMap != mapEnd;
143  ++iMap )
144  {
145  // look for the address of the pointed-at object
146  // must dereference the ElementLink pointer
147  if ( &*(*(iMap->first)) == &*(object) )
148  {
149  foundIter = iMap;
150  break;
151  }
152  }
153  if ( foundIter == m_associationMap.end() )
154  {
155  return false;
156  }
157 
158  // Now, loop over all associations and fill the vector of associations
159  associatedElementLinks.reserve( associatedElementLinks.size() +
160  getNumberOfAssociations(object) );
163  for ( ; assoItr != assoItrEnd; ++assoItr )
164  {
165  const INav4MomLink assoLink = (*assoItr);
166  associatedElementLinks.push_back( assoLink );
167  }
168 
169  return true;
170 }
171 
172 
173 
175 // Non-const methods:
177 
179 {
180  const std::string& id = assocStore.dataID();
181  const std::map<std::string, DataLink<INav4MomAssocs> >::const_iterator itr = m_assocStores.find(id);
182  if ( itr != m_assocStores.end() ) {
183  m_assocStores[id] = assocStore;
184  }
185 }
186 
187 
188 std::vector<DataLink<INav4MomAssocs> > INav4MomAssocs::getAssocStores() const
189 {
190  std::vector<DataLink<INav4MomAssocs> > ret;
191  ret.reserve (m_assocStores.size());
192  for (const auto& p : m_assocStores) {
193  ret.push_back (p.second);
194  }
195  return ret;
196 }
197 
198 
199 #ifdef __APPLE__
200 // Static template members:
203 // This is only necessary for MacOSX where there's a bug in the linker that causes duplicate symbols if
204 // the static templates for the same concrete type are instantiated in two different .cxx files
205 template <class T> DataVector_detail::RegisterDVLEltBaseInit<T> DataVector_detail::DVLEltBaseInit<T>::s_regbase;
206 template class DataVector_detail::RegisterDVLEltBaseInit<IParticle> DataVector_detail::DVLEltBaseInit<IParticle>::s_regbase;
207 #endif
208 
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::containsObject
bool containsObject(const object_type *theObject) const
testing if object is in store
Definition: AssociationMap.h:143
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::endAssociation
asso_iterator endAssociation(const object_type *objectPointer) const
end iterator for associations
INav4MomAssocs::m_assocStores
std::map< std::string, INav4MomAssocsLink_t > m_assocStores
Definition: INav4MomAssocs.h:126
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::getNumberOfAssociations
size_t getNumberOfAssociations(const object_type *objectPointer) const
Definition: AssociationMap.h:195
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::beginAssociation
asso_iterator beginAssociation(const object_type *objectPointer) const
begin iterator for associations
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
AssociationMap
templated base class for a look-up map for associations
Definition: AssociationMap.h:39
IParticle.h
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
INav4MomAssocs.h
INav4MomAssocs::assocs
bool assocs(const INavigable4Momentum *object, ConstDataVector< INavigable4MomentumCollection > &assocs) const
Retrieve all the associated-to objects which have been associated to the given.
Definition: INav4MomAssocs.cxx:54
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
INavigable4MomentumCollection
DataVector< INavigable4Momentum > INavigable4MomentumCollection
Definition: INavigable4MomentumCollection.h:22
INav4MomAssocs
Definition: INav4MomAssocs.h:33
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
INav4MomAssocs::addAssocStore
void addAssocStore(const DataLink< INav4MomAssocs > &assocStore)
Retrieve all the associated-to objects which have been associated to the given.
Definition: INav4MomAssocs.cxx:178
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
INav4MomAssocs::getAssocStores
std::vector< DataLink< INav4MomAssocs > > getAssocStores() const
Return links to all other association stores.
Definition: INav4MomAssocs.cxx:188
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
INavigable4Momentum
Definition: INavigable4Momentum.h:21
ElementLinkVector::ELVIterator
Definition: AthLinks/ElementLinkVector.h:112
INav4MomAssocs::getAssociations
bool getAssociations(const INav4MomLink &objectLink, INav4MomLinkContainer &associatedElementLinks) const
Retrieve all the associated-to ElementLinks_to_objects which have been associated to the given.
Definition: INav4MomAssocs.cxx:90
pickleTool.object
object
Definition: pickleTool.py:30
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::asso_iterator
AssociationVectorIterator asso_iterator
association iterator type
Definition: AssociationMap.h:81
AssociationMap< INavigable4MomentumCollection, INavigable4MomentumCollection >::m_associationMap
store_type m_associationMap
internal store
Definition: AssociationMap.h:207
INav4MomAssocs::operator=
INav4MomAssocs & operator=(const INav4MomAssocs &rhs)
Assignment operator:
Definition: INav4MomAssocs.cxx:39
INav4MomAssocs::INav4MomAssocs
INav4MomAssocs()
Default constructor:
Definition: INav4MomAssocs.cxx:26