Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrTruthTrackv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrTruthTrackv1.cc
1 
7 #include "TrkrTruthTrackv1.h"
8 
9 #include <g4main/PHG4Particle.h>
10 #include <g4main/PHG4VtxPoint.h>
11 
12 #include <TLorentzVector.h>
13 
14 #include <cmath>
15 
16 void TrkrTruthTrackv1::identify(std::ostream& os) const
17 {
18  os << " TrkrTruthTrack: " << std::endl
19  << " trackid(" << trackid << ") [X0,Y0,Z0](" << X0 << "," << Y0 << "," << Z0 << ") "
20  << " [pseudorapidity,pt,phi](" << pseudoRapidity << "," << pt << "," << phi << ")" << std::endl;
21  os << " Clusters HitSetKey(layer) : " << std::endl
22  << " ";
23  int cnt = 0;
24  for (auto cluster : clusters)
25  {
26  if (cnt == 8)
27  {
28  cnt = 0;
29  os << std::endl
30  << " ";
31  }
32  if (cnt > 0)
33  {
34  os << ", ";
35  }
36  uint32_t i_hitsetkey = TrkrDefs::getHitSetKeyFromClusKey(cluster);
37  int layer = TrkrDefs::getLayer(cluster);
38  os << " " << i_hitsetkey << "(" << layer << ")";
39  ++cnt;
40  }
41  if (cnt != 0)
42  {
43  os << std::endl;
44  }
45 }
46 
48  : trackid{UINT_MAX}
49  , X0{NAN}
50  , Y0{NAN}
51  , Z0{NAN}
53  , pt{NAN}
54  , phi{NAN}
56 {
57 }
58 
60  : trackid{_trackid}
61  , clusters{}
62 {
63  X0 = vtx->get_x();
64  Y0 = vtx->get_y();
65  Z0 = vtx->get_z();
66 
67  TLorentzVector v1;
68  v1.SetPxPyPzE(p->get_px(), p->get_py(), p->get_pz(), p->get_e());
69  phi = v1.Phi();
70  pseudoRapidity = v1.PseudoRapidity();
71  pt = v1.Pt();
72 }
73 
75 {
76  clusters.push_back(key);
77 }
78 
79 
81  return std::binary_search(clusters.begin(), clusters.end(), key, CompHitSetKey() );
82 }
83 
85  return std::binary_search(clusters.begin(), clusters.end(), key, CompHitSetKey() );
86 }
87 
88 std::pair<bool, TrkrDefs::cluskey> TrkrTruthTrackv1::get_cluskey(TrkrDefs::hitsetkey hitsetkey) const {
89  auto lb = std::lower_bound(clusters.begin(), clusters.end(), hitsetkey, CompHitSetKey());
90  if (lb == clusters.end() || TrkrDefs::getHitSetKeyFromClusKey(*lb) != hitsetkey) return { false, 0. };
91  else return { true, *lb };
92 }