Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrClusterHitAssocv3.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrClusterHitAssocv3.cc
1 
9 #include "TrkrDefs.h"
10 
11 #include <ostream> // for operator<<, endl, basic_ostream, ostream, basic_o...
12 
13 namespace
14 {
16 }
17 
18 //_________________________________________________________________________
20 {
21  std::map<TrkrDefs::hitsetkey, Map> empty_map;
22  m_map.swap(empty_map);
23 }
24 //_________________________________________________________________________
25 void TrkrClusterHitAssocv3::identify(std::ostream& os) const
26 {
27  std::multimap<TrkrDefs::cluskey, TrkrDefs::hitkey>::const_iterator iter;
28  os << "-----TrkrClusterHitAssocv3-----" << std::endl;
29  os << "Number of associations: " << size() << std::endl;
30  for (const auto& map_pair : m_map)
31  {
32  for (const auto& pair : map_pair.second)
33  {
34  os << "clus key " << pair.first << std::dec
35  << " layer " << (unsigned int) TrkrDefs::getLayer(pair.first)
36  << " hit key: " << pair.second << std::endl;
37  }
38  }
39  os << "------------------------------" << std::endl;
40 
41  return;
42 }
43 
44 //_________________________________________________________________________
46 {
47  // get hitset key from cluster
49 
50  // find relevant association map, create one if not found
51  Map& clusterMap = m_map[hitsetkey];
52 
53  // insert association
54  clusterMap.insert(std::make_pair(ckey, hidx));
55 }
56 
57 //_________________________________________________________________________
59 {
60  // find relevant association map, create one if not found, and return adress
61  return &m_map[hitsetkey];
62 }
63 
64 //_________________________________________________________________________
66 {
67  // get hitset key from cluster
69 
70  // find relevant association map, create one if not found
71  const auto iter = m_map.find(hitsetkey);
72  if (iter != m_map.end())
73  {
74  return std::make_pair(iter->second.lower_bound(ckey), iter->second.upper_bound(ckey));
75  }
76  else
77  {
78  return std::make_pair(dummy_map.cbegin(), dummy_map.cend());
79  }
80 }
81 
82 //_________________________________________________________________________
83 unsigned int TrkrClusterHitAssocv3::size() const
84 {
85  unsigned int size = 0;
86  for (const auto& map_pair : m_map)
87  {
88  size += map_pair.second.size();
89  }
90 
91  return size;
92 }