Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:09

0001 /**
0002  * @file trackbase/LaserClusterContainerv1.cc
0003  * @author Ben Kimelman
0004  * @date February 2024
0005  * @brief Implementation of LaserClusterContainerv1
0006  */
0007 #include "LaserClusterContainerv1.h"
0008 #include "LaserCluster.h"
0009 
0010 #include <cstdlib>
0011 
0012 void LaserClusterContainerv1::Reset()
0013 {
0014   for( auto&& [key, cluster]:m_clusmap )
0015   { delete cluster; }
0016   
0017   m_clusmap.clear();
0018 }
0019 
0020 void LaserClusterContainerv1::identify(std::ostream& os) const
0021 {
0022   os << "-----LaserClusterContainerv1-----" << std::endl;
0023   ConstIterator iter;
0024   os << "Number of clusters: " << size() << std::endl;
0025   for (iter = m_clusmap.begin(); iter != m_clusmap.end(); ++iter)
0026   {
0027     os << "clus key " << iter->first  << std::endl;
0028     (iter->second)->identify();
0029   }
0030   os << "------------------------------" << std::endl;
0031   return;
0032 }
0033 
0034 void LaserClusterContainerv1::addClusterSpecifyKey(const TrkrDefs::cluskey key, LaserCluster* newclus)
0035 {
0036   auto ret = m_clusmap.insert(std::make_pair(key, newclus));
0037   if ( !ret.second )
0038   {
0039     std::cout << "LaserClusterContainerv1::AddClusterSpecifyKey: duplicate key: " << key << " exiting now" << std::endl;
0040     exit(1);
0041   }
0042 }
0043 
0044 void LaserClusterContainerv1::removeCluster(TrkrDefs::cluskey key)
0045 { 
0046   auto clus = findCluster(key);
0047   delete clus;
0048 
0049   m_clusmap.erase(key); 
0050 }
0051 
0052 LaserClusterContainer::ConstRange
0053 LaserClusterContainerv1::getClusters() const
0054 { return std::make_pair(m_clusmap.cbegin(), m_clusmap.cend()); }
0055 
0056 LaserCluster*
0057 LaserClusterContainerv1::findCluster(TrkrDefs::cluskey key) const
0058 {
0059   auto it = m_clusmap.find(key);
0060   return it == m_clusmap.end() ? nullptr:it->second;
0061 }
0062 
0063 unsigned int LaserClusterContainerv1::size() const
0064 {
0065   return m_clusmap.size();
0066 }