FairRoot/PandaRoot
Public Member Functions | List of all members
PndTrkTools Class Reference

#include <PndTrkTools.h>

Inheritance diagram for PndTrkTools:

Public Member Functions

 PndTrkTools ()
 
 ~PndTrkTools ()
 
void ComputeLinePointOfTangenceOnACircle (double m, double xc, double yc, double R, double &xi1, double &yi1, double &xi2, double &yi2)
 
TVector2 ComputePocaToPointOnCircle2 (double x, double y, double xc, double yc, double R)
 
TVector3 ComputePocaToPointOnCircle3 (double x, double y, double xc, double yc, double R)
 
TVector2 ComputePocaToLineOnCircle (double m, double q, double xc, double yc, double R)
 
Int_t ComputeSegmentCircleIntersection (TVector2 ex1, TVector2 ex2, double xc, double yc, double R, TVector2 &intersection1, TVector2 &intersection2)
 
TVector2 ComputeTangentInPoint (double xc, double yc, TVector2 point)
 
void ComputeTangentInPoint (double xc, double yc, TVector2 point, double &m, double &p)
 
 ClassDef (PndTrkTools, 1)
 

Detailed Description

PndTrkTools

Author
Lia Lavezzi

Definition at line 14 of file PndTrkTools.h.

Constructor & Destructor Documentation

PndTrkTools::PndTrkTools ( )

Definition at line 17 of file PndTrkTools.cxx.

17 {}
PndTrkTools::~PndTrkTools ( )

Definition at line 18 of file PndTrkTools.cxx.

18 {}

Member Function Documentation

PndTrkTools::ClassDef ( PndTrkTools  ,
 
)
void PndTrkTools::ComputeLinePointOfTangenceOnACircle ( double  m,
double  xc,
double  yc,
double  R,
double &  xi1,
double &  yi1,
double &  xi2,
double &  yi2 
)

Definition at line 23 of file PndTrkTools.cxx.

References CAMath::Sqrt().

23  {
24  // there are two points where the line is tangent
25  xi1 = xc + m * R / TMath::Sqrt(m * m + 1);
26  yi1 = yc - R / TMath::Sqrt(m * m + 1);
27 
28  xi2 = xc - m * R / TMath::Sqrt(m * m + 1);
29  yi2 = yc + R / TMath::Sqrt(m * m + 1);
30 
31 }
__m128 m
Definition: P4_F32vec4.h:28
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Double_t R
Definition: checkhelixhit.C:61
TVector2 PndTrkTools::ComputePocaToLineOnCircle ( double  m,
double  q,
double  xc,
double  yc,
double  R 
)

Definition at line 60 of file PndTrkTools.cxx.

References fabs().

60  {
61  // there are two points where the line is tangent
62  // to the circle
63  double xi1, yi1, xi2, yi2;
64  ComputeLinePointOfTangenceOnACircle(m, xc, yc, R, xi1, yi1, xi2, yi2);
65 
66  // I want the nearest to the line
67  double xp = 999, yp = -999;
68  fabs(yi1 - (m * xi1 + q)) < fabs(yi2 - (m * xi2 + q)) ? (xp = xi1, yp = yi1) : (xp = xi2 , yp = yi2);
69 
70  return TVector2(xp, yp);
71 }
__m128 m
Definition: P4_F32vec4.h:28
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
void ComputeLinePointOfTangenceOnACircle(double m, double xc, double yc, double R, double &xi1, double &yi1, double &xi2, double &yi2)
Definition: PndTrkTools.cxx:23
Double_t R
Definition: checkhelixhit.C:61
TVector2 PndTrkTools::ComputePocaToPointOnCircle2 ( double  x,
double  y,
double  xc,
double  yc,
double  R 
)

Definition at line 36 of file PndTrkTools.cxx.

References m, and sqrt().

Referenced by PndTrkCombiLegendreTask::CreateClusterAroundTrack2().

36  {
37  // line which pass in P and C(xc, yc)
38  double m = (y - yc)/(x - xc);
39  // its perpendicular --> tangent in the poca I am searching
40  double mperp = -1./m;
41 
42  double xi1, yi1, xi2, yi2;
43  ComputeLinePointOfTangenceOnACircle(mperp, xc, yc, R, xi1, yi1, xi2, yi2);
44 
45  // I want the nearest to P
46  double xp = 999, yp = -999;
47 
48  sqrt((xi1 - x) * (xi1 - x) + (yi1 - y) * (yi1 - y)) < sqrt((xi2 - x) * (xi2 - x) + (yi2 - y) * (yi2 - y)) ? (xp = xi1 , yp = yi1) : (xp = xi2 , yp = yi2);
49  return TVector2(xp, yp);
50 }
__m128 m
Definition: P4_F32vec4.h:28
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
void ComputeLinePointOfTangenceOnACircle(double m, double xc, double yc, double R, double &xi1, double &yi1, double &xi2, double &yi2)
Definition: PndTrkTools.cxx:23
Double_t x
Double_t y
Double_t R
Definition: checkhelixhit.C:61
TVector3 PndTrkTools::ComputePocaToPointOnCircle3 ( double  x,
double  y,
double  xc,
double  yc,
double  R 
)

Definition at line 52 of file PndTrkTools.cxx.

References vec.

Referenced by PndTrkTrack::ComputeCharge(), and PndTrkTrack::ComputeMomentumAtPosition().

52  {
53  TVector2 vec = ComputePocaToPointOnCircle2(x, y, xc, yc, R);
54  return TVector3(vec.X(), vec.Y(), 0.0);
55 }
TVector2 ComputePocaToPointOnCircle2(double x, double y, double xc, double yc, double R)
Definition: PndTrkTools.cxx:36
Double_t x
Double_t y
Double_t R
Definition: checkhelixhit.C:61
dble_vec_t vec[12]
Definition: ranlxd.cxx:380
Int_t PndTrkTools::ComputeSegmentCircleIntersection ( TVector2  ex1,
TVector2  ex2,
double  xc,
double  yc,
double  R,
TVector2 &  intersection1,
TVector2 &  intersection2 
)

Definition at line 77 of file PndTrkTools.cxx.

References m, p, and sqrt().

Referenced by PndTrkLegendreSecTask::CreateSkewHitList(), PndTrkLegendreTask::CreateSkewHitList(), PndTrkLegendreSecTask2::CreateSkewHitList(), PndTrkTrackFinder::CreateSkewHitList(), and PndTrkTrackFinder::Exec().

77  {
78 
79  double xa, ya, xb, yb;
80  double delta;
81  // ex1.Print();
82  // ex2.Print();
83  // cout << xc << " " << yc << " " << R << endl;
84 
85  if((ex2.X() - ex1.X()) != 0) {
86  double m = (ex2.Y() - ex1.Y())/(ex2.X() - ex1.X());
87  double p = ex2.Y() - m * ex2.X();;
88 
89  delta = - (m * xc + p - yc) * (m * xc + p - yc) + R * R * (m * m + 1);
90  // cout << "delta " << delta << endl;
91  if(delta < 0 || TMath::IsNaN(delta)) return 0;
92  xa = (-(m * (p - yc) - xc) + sqrt(delta))/(m * m + 1);
93  ya = m * xa + p;
94  xb = (-(m * (p - yc) - xc) - sqrt(delta))/(m * m + 1);
95  yb = m * xb + p;
96  }
97  else {
98  // (x - xc)**2 + (y -yc)**2 = R**2
99  // y**2 - 2yc y + x**2 + xc**2 - 2xc x + yc**2 - R**2 = 0;
100  // y = yc +/- sqrt(R**2 -(x - xc)**2)
101  delta = R * R - (ex1.X() - xc) * (ex1.X() - xc);
102  // cout << "// to y, delta " << delta << endl;
103  if(delta < 0 || TMath::IsNaN(delta)) return 0;
104 
105  xa = ex1.X();
106  ya = yc + sqrt(delta);
107  xb = ex1.X();
108  yb = yc - sqrt(delta);
109  }
110 
111  TVector2 int1(xa, ya);
112  TVector2 int2(xb, yb);
113 
114  TVector2 distance11 = int1 - ex1;
115  TVector2 distance12 = int1 - ex2;
116 
117  TVector2 distance21 = int2 - ex1;
118  TVector2 distance22 = int2 - ex2;
119 
120  TVector2 length = ex1 - ex2;
121  Int_t found = 0;
122  // cout << distance11.Mod() << " " << distance12.Mod() << " " << length.Mod() << endl;
123  // cout << distance21.Mod() << " " << distance22.Mod() << " " << length.Mod() << endl;
124  if(distance11.Mod() < length.Mod() && distance12.Mod() < length.Mod()) {
125  // cout << "intersection 1" << endl;
126  // TMarker *mrka = new TMarker(xa, ya, 20);
127  // mrka->Draw("SAME");
128  found++;
129  intersection1 = int1;
130  }
131 
132  if(distance22.Mod() < length.Mod() && distance21.Mod() < length.Mod()) {
133  // cout << "intersection 2" << endl;
134  // TMarker *mrkb = new TMarker(xb, yb, 22);
135  // mrkb->Draw("SAME");
136  if(found == 1) intersection2 = int2;
137  else intersection1 = int2;
138  found++;
139  }
140 
141  // if delta = 0 we have two identical intersections
142  if(delta == 0) found--; // CHECK
143  return found;
144 }
Double_t p
Definition: anasim.C:58
__m128 m
Definition: P4_F32vec4.h:28
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t R
Definition: checkhelixhit.C:61
TVector2 PndTrkTools::ComputeTangentInPoint ( double  xc,
double  yc,
TVector2  point 
)

Definition at line 149 of file PndTrkTools.cxx.

Referenced by PndTrkLegendreSecTask::CreateSkewHitList(), PndTrkLegendreTask::CreateSkewHitList(), PndTrkLegendreSecTask2::CreateSkewHitList(), PndTrkTrackFinder::CreateSkewHitList(), and PndTrkTrackFinder::Exec().

149  {
150  TVector2 center(xc, yc);
151  TVector2 fromcentertoint = point - center;
152  TVector2 tangent(fromcentertoint.Y(), -fromcentertoint.X()); // CHECK
153  return tangent;
154 }
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72
void PndTrkTools::ComputeTangentInPoint ( double  xc,
double  yc,
TVector2  point,
double &  m,
double &  p 
)

Definition at line 156 of file PndTrkTools.cxx.

References CAMath::Tan().

156  {
157  TVector2 tangent = ComputeTangentInPoint(xc, yc, point);
158  m = TMath::Tan(tangent.Phi()); // CHECK this is [0, 2pi] by default
159  p = point.Y() - m * point.X();
160 }
Double_t p
Definition: anasim.C:58
__m128 m
Definition: P4_F32vec4.h:28
float Tan(float x)
Definition: PndCAMath.h:165
TVector2 ComputeTangentInPoint(double xc, double yc, TVector2 point)
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72

The documentation for this class was generated from the following files: