File indexing completed on 2025-08-06 08:18:13
0001
0002
0003
0004
0005
0006
0007 #include "TrkrHitSetv1.h"
0008 #include "TrkrHit.h"
0009
0010 #include <cstdlib> // for exit
0011 #include <iostream>
0012 #include <type_traits> // for __decay_and_strip<>::__type
0013
0014 void TrkrHitSetv1::Reset()
0015 {
0016 m_hitSetKey = TrkrDefs::HITSETKEYMAX;
0017
0018 for (auto&& [key, hit] : m_hits)
0019 {
0020 delete hit;
0021 }
0022
0023 m_hits.clear();
0024 }
0025
0026 void TrkrHitSetv1::identify(std::ostream& os) const
0027 {
0028 const unsigned int layer = TrkrDefs::getLayer(m_hitSetKey);
0029 const unsigned int trkrid = TrkrDefs::getTrkrId(m_hitSetKey);
0030 os
0031 << "TrkrHitSetv1: "
0032 << " hitsetkey " << getHitSetKey()
0033 << " TrkrId " << trkrid
0034 << " layer " << layer
0035 << " nhits: " << m_hits.size()
0036 << std::endl;
0037
0038 for (const auto& entry : m_hits)
0039 {
0040 std::cout << " hitkey " << entry.first << std::endl;
0041 (entry.second)->identify(os);
0042 }
0043 }
0044
0045 void TrkrHitSetv1::removeHit(TrkrDefs::hitkey key)
0046 {
0047 const auto it = m_hits.find(key);
0048 if (it != m_hits.end())
0049 {
0050 delete it->second;
0051 m_hits.erase(it);
0052 }
0053 else
0054 {
0055 identify();
0056 std::cout << "TrkrHitSetv1::removeHit: deleting a nonexist key: " << key << " exiting now" << std::endl;
0057 exit(1);
0058 }
0059 }
0060
0061 TrkrHitSetv1::ConstIterator
0062 TrkrHitSetv1::addHitSpecificKey(const TrkrDefs::hitkey key, TrkrHit* hit)
0063 {
0064 const auto ret = m_hits.insert(std::make_pair(key, hit));
0065 if (!ret.second)
0066 {
0067 std::cout << "TrkrHitSetv1::AddHitSpecificKey: duplicate key: " << key << " exiting now" << std::endl;
0068 exit(1);
0069 }
0070 else
0071 {
0072 return ret.first;
0073 }
0074 }
0075
0076 TrkrHit*
0077 TrkrHitSetv1::getHit(const TrkrDefs::hitkey key) const
0078 {
0079 TrkrHitSetv1::ConstIterator it = m_hits.find(key);
0080
0081 if (it != m_hits.end())
0082 {
0083 return it->second;
0084 }
0085 else
0086 {
0087 return nullptr;
0088 }
0089 }
0090
0091 TrkrHitSetv1::ConstRange
0092 TrkrHitSetv1::getHits() const
0093 {
0094 return std::make_pair(m_hits.cbegin(), m_hits.cend());
0095 }