Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackAnalysisUtils.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackAnalysisUtils.cc
1 #include "TrackAnalysisUtils.h"
2 
3 #include <cmath>
4 #include "SvtxTrack.h"
5 
6 namespace TrackAnalysisUtils
7 {
8 
11  {
13  if (!track)
14  {
15  std::cout << "You passed a nullptr, can't calculate DCA" << std::endl;
16  return pair;
17  }
18 
19  Acts::Vector3 pos(track->get_x(),
20  track->get_y(),
21  track->get_z());
22  Acts::Vector3 mom(track->get_px(),
23  track->get_py(),
24  track->get_pz());
25 
26  pos -= vertex;
27 
29  for (int i = 0; i < 3; ++i)
30  {
31  for (int j = 0; j < 3; ++j)
32  {
33  posCov(i, j) = track->get_error(i, j);
34  }
35  }
36 
37  Acts::Vector3 r = mom.cross(Acts::Vector3(0., 0., 1.));
38  float phi = atan2(r(1), r(0));
39  phi *= -1;
42  rot(0, 0) = std::cos(phi);
43  rot(0, 1) = -std::sin(phi);
44  rot(0, 2) = 0;
45  rot(1, 0) = std::sin(phi);
46  rot(1, 1) = std::cos(phi);
47  rot(1, 2) = 0;
48  rot(2, 0) = 0;
49  rot(2, 1) = 0;
50  rot(2, 2) = 1;
51 
52  rot_T = rot.transpose();
53 
54  Acts::Vector3 pos_R = rot * pos;
55  Acts::ActsSquareMatrix<3> rotCov = rot * posCov * rot_T;
57  pair.first.first = pos_R(0);
58  pair.first.second = sqrt(rotCov(0, 0));
59 
61  pair.second.first = pos_R(2);
62  pair.second.second = sqrt(rotCov(2, 2));
63 
64  return pair;
65  }
66 
67  std::vector<TrkrDefs::cluskey> get_cluster_keys(SvtxTrack* track)
68  {
69  std::vector<TrkrDefs::cluskey> out;
70  for (const auto& seed : {track->get_silicon_seed(), track->get_tpc_seed()})
71  {
72  if (seed)
73  {
74  std::copy(seed->begin_cluster_keys(), seed->end_cluster_keys(), std::back_inserter(out));
75  }
76  }
77  return out;
78  }
79 
80 } // namespace TrackAnalysisUtils