FairRoot/PandaRoot
PndSttTrack.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndSttTrack source file -----
3 // ----- Created 28/03/06 by R. Castelijns -----
4 // -------------------------------------------------------------------------
5 
6 #include "PndSttTrack.h"
7 #include "PndDetectorList.h"
8 #include "TMath.h"
9 
10 #include <iostream>
11 
12 using std::cout;
13 using std::endl;
14 using std::map;
15 
16 // ----- Default constructor -------------------------------------------
18  fHelixHits(TArrayI()),fPidHypo(0), fDist(0.), fPhi(0.), fRad(0.), fTanL(0.), fZ(0.), fH(0), fFlag(0), fChi2Long(0.), fNDF(0), fChi2Rad(0.), fTrackCandIndex(0)
19 {
20 }
21 // -------------------------------------------------------------------------
22 
23 
24 
25 // ----- Destructor ----------------------------------------------------
27 {}
28 // -------------------------------------------------------------------------
29 
30 // ----- Public method Print -------------------------------------------
32 {
33  cout << " Reco track corresponding to track cand: "
34  << fTrackCandIndex << endl;
35  cout << " Parameters of the helix: " << endl;
36  cout << fDist << " " << fPhi << " " << fRad << " " << fTanL << " " << fZ << endl;
37  // cout << "Chi2Long: " << fChi2Long << ", Chi2Rad: " << fChi2Rad << endl;
38  cout << "Quality flag " << fFlag << endl; // CHECK add number of helix hits
39 }
40 // -------------------------------------------------------------------------
41 
42 void PndSttTrack::AddHelixHit(Int_t size, Int_t index, Int_t helixhitindex)
43 {
44  // fHelixHits.Reset();
45  fHelixHits.Set(size);
46  fHelixHits[index] = helixhitindex;
47  AddLink(FairLink("STTHelixHit", helixhitindex));
48 }
49 
50 // =================================================
51 // calculates the pca to (0, 0) in 2D (xy plane)
52 TVector3 *PndSttTrack::PCAToPoint(TVector3 *point){
53 
54  // transverse
55  Double_t R = fRad;
56  Double_t xc = (fDist + fRad) * TMath::Cos(fPhi);
57  Double_t yc = (fDist + fRad) * TMath::Sin(fPhi);
58 
59  // transverse -> circle
60  // 1. find the line joining the point and the centre
61  Double_t m = (yc - point->Y()) / (xc - point->X());
62  Double_t q = yc - m * xc;
63 
64  // 2. find the point on track closest to point
65  // +
66  Double_t x1 = (-(m*(q - yc) - xc) + sqrt((m*(q - yc) - xc)*(m*(q - yc) - xc) - (m*m + 1)*((q - yc)*(q - yc) + xc*xc - R*R))) / (m*m + 1);
67  Double_t y1 = m*x1 + q;
68  // -
69  Double_t x2 = (-(m*(q - yc) - xc) - sqrt((m*(q - yc) - xc)*(m*(q - yc) - xc) - (m*m + 1)*((q - yc)*(q - yc) + xc*xc - R*R))) / (m*m + 1);
70  Double_t y2 = m*x2 + q;
71 
72  Double_t dist1 = sqrt((point->Y() - y1)*(point->Y() - y1) + (point->X() - x1)*(point->X() - x1));
73  Double_t dist2 = sqrt((point->Y() - y2)*(point->Y() - y2) + (point->X() - x2)*(point->X() - x2));
74 
75  TVector3 *clsontrk; // close on track
76  if(dist1 < dist2) clsontrk = new TVector3(x1, y1, 0.);
77  else clsontrk = new TVector3(x2, y2, 0.);
78 
79  // longitudinal: find the z correspondent to the PCA in x, y (CHECK not in 3D!!!)
80  Double_t clstrkln = CalculateScosl(clsontrk->X(), clsontrk->Y());
81  Double_t z0 = fZ;
82  Double_t zslope = fTanL;
83  Double_t z = z0 + zslope * clstrkln;
84  clsontrk->SetZ(z);
85 
86  return clsontrk;
87 }
88 
89 // momentum at a certain point of the helix track
90 TVector3 *PndSttTrack::MomentumAtPoint(TVector3 *point){
91 
92  // transverse momentum ..................................
93  Double_t pt = 0., px = 0., py = 0.;
94 
95  // tangent in point on track
96  Double_t R = fRad;
97  Double_t xc = (fDist + fRad) * TMath::Cos(fPhi);
98  Double_t yc = (fDist + fRad) * TMath::Sin(fPhi);
99  Double_t m = (yc - point->Y()) / (xc - point->X());
100  Double_t mt = -1./m;
101  Double_t alpha = TMath::ATan(mt);
102 
103  pt = 0.006 * R;
104  px = pt * TMath::Cos(alpha);
105  py = pt * TMath::Sin(alpha);
106 
107 
108  // negative NO if point higher than center
109  // positive NO if point lower than center
110  if((fH < 0 && (yc - point->Y()) < 0) || (fH > 0 && (yc - point->Y()) > 0))
111  {
112  px = -px;
113  py = -py;
114  }
115  else if(fH == 0) cout << "NO CHARGE" << endl;
116 
117  // longitudinal momentum ..................................
118  Double_t pl = 0.;
119 
120  Double_t tanl = fTanL;
121  pl = pt * tanl;
122 
123  TVector3 *ptotcl = new TVector3(px, py, pl);
124 
125  return ptotcl;
126 }
127 
128 // track length
130 {
131 
132  Double_t x_0 = (fDist + fRad) * TMath::Cos(fPhi);
133  Double_t y_0 = (fDist + fRad) * TMath::Sin(fPhi);
134 
137 
138  Double_t Phi0 = TMath::ATan2((y0 - y_0),(x0 - x_0));
139 
140  // cout << "calculate Phi0: " << Phi0 << " v0: " << x0 << " " << y0 << endl;
141  // cout << "phi: " << fPhi << " Phi0: " << Phi0 << endl;
142 
143  Double_t scos = -fH * fRad * TMath::ATan2((y - y0) * TMath::Cos(Phi0) - (x - x0) * TMath::Sin(Phi0) , fRad + (x - x0) * TMath::Cos(Phi0) + (y - y0) * TMath::Sin(Phi0));
144 
145  return scos;
146 
147 }
148 
149 
150 
Double_t tanl
Definition: checkhelixhit.C:63
TVector3 * MomentumAtPoint(TVector3 *point)
Definition: PndSttTrack.cxx:90
Double_t z0
Definition: checkhelixhit.C:62
Double_t x0
Definition: checkhelixhit.C:70
Int_t fTrackCandIndex
// CHECK not for now, maybe in future if needed
Definition: PndSttTrack.h:122
Double_t fPhi
Definition: PndSttTrack.h:110
__m128 m
Definition: P4_F32vec4.h:28
PndTransMap * map
Definition: sim_emc_apd.C:99
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
void Print()
Definition: PndSttTrack.cxx:31
static T Sin(const T &x)
Definition: PndCAMath.h:42
Double_t fTanL
Definition: PndSttTrack.h:110
static T Cos(const T &x)
Definition: PndCAMath.h:43
Double_t fZ
Definition: PndCaloDraw.cxx:34
void AddHelixHit(Int_t size, Int_t index, Int_t helixhitindex)
Definition: PndSttTrack.cxx:42
TVector3 * PCAToPoint(TVector3 *point)
Definition: PndSttTrack.cxx:52
Double_t fDist
// CHECK not for now, maybe in future if needed
Definition: PndSttTrack.h:110
TString pt(TString pts, TString exts="px py pz")
Definition: invexp.C:133
TArrayI fHelixHits
Definition: PndSttTrack.h:104
virtual ~PndSttTrack()
Definition: PndSttTrack.cxx:26
Double_t
Double_t y0
Definition: checkhelixhit.C:71
static T ATan2(const T &y, const T &x)
TClonesArray * point
Definition: anaLmdDigi.C:29
Double_t z
Double_t const fPhi
Double_t x
Double_t CalculateScosl(Double_t x, Double_t y)
Double_t fRad
Definition: PndSttTrack.h:110
ClassImp(PndAnaContFact)
Double_t y
double alpha
Definition: f_Init.h:9
Double_t R
Definition: checkhelixhit.C:61
Double_t fZ
Definition: PndSttTrack.h:110