Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHSiliconSeedMerger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHSiliconSeedMerger.cc
1 
2 #include "PHSiliconSeedMerger.h"
3 
6 #include <phool/getClass.h>
7 #include <phool/phool.h>
8 #include <phool/PHObject.h>
9 #include <phool/PHTimer.h>
10 
11 #include <trackbase/TrkrDefs.h>
12 
15 
16 
17 #include <phool/PHCompositeNode.h>
18 
19 //____________________________________________________________________________..
21  SubsysReco(name)
22 {}
23 
24 //____________________________________________________________________________..
26 {
27 }
28 
29 //____________________________________________________________________________..
31 {
32 
34 }
35 
36 //____________________________________________________________________________..
38 {
39  int ret = getNodes(topNode);
40  return ret;
41 }
42 
43 //____________________________________________________________________________..
45 {
46 
47  std::multimap<unsigned int, std::set<TrkrDefs::cluskey>> matches;
48  std::set<unsigned int> seedsToDelete;
49 
50  if(Verbosity() > 0)
51  {
52  std::cout << "Silicon seed track container has " << m_siliconTracks->size() << std::endl;
53  }
54 
55  for(unsigned int track1ID = 0;
56  track1ID != m_siliconTracks->size();
57  ++track1ID)
58  {
59  TrackSeed* track1 = m_siliconTracks->get(track1ID);
60 
61  if(seedsToDelete.find(track1ID) != seedsToDelete.end())
62  { continue; }
63 
64  std::set<TrkrDefs::cluskey> mvtx1Keys;
66  iter != track1->end_cluster_keys();
67  ++iter)
68  {
69  TrkrDefs::cluskey ckey = *iter;
70  auto trkrid = TrkrDefs::getTrkrId(ckey);
71  if(m_mvtxOnly && trkrid == TrkrDefs::TrkrId::inttId)
72  {
73  continue;
74  }
75 
76  mvtx1Keys.insert(ckey);
77  }
78 
79 
84  for(unsigned int track2ID = track1ID;
85  track2ID != m_siliconTracks->size();
86  ++track2ID)
87  {
88  if(track1ID == track2ID)
89  { continue; }
90 
91  TrackSeed* track2 = m_siliconTracks->get(track2ID);
92  std::set<TrkrDefs::cluskey> mvtx2Keys;
94  iter != track2->end_cluster_keys();
95  ++iter)
96  {
97  TrkrDefs::cluskey ckey = *iter;
98  auto trkrid = TrkrDefs::getTrkrId(ckey);
99  if (m_mvtxOnly && trkrid == TrkrDefs::TrkrId::inttId)
100  {
101  continue;
102  }
103  mvtx2Keys.insert(ckey);
104  }
105 
106  std::vector<TrkrDefs::cluskey> intersection;
107  std::set_intersection(mvtx1Keys.begin(),
108  mvtx1Keys.end(),
109  mvtx2Keys.begin(),
110  mvtx2Keys.end(),
111  std::back_inserter(intersection));
112 
115  if(intersection.size() > m_clusterOverlap)
116  {
117  if(Verbosity() > 2)
118  {
119  std::cout << "Track " << track1ID << " keys " << std::endl;
120  for(auto& key : mvtx1Keys)
121  { std::cout << " ckey: " << key << std::endl; }
122  std::cout << "Track " << track2ID << " keys " << std::endl;
123  for(auto& key : mvtx2Keys)
124  { std::cout << " ckey: " << key << std::endl; }
125  std::cout << "Intersection keys " << std::endl;
126  for(auto& key : intersection)
127  { std::cout << " ckey: " << key << std::endl; }
128  }
129 
130  for(auto& key : mvtx2Keys)
131  {
132  mvtx1Keys.insert(key);
133  }
134 
135  if(Verbosity() > 2)
136  {
137  std::cout << "Match IDed"<<std::endl;
138  for(auto& key : mvtx1Keys)
139  { std::cout << " total track keys " << key << std::endl; }
140  }
141 
142  matches.insert(std::make_pair(track1ID, mvtx1Keys));
143  seedsToDelete.insert(track2ID);
144  break;
145  }
146  }
147  }
148 
149  for(const auto& [trackKey, mvtxKeys] : matches)
150  {
151  auto track = m_siliconTracks->get(trackKey);
152  if(Verbosity() > 2)
153  { std::cout << "original track: " << std::endl; track->identify(); }
154 
155  for(auto& key : mvtxKeys)
156  {
157  if(track->find_cluster_key(key) == track->end_cluster_keys())
158  {
159  track->insert_cluster_key(key);
160  if(Verbosity() > 2)
161  std::cout << "adding " << key << std::endl;
162  }
163  }
164 
165  }
166 
167  for(const auto& key : seedsToDelete)
168  {
169  if(Verbosity() > 2 )
170  { std::cout << "Erasing track " << key << std::endl; }
171  m_siliconTracks->erase(key);
172  }
173 
174  if(Verbosity() > 2)
175  {
176  for(const auto& seed : *m_siliconTracks)
177  {
178  if (!seed) continue;
179  seed->identify();
180  }
181  }
182 
184 }
185 
186 //____________________________________________________________________________..
188 {
189 
191 }
192 
193 
194 
195 //____________________________________________________________________________..
197 {
198 
200 }
201 
203 {
204  m_siliconTracks = findNode::getClass<TrackSeedContainer>(topNode, m_trackMapName.c_str());
205  if(!m_siliconTracks)
206  {
207  std::cout << PHWHERE << "No silicon track container, can't merge seeds"
208  << std::endl;
210  }
211 
213 }
214