StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tofPathLength.cc
1  /***************************************************************************
2  *
3  * $Id: tofPathLength.cc,v 1.1 2009/02/11 17:31:14 dongx Exp $
4  *
5  * Author: Frank Geurts
6  ***************************************************************************
7  *
8  * Description: Calculate helix path length between to points.
9  * requires begin and end point StThreeVectors and helix curvature
10  *
11  ***************************************************************************
12  *
13  **************************************************/
14 #include "StThreeVectorD.hh"
15 #include "StThreeVectorF.hh"
16 #include "tofPathLength.hh"
17 
18 // ----------------------------------------------------------------------------------------------
19 #if 0
20 double tofPathLength(const StThreeVectorD* beginPoint, const StThreeVectorD* endPoint, const double curvature){
21  // used in StTofGeometry::tofHelixToArray
22  double x,y,z;
23  x = (double)beginPoint->x();
24  y = (double)beginPoint->y();
25  z = (double)beginPoint->z();
26  StThreeVector<double> bp (x,y,z);
27  x = (double)endPoint->x();
28  y = (double)endPoint->y();
29  z = (double)endPoint->z();
30  StThreeVector<double> ep(x,y,z);
31  return tofPathLength(&bp,&ep,curvature);
32 }
33 #endif
34 
35 double tofPathLength(const StThreeVectorD* beginPoint, const StThreeVectorF* endPoint, const double curvature){
36  double x,y,z;
37  x = (double)beginPoint->x();
38  y = (double)beginPoint->y();
39  z = (double)beginPoint->z();
40  StThreeVector<double> bp (x,y,z);
41  x = (double)endPoint->x();
42  y = (double)endPoint->y();
43  z = (double)endPoint->z();
44  StThreeVector<double> ep(x,y,z);
45  return tofPathLength(&bp,&ep,curvature);
46 }
47 
48 
49 double tofPathLength(const StThreeVectorF* beginPoint, const StThreeVectorD* endPoint, const double curvature){
50  double x,y,z;
51  x = (double)beginPoint->x();
52  y = (double)beginPoint->y();
53  z = (double)beginPoint->z();
54  StThreeVector<double> bp (x,y,z);
55  x = (double)endPoint->x();
56  y = (double)endPoint->y();
57  z = (double)endPoint->z();
58  StThreeVector<double> ep(x,y,z);
59  return tofPathLength(&bp,&ep,curvature);
60 }
61 
62 double tofPathLength(const StThreeVectorF* beginPoint, const StThreeVectorF* endPoint, const double curvature){
63  double x,y,z;
64  x = (double)beginPoint->x();
65  y = (double)beginPoint->y();
66  z = (double)beginPoint->z();
67  StThreeVector<double> bp (x,y,z);
68  x = (double)endPoint->x();
69  y = (double)endPoint->y();
70  z = (double)endPoint->z();
71  StThreeVector<double> ep(x,y,z);
72  return tofPathLength(&bp,&ep,curvature);
73 }
74 
75 // ----------------------------------------------------------------------------------------------
76 double tofPathLength(const StThreeVector<double>* beginPoint, const StThreeVector<double>* endPoint, const double curvature){
77 
78  double xdif = endPoint->x() - beginPoint->x();
79  double ydif = endPoint->y() - beginPoint->y();
80 
81  double C = ::sqrt(xdif*xdif + ydif*ydif);
82  double s_perp = C;
83  if (curvature){
84  double R = 1/curvature;
85  s_perp = 2*R * asin(C/(2*R));
86  }
87 
88  double s_z = fabs(endPoint->z() - beginPoint->z());
89  double value = ::sqrt(s_perp*s_perp + s_z*s_z);
90 
91  return(value);
92 }
93