EIC 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  for(unsigned int phi_segment = 0;phi_segment < max_phisegment;phi_segment++)
23  for(unsigned int z_segment = 0; z_segment < max_zsegment; z_segment++)
24  { m_map[layer][phi_segment][z_segment].clear(); }
25 }
26 
27 //_________________________________________________________________________
28 void TrkrClusterHitAssocv2::identify(std::ostream &os) const
29 {
30  std::multimap<TrkrDefs::cluskey, TrkrDefs::hitkey>::const_iterator iter;
31  os << "-----TrkrClusterHitAssocv2-----" << std::endl;
32  os << "Number of associations: " << size() << std::endl;
33  for(unsigned int layer = 0;layer < max_layer; layer++)
34  for(unsigned int phi_segment = 0;phi_segment < max_phisegment;phi_segment++)
35  for(unsigned int z_segment = 0; z_segment < max_zsegment; z_segment++)
36  {
37  for( const auto& pair:m_map[layer][phi_segment][z_segment] )
38  {
39  int layer = TrkrDefs::getLayer(pair.first);
40  os << "clus key " << pair.first << std::dec
41  << " layer " << layer
42  << " hit key: " << pair.second << std::endl;
43  }
44  }
45  os << "------------------------------" << std::endl;
46 
47  return;
48 
49 }
50 
51 //_________________________________________________________________________
53 {
54  unsigned int layer = TrkrDefs::getLayer(ckey);
55  unsigned int sector = TrkrDefs::getPhiElement(ckey);
56  unsigned int side = TrkrDefs::getZElement(ckey);
57 
58  // bound check
59  if( layer < max_layer && sector < max_phisegment && side < max_zsegment )
60  {
61  m_map[layer][sector][side].insert(std::make_pair(ckey, hidx));
62  } else {
63  std::cout
64  << "TrkrClusterHitAssocv2::addAssoc - out of range access."
65  << " layer: " << layer
66  << " sector: " << sector
67  << " side: " << side
68  << std::endl;
69  }
70 }
71 
72 //_________________________________________________________________________
74 {
75  unsigned int layer = TrkrDefs::getLayer(hitsetkey);
76  unsigned int sector = TrkrDefs::getPhiElement(hitsetkey);
77  unsigned int side = TrkrDefs::getZElement(hitsetkey);
78 
79  // bound check
80  if( layer < max_layer && sector < max_phisegment && side < max_zsegment )
81  {
82  return &m_map[layer][sector][side];
83  } else {
84  std::cout
85  << "TrkrClusterHitAssocv2::getClusterMap - out of range access."
86  << " layer: " << layer
87  << " sector: " << sector
88  << " side: " << side
89  << std::endl;
90  return nullptr;
91  }
92 }
93 
94 //_________________________________________________________________________
96 {
97  unsigned int layer = TrkrDefs::getLayer(ckey);
98  unsigned int sector = TrkrDefs::getPhiElement(ckey);
99  unsigned int side = TrkrDefs::getZElement(ckey);
100 
101  // bound check
102  if( layer < max_layer && sector < max_phisegment && side < max_zsegment )
103  {
104  return std::make_pair( m_map[layer][sector][side].lower_bound(ckey), m_map[layer][sector][side].upper_bound(ckey) );
105  } else {
106  std::cout
107  << "TrkrClusterHitAssocv2::getHits - out of range access."
108  << " layer: " << layer
109  << " sector: " << sector
110  << " side: " << side
111  << std::endl;
112  return std::make_pair(dummy_map.cbegin(), dummy_map.cend() );
113  }
114 }
115 
116 //_________________________________________________________________________
117 unsigned int TrkrClusterHitAssocv2::size() const
118 {
119  unsigned int size = 0;
120  for(unsigned layer = 0;layer < max_layer; layer++)
121  for(unsigned phi_segment = 0;phi_segment < max_phisegment;phi_segment++)
122  for(unsigned z_segment = 0; z_segment < max_zsegment; z_segment++)
123  { size += m_map[layer][phi_segment][z_segment].size(); }
124 
125  return size;
126 }