Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawHitSetContainerv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RawHitSetContainerv1.cc
1 
7 #include "RawHitSetContainerv1.h"
8 
9 #include "TrkrDefs.h"
10 #include "RawHitSetv1.h"
11 
12 #include <cstdlib>
13 
15 {
16  for( const auto& pair:m_hitmap )
17  { delete pair.second; }
18 
19  m_hitmap.clear();
20 }
21 
22 void RawHitSetContainerv1::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 << "RawHitSetContainerv1::AddHitSpecifyKey: duplicate key: " << key << " exiting now" << std::endl;
46  exit(1);
47  } else {
48  return ret.first;
49  }
50 }
51 
53 { m_hitmap.erase(key); }
54 
56 { removeHitSet( hitset->getHitSetKey() ); }
57 
60 {
61  const TrkrDefs::hitsetkey keylo = TrkrDefs::getHitSetKeyLo(trackerid);
62  const TrkrDefs::hitsetkey keyhi = TrkrDefs::getHitSetKeyHi(trackerid);
63  return std::make_pair( m_hitmap.lower_bound(keylo), m_hitmap.upper_bound(keyhi) );
64 }
65 
67 RawHitSetContainerv1::getHitSets(const TrkrDefs::TrkrId trackerid, const uint8_t layer) const
68 {
69  TrkrDefs::hitsetkey keylo = TrkrDefs::getHitSetKeyLo(trackerid, layer);
70  TrkrDefs::hitsetkey keyhi = TrkrDefs::getHitSetKeyHi(trackerid, layer);
71  return std::make_pair( m_hitmap.lower_bound(keylo), m_hitmap.upper_bound(keyhi) );
72 }
73 
76 { return std::make_pair(m_hitmap.cbegin(), m_hitmap.cend()); }
77 
80 {
81  auto it = m_hitmap.lower_bound( key );
82  if( it == m_hitmap.end() || (key < it->first ) )
83  {
84  it = m_hitmap.insert(it, std::make_pair(key, new RawHitSetv1));
85  it->second->setHitSetKey( key );
86  }
87  return it;
88 }
89 
90 RawHitSet*
92 {
93  auto it = m_hitmap.find(key);
94  if (it != m_hitmap.end())
95  {
96  return it->second;
97  } else {
98  return nullptr;
99  }
100 }