Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrClusterHitAssocv2.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrClusterHitAssocv2.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  for (unsigned int layer = 0; layer < max_layer; layer++)
22  {
23  for (unsigned int phi_segment = 0; phi_segment < max_phisegment; phi_segment++)
24  {
25  for (unsigned int z_segment = 0; z_segment < max_zsegment; z_segment++)
26  {
27  m_map[layer][phi_segment][z_segment].clear();
28  }
29  }
30  }
31 }
32 
33 //_________________________________________________________________________
34 void TrkrClusterHitAssocv2::identify(std::ostream& os) const
35 {
36  std::multimap<TrkrDefs::cluskey, TrkrDefs::hitkey>::const_iterator iter;
37  os << "-----TrkrClusterHitAssocv2-----" << std::endl;
38  os << "Number of associations: " << size() << std::endl;
39  for (unsigned int layer = 0; layer < max_layer; layer++)
40  {
41  for (unsigned int phi_segment = 0; phi_segment < max_phisegment; phi_segment++)
42  {
43  for (unsigned int z_segment = 0; z_segment < max_zsegment; z_segment++)
44  {
45  for (const auto& pair : m_map[layer][phi_segment][z_segment])
46  {
47  os << "clus key " << pair.first << std::dec
48  << " layer " << TrkrDefs::getLayer(pair.first)
49  << " hit key: " << pair.second << std::endl;
50  }
51  }
52  }
53  }
54  os << "------------------------------" << std::endl;
55 
56  return;
57 }
58 
59 //_________________________________________________________________________
61 {
62  unsigned int layer = TrkrDefs::getLayer(ckey);
63  unsigned int sector = TrkrDefs::getPhiElement(ckey);
64  unsigned int side = TrkrDefs::getZElement(ckey);
65 
66  // bound check
67  if (layer < max_layer && sector < max_phisegment && side < max_zsegment)
68  {
69  m_map[layer][sector][side].insert(std::make_pair(ckey, hidx));
70  }
71  else
72  {
73  std::cout
74  << "TrkrClusterHitAssocv2::addAssoc - out of range access."
75  << " layer: " << layer
76  << " sector: " << sector
77  << " side: " << side
78  << std::endl;
79  }
80 }
81 
82 //_________________________________________________________________________
84 {
85  unsigned int layer = TrkrDefs::getLayer(hitsetkey);
86  unsigned int sector = TrkrDefs::getPhiElement(hitsetkey);
87  unsigned int side = TrkrDefs::getZElement(hitsetkey);
88 
89  // bound check
90  if (layer < max_layer && sector < max_phisegment && side < max_zsegment)
91  {
92  return &m_map[layer][sector][side];
93  }
94  else
95  {
96  std::cout
97  << "TrkrClusterHitAssocv2::getClusterMap - out of range access."
98  << " layer: " << layer
99  << " sector: " << sector
100  << " side: " << side
101  << std::endl;
102  return nullptr;
103  }
104 }
105 
106 //_________________________________________________________________________
108 {
109  unsigned int layer = TrkrDefs::getLayer(ckey);
110  unsigned int sector = TrkrDefs::getPhiElement(ckey);
111  unsigned int side = TrkrDefs::getZElement(ckey);
112 
113  // bound check
114  if (layer < max_layer && sector < max_phisegment && side < max_zsegment)
115  {
116  return std::make_pair(m_map[layer][sector][side].lower_bound(ckey), m_map[layer][sector][side].upper_bound(ckey));
117  }
118  else
119  {
120  std::cout
121  << "TrkrClusterHitAssocv2::getHits - out of range access."
122  << " layer: " << layer
123  << " sector: " << sector
124  << " side: " << side
125  << std::endl;
126  return std::make_pair(dummy_map.cbegin(), dummy_map.cend());
127  }
128 }
129 
130 //_________________________________________________________________________
131 unsigned int TrkrClusterHitAssocv2::size() const
132 {
133  unsigned int size = 0;
134  for (unsigned layer = 0; layer < max_layer; layer++)
135  {
136  for (unsigned phi_segment = 0; phi_segment < max_phisegment; phi_segment++)
137  {
138  for (unsigned z_segment = 0; z_segment < max_zsegment; z_segment++)
139  {
140  size += m_map[layer][phi_segment][z_segment].size();
141  }
142  }
143  }
144 
145  return size;
146 }