Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHCosmicSeedCombiner.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHCosmicSeedCombiner.cc
1 
2 #include "PHCosmicSeedCombiner.h"
3 
6 #include <phool/PHDataNode.h>
7 #include <phool/PHNode.h>
8 #include <phool/PHNodeIterator.h>
9 #include <phool/PHObject.h>
10 #include <phool/getClass.h>
11 #include <phool/phool.h>
12 
16 
17 #include <trackbase/ActsGeometry.h>
18 #include <trackbase/TrkrCluster.h>
20 
21 #include <phool/PHCompositeNode.h>
22 
23 //____________________________________________________________________________..
25  : SubsysReco(name)
26 {
27 }
28 
29 //____________________________________________________________________________..
31 {
32 }
33 
34 //____________________________________________________________________________..
36 {
38 }
39 
40 //____________________________________________________________________________..
42 {
43  return getNodes(topNode);
44 }
45 
46 //____________________________________________________________________________..
48 {
49  for (auto trackiter = m_seedMap->begin(); trackiter != m_seedMap->end();
50  ++trackiter)
51  {
52  TrackSeed* track1 = *trackiter;
53  if (!track1)
54  {
55  continue;
56  }
57 
58  unsigned int tpcid1 = track1->get_tpc_seed_index();
59  unsigned int siid1 = track1->get_silicon_seed_index();
60 
61  if (Verbosity() > 1)
62  {
63  std::cout << "tpc id" << tpcid1 << std::endl;
64  }
65 
66  auto tpcseed1 = m_tpcSeeds->get(tpcid1);
67  auto silseed1 = m_siliconSeeds->get(siid1);
68 
69  const float phi1 = tpcseed1->get_phi(m_clusterContainer, m_tGeometry);
70  const float eta1 = tpcseed1->get_eta();
71 
72  for (auto trackiter2 = trackiter; trackiter2 != m_seedMap->end(); ++trackiter2)
73  {
74  if (trackiter == trackiter2) continue;
75  TrackSeed* track2 = *trackiter2;
76  if (!track2)
77  {
78  continue;
79  }
80 
81  unsigned int tpcid2 = track2->get_tpc_seed_index();
82  unsigned int siid2 = track2->get_silicon_seed_index();
83 
84  if (Verbosity() > 1)
85  {
86  std::cout << "tpc 2 " << tpcid2 << std::endl;
87  }
88 
89  auto tpcseed2 = m_tpcSeeds->get(tpcid2);
90  auto silseed2 = m_siliconSeeds->get(siid2);
91  const float phi2 = tpcseed2->get_phi(m_clusterContainer, m_tGeometry);
92  const float eta2 = tpcseed2->get_eta();
93 
95  float dphi = phi1 - phi2;
96  if (dphi > M_PI)
97  {
98  dphi -= 2. * M_PI;
99  }
100  else if (dphi < -1 * M_PI)
101  {
102  dphi += 2. * M_PI;
103  }
105  dphi = fabs(dphi) - M_PI;
106 
108  const float deta = eta1 + eta2;
109  if (Verbosity() > 3)
110  {
111  std::cout << "phi 1 and phi2 " << phi1 << " , " << phi2 << std::endl;
112  std::cout << "eta 1 and eta2 " << eta1 << " , " << eta2 << std::endl;
113  std::cout << "dphi and deta " << dphi << " , " << deta << std::endl;
114  }
115  if (fabs(dphi) < m_dphiCut && fabs(deta) < m_detaCut)
116  {
119  addKeys(tpcseed1, tpcseed2);
120  if (silseed1)
121  {
122  if (silseed2)
123  {
124  addKeys(silseed1, silseed2);
125  }
126  }
127  else
128  {
129  if (silseed2)
130  {
131  track1->set_silicon_seed_index(siid2);
132  }
133  }
134 
135  m_seedMap->erase(m_seedMap->index(trackiter2));
136  }
137  if (Verbosity() > 3)
138  {
139  track1->identify();
140  tpcseed1->identify();
141  if (silseed1)
142  {
143  silseed1->identify();
144  }
145  }
146  }
147  }
148 
150 }
151 void PHCosmicSeedCombiner::addKeys(TrackSeed* seedToAddTo, TrackSeed* seedToAdd)
152 {
153  for (auto citer = seedToAdd->begin_cluster_keys();
154  citer != seedToAdd->end_cluster_keys();
155  ++citer)
156  {
157  seedToAddTo->insert_cluster_key(*citer);
158  }
159 }
160 //____________________________________________________________________________..
162 {
164 }
166 {
167  m_tpcSeeds = findNode::getClass<TrackSeedContainer>(topNode, "TpcTrackSeedContainer");
168  if (!m_tpcSeeds)
169  {
170  std::cout << PHWHERE << "TpcTrackSeedContainer not on node tree. Bailing"
171  << std::endl;
173  }
174 
175  m_siliconSeeds = findNode::getClass<TrackSeedContainer>(topNode, "SiliconTrackSeedContainer");
176  if (!m_siliconSeeds)
177  {
178  std::cout << PHWHERE << "SiliconTrackSeedContainer not on node tree. Bailing"
179  << std::endl;
181  }
182 
183  m_clusterContainer = findNode::getClass<TrkrClusterContainer>(topNode, "TRKR_CLUSTER");
184  if (!m_clusterContainer)
185  {
186  std::cout << PHWHERE
187  << "No trkr cluster container, exiting." << std::endl;
189  }
190 
191  m_tGeometry = findNode::getClass<ActsGeometry>(topNode, "ActsGeometry");
192  if (!m_tGeometry)
193  {
194  std::cout << "ActsGeometry not on node tree. Exiting."
195  << std::endl;
196 
198  }
199 
200  m_seedMap = findNode::getClass<TrackSeedContainer>(topNode, "SvtxTrackSeedContainer");
201  if (!m_seedMap)
202  {
203  std::cout << "No Svtx seed map on node tree. Exiting."
204  << std::endl;
206  }
207 
209 }