ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrClusterContainerv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrClusterContainerv1.cc
1 
8 #include "TrkrCluster.h"
9 #include "TrkrClusterv2.h"
10 
11 #include <cstdlib>
12 
14 {
15  while (m_clusmap.begin() != m_clusmap.end())
16  {
17  delete m_clusmap.begin()->second;
18  m_clusmap.erase(m_clusmap.begin());
19  }
20  return;
21 }
22 
23 void TrkrClusterContainerv1::identify(std::ostream& os) const
24 {
25  os << "-----TrkrClusterContainerv1-----" << std::endl;
26  ConstIterator iter;
27  os << "Number of clusters: " << size() << std::endl;
28  for (iter = m_clusmap.begin(); iter != m_clusmap.end(); ++iter)
29  {
30  int layer = TrkrDefs::getLayer(iter->first);
31  os << "clus key " << iter->first << " layer " << layer << std::endl;
32  (iter->second)->identify();
33  }
34  os << "------------------------------" << std::endl;
35  return;
36 }
37 
40 {
41  return addClusterSpecifyKey(newclus->getClusKey(), newclus);
42 }
43 
46 {
47  auto ret = m_clusmap.insert(std::make_pair(key, newclus));
48  if ( !ret.second )
49  {
50  std::cout << "TrkrClusterContainerv1::AddClusterSpecifyKey: duplicate key: " << key << " exiting now" << std::endl;
51  exit(1);
52  }
53  else
54  {
55  return ret.first;
56  }
57 }
58 
60 { m_clusmap.erase(key); }
61 
63 { removeCluster( clus->getClusKey() ); }
64 
67 {
68  auto it = m_clusmap.lower_bound( key );
69  if (it == m_clusmap.end()|| (key < it->first ))
70  {
71  // add new cluster and set its key
72  it = m_clusmap.insert(it, std::make_pair(key, new TrkrClusterv2()));
73  it->second->setClusKey(key);
74  }
75  return it;
76 }
77 
80 { return std::make_pair(m_clusmap.cbegin(), m_clusmap.cend()); }
81 
84 {
85  auto it = m_clusmap.find(key);
86  return it == m_clusmap.end() ? nullptr:it->second;
87 }
88 
89 unsigned int TrkrClusterContainerv1::size() const
90 {
91  return m_clusmap.size();
92 }