ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CMFlashClusterContainerv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CMFlashClusterContainerv1.cc
1 
8 #include "CMFlashCluster.h"
9 #include "CMFlashClusterv1.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 CMFlashClusterContainerv1::identify(std::ostream& os) const
24 {
25  os << "-----CMFlashClusterContainerv1-----" << 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  os << "clus key " << iter->first << std::endl;
31  (iter->second)->identify();
32  }
33  os << "------------------------------" << std::endl;
34  return;
35 }
36 
39 {
40  return addClusterSpecifyKey(newclus->getClusKey(), newclus);
41 }
42 
45 {
46  auto ret = m_clusmap.insert(std::make_pair(key, newclus));
47  if ( !ret.second )
48  {
49  std::cout << "CMFlashClusterContainerv1::AddClusterSpecifyKey: duplicate key: " << key << " exiting now" << std::endl;
50  exit(1);
51  }
52  else
53  {
54  return ret.first;
55  }
56 }
57 
59 { m_clusmap.erase(key); }
60 
62 { removeCluster( clus->getClusKey() ); }
63 
66 {
67  auto it = m_clusmap.lower_bound( key );
68  if (it == m_clusmap.end()|| (key < it->first ))
69  {
70  // add new cluster and set its key
71  it = m_clusmap.insert(it, std::make_pair(key, new CMFlashClusterv1()));
72  it->second->setClusKey(key);
73  }
74  return it;
75 }
76 
79 { return std::make_pair(m_clusmap.cbegin(), m_clusmap.cend()); }
80 
83 {
84  auto it = m_clusmap.find(key);
85  return it == m_clusmap.end() ? nullptr:it->second;
86 }
87 
88 unsigned int CMFlashClusterContainerv1::size() const
89 {
90  return m_clusmap.size();
91 }