Analysis Software
Documentation for sPHENIX simulation 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 
18  for(auto&& [key, hit] : m_hits)
19  { delete hit; }
20 
21  m_hits.clear();
22 
23 }
24 
25 void TrkrHitSetv1::identify(std::ostream& os) const
26 {
27  const unsigned int layer = TrkrDefs::getLayer(m_hitSetKey);
28  const unsigned int trkrid = TrkrDefs::getTrkrId(m_hitSetKey);
29  os
30  << "TrkrHitSetv1: "
31  << " hitsetkey " << getHitSetKey()
32  << " TrkrId " << trkrid
33  << " layer " << layer
34  << " nhits: " << m_hits.size()
35  << std::endl;
36 
37  for( const auto& entry : m_hits )
38  {
39  std::cout << " hitkey " << entry.first << std::endl;
40  (entry.second)->identify(os);
41  }
42 }
43 
45 {
46  const auto it = m_hits.find(key);
47  if (it != m_hits.end())
48  {
49  delete it->second;
50  m_hits.erase(it);
51  } else {
52  identify();
53  std::cout << "TrkrHitSetv1::removeHit: deleting a nonexist key: " << key << " exiting now" << std::endl;
54  exit(1);
55  }
56 }
57 
60 {
61  const auto ret = m_hits.insert(std::make_pair(key, hit));
62  if ( !ret.second )
63  {
64  std::cout << "TrkrHitSetv1::AddHitSpecificKey: duplicate key: " << key << " exiting now" << std::endl;
65  exit(1);
66  } else {
67  return ret.first;
68  }
69 }
70 
71 TrkrHit*
73 {
75 
76  if (it != m_hits.end()) return it->second;
77  else return nullptr;
78 }
79 
82 {
83  return std::make_pair(m_hits.cbegin(), m_hits.cend());
84 }