ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrHitSetv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrHitSetv1.cc
1 
7 #include "TrkrHitSetv1.h"
8 #include "TrkrHit.h"
9 
10 #include <cstdlib> // for exit
11 #include <iostream>
12 #include <type_traits> // for __decay_and_strip<>::__type
13 
15 {
16  m_hitSetKey = TrkrDefs::HITSETKEYMAX;
17  for( const auto& pair:m_hits )
18  { delete pair.second; }
19 
20  m_hits.clear();
21  return;
22 }
23 
24 void TrkrHitSetv1::identify(std::ostream& os) const
25 {
26  const unsigned int layer = TrkrDefs::getLayer(m_hitSetKey);
27  const unsigned int trkrid = TrkrDefs::getTrkrId(m_hitSetKey);
28  os
29  << "TrkrHitSetv1: "
30  << " hitsetkey " << getHitSetKey()
31  << " TrkrId " << trkrid
32  << " layer " << layer
33  << " nhits: " << m_hits.size()
34  << std::endl;
35 
36  for( const auto& entry : m_hits )
37  {
38  std::cout << " hitkey " << entry.first << std::endl;
39  (entry.second)->identify(os);
40  }
41 }
42 
44 {
45  const auto it = m_hits.find(key);
46  if (it != m_hits.end())
47  {
48  delete it->second;
49  m_hits.erase(it);
50  } else {
51  identify();
52  std::cout << "TrkrHitSetv1::removeHit: deleting a nonexist key: " << key << " exiting now" << std::endl;
53  exit(1);
54  }
55 }
56 
59 {
60  const auto ret = m_hits.insert(std::make_pair(key, hit));
61  if ( !ret.second )
62  {
63  std::cout << "TrkrHitSetv1::AddHitSpecificKey: duplicate key: " << key << " exiting now" << std::endl;
64  exit(1);
65  } else {
66  return ret.first;
67  }
68 }
69 
70 TrkrHit*
72 {
74 
75  if (it != m_hits.end()) return it->second;
76  else return nullptr;
77 }
78 
81 {
82  return std::make_pair(m_hits.cbegin(), m_hits.cend());
83 }