Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrHitSetContainerv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrHitSetContainerv1.cc
1 
8 
9 #include "TrkrDefs.h"
10 #include "TrkrHitSetv1.h"
11 
12 #include <cstdlib>
13 
15 {
16  for(auto&& [key, hitset] : m_hitmap)
17  { delete hitset;}
18 
19  m_hitmap.clear();
20 }
21 
22 void TrkrHitSetContainerv1::identify(std::ostream& os) const
23 {
24  ConstIterator iter;
25  os << "Number of hits: " << size() << std::endl;
26  for( const auto& pair:m_hitmap )
27  {
28  int layer = TrkrDefs::getLayer(pair.first);
29  os << "hitsetkey " << pair.first << " layer " <<layer << std::endl;
30  pair.second->identify();
31  }
32  return;
33 }
34 
37 { return addHitSetSpecifyKey(newhit->getHitSetKey(), newhit); }
38 
41 {
42  const auto ret = m_hitmap.insert(std::make_pair(key, newhit));
43  if ( !ret.second )
44  {
45  std::cout << "TrkrHitSetContainerv1::AddHitSpecifyKey: duplicate key: " << key << " exiting now" << std::endl;
46  exit(1);
47  } else {
48  return ret.first;
49  }
50 }
51 
53 {
54  auto iter = m_hitmap.find( key );
55  if(iter != m_hitmap.end())
56  {
57  TrkrHitSet* hitset = iter->second;
58  delete hitset;
59  m_hitmap.erase(iter);
60  }
61 }
62 
64 { removeHitSet( hitset->getHitSetKey() ); }
65 
68 {
69  const TrkrDefs::hitsetkey keylo = TrkrDefs::getHitSetKeyLo(trackerid);
70  const TrkrDefs::hitsetkey keyhi = TrkrDefs::getHitSetKeyHi(trackerid);
71  return std::make_pair( m_hitmap.lower_bound(keylo), m_hitmap.upper_bound(keyhi) );
72 }
73 
75 TrkrHitSetContainerv1::getHitSets(const TrkrDefs::TrkrId trackerid, const uint8_t layer) const
76 {
77  TrkrDefs::hitsetkey keylo = TrkrDefs::getHitSetKeyLo(trackerid, layer);
78  TrkrDefs::hitsetkey keyhi = TrkrDefs::getHitSetKeyHi(trackerid, layer);
79  return std::make_pair( m_hitmap.lower_bound(keylo), m_hitmap.upper_bound(keyhi) );
80 }
81 
84 { return std::make_pair(m_hitmap.cbegin(), m_hitmap.cend()); }
85 
88 {
89  auto it = m_hitmap.lower_bound( key );
90  if( it == m_hitmap.end() || (key < it->first ) )
91  {
92  it = m_hitmap.insert(it, std::make_pair(key, new TrkrHitSetv1));
93  it->second->setHitSetKey( key );
94  }
95  return it;
96 }
97 
100 {
101  auto it = m_hitmap.find(key);
102  if (it != m_hitmap.end())
103  {
104  return it->second;
105  } else {
106  return nullptr;
107  }
108 }