File indexing completed on 2025-08-06 08:18:11
0001
0002
0003
0004
0005
0006
0007 #include "TrkrClusterContainerv1.h"
0008 #include "TrkrCluster.h"
0009
0010 #include <cstdlib>
0011
0012 void TrkrClusterContainerv1::Reset()
0013 {
0014 while (m_clusmap.begin() != m_clusmap.end())
0015 {
0016 delete m_clusmap.begin()->second;
0017 m_clusmap.erase(m_clusmap.begin());
0018 }
0019 return;
0020 }
0021
0022 void TrkrClusterContainerv1::identify(std::ostream& os) const
0023 {
0024 os << "-----TrkrClusterContainerv1-----" << std::endl;
0025 ConstIterator iter;
0026 os << "Number of clusters: " << size() << std::endl;
0027 for (iter = m_clusmap.begin(); iter != m_clusmap.end(); ++iter)
0028 {
0029 int layer = TrkrDefs::getLayer(iter->first);
0030 os << "clus key " << iter->first << " layer " << layer << std::endl;
0031 (iter->second)->identify();
0032 }
0033 os << "------------------------------" << std::endl;
0034 return;
0035 }
0036
0037 void TrkrClusterContainerv1::addClusterSpecifyKey(const TrkrDefs::cluskey key, TrkrCluster* newclus)
0038 {
0039 const auto [iter, success] = m_clusmap.insert(std::make_pair(key, newclus));
0040 if (!success)
0041 {
0042 std::cout << "TrkrClusterContainerv1::AddClusterSpecifyKey: duplicate key: " << key << " exiting now" << std::endl;
0043 exit(1);
0044 }
0045 }
0046
0047 void TrkrClusterContainerv1::removeCluster(TrkrDefs::cluskey key)
0048 {
0049 m_clusmap.erase(key);
0050 }
0051
0052 TrkrClusterContainer::ConstRange
0053 TrkrClusterContainerv1::getClusters() const
0054 {
0055 return std::make_pair(m_clusmap.cbegin(), m_clusmap.cend());
0056 }
0057
0058 TrkrCluster*
0059 TrkrClusterContainerv1::findCluster(TrkrDefs::cluskey key) const
0060 {
0061 auto it = m_clusmap.find(key);
0062 return it == m_clusmap.end() ? nullptr : it->second;
0063 }
0064
0065 unsigned int TrkrClusterContainerv1::size() const
0066 {
0067 return m_clusmap.size();
0068 }