CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HelixBarrelPlaneCrossing2OrderLocal.cc
Go to the documentation of this file.
2 #include <algorithm>
3 #include <cmath>
4 
7  const GlobalVector& startingDir,
8  float rho, const Plane& plane)
9 {
10 
12 
13  // translate problem to local frame of the plane
14  Plane::ToLocal toLocal(plane);
15  LocalPoint lPos = toLocal.toLocal(startingPos);
16  LocalVector lDir = toLocal.toLocal(startingDir);
17 
18  // check if local frame is already special (local Y axis == global Z axis)
19  LocalVector yPrime = toLocal.toLocal( GlobalVector(0,0,1.f));
20  // LocalVector diff = yPrime - LocalVector(0,-1.f,0);
21  float sinPhi=0, cosPhi=0;
22  bool rotated;
23  Vector2D pos;
24  Vector2D dir;
25 
26  if ( std::abs(yPrime.y()) > 0.9999f ) {
27 
28  // cout << "Plane already oriented, yPrime = " << yPrime << endl;
29 
30  // we are already in the special orientation
31  pos = Vector2D( lPos.x(), lPos.y());
32  dir = Vector2D( lDir.x(), lDir.y());;
33  rotated = false;
34  }
35  else {
36 
37  // cout << "Plane needs rotation, yPrime = " << yPrime << endl;
38 
39  // we need to rotate the problem
40  sinPhi = yPrime.y();
41  cosPhi = yPrime.x();
42  pos = Vector2D( lPos.x()*cosPhi + lPos.y()*sinPhi,
43  -lPos.x()*sinPhi + lPos.y()*cosPhi);
44  dir = Vector2D( lDir.x()*cosPhi + lDir.y()*sinPhi,
45  -lDir.x()*sinPhi + lDir.y()*cosPhi);
46  rotated = true;
47  }
48 
49  float d = -lPos.z();
50  float x = pos.x() + dir.x()/lDir.z()*d - 0.5f*rho*d*d;
51  float y = pos.y() + dir.y()/lDir.z()*d;
52 
53 // cout << "d= " << d << ", pos.x()= " << pos.x()
54 // << ", dir.x()/lDir.z()= " << dir.x()/lDir.z()
55 // << ", 0.5*rho*d*d= " << 0.5*rho*d*d << endl;
56 
57  if (!rotated) {
58  thePos = LocalPoint( x, y, 0);
59  theDir = LocalVector( dir.x()+rho*d, dir.y(), lDir.z());
60  }
61  else {
62  thePos = LocalPoint( x*cosPhi - y*sinPhi,
63  x*sinPhi + y*cosPhi, 0);
64  float px = dir.x()+rho*d;
65  theDir = LocalVector( px*cosPhi - dir.y()*sinPhi,
66  px*sinPhi + dir.y()*cosPhi, lDir.z());
67  }
68 }
69 
70 
72  const GlobalVector& startingDir,
73  float rho,
74  const Plane& plane) {
75 
77 
78  // translate problem to local frame of the plane
79  Plane::ToLocal toLocal(plane);
80  LocalPoint lPos = toLocal.toLocal(startingPos);
81  LocalVector lDir = toLocal.toLocal(startingDir);
82 
83  // check if local frame is already special (local Y axis == global Z axis)
84  LocalVector yPrime = toLocal.toLocal( GlobalVector(0,0,1.f));
85  // LocalVector diff = yPrime - LocalVector(0,-1.f,0);
86  float sinPhi=0, cosPhi=0;
87  bool rotated;
88  Vector2D pos;
89  Vector2D dir;
90 
91  if ( std::abs(yPrime.y()) > 0.9999f ) {
92 
93  // cout << "Plane already oriented, yPrime = " << yPrime << endl;
94 
95  // we are already in the special orientation
96  pos = Vector2D( lPos.x(), lPos.y());
97  dir = Vector2D( lDir.x(), lDir.y());;
98  rotated = false;
99  } else {
100 
101  // cout << "Plane needs rotation, yPrime = " << yPrime << endl;
102 
103  // we need to rotate the problem
104  sinPhi = yPrime.y();
105  cosPhi = yPrime.x();
106  pos = Vector2D( lPos.x()*cosPhi + lPos.y()*sinPhi,
107  -lPos.x()*sinPhi + lPos.y()*cosPhi);
108  dir = Vector2D( lDir.x()*cosPhi + lDir.y()*sinPhi,
109  -lDir.x()*sinPhi + lDir.y()*cosPhi);
110  rotated = true;
111  }
112 
113  float d = -lPos.z();
114  float x = pos.x() + dir.x()/lDir.z()*d - 0.5f*rho*d*d;
115  float y = pos.y() + dir.y()/lDir.z()*d;
116 
117 // cout << "d= " << d << ", pos.x()= " << pos.x()
118 // << ", dir.x()/lDir.z()= " << dir.x()/lDir.z()
119 // << ", 0.5*rho*d*d= " << 0.5*rho*d*d << endl;
120 
121  return (!rotated) ? LocalPoint( x, y, 0) :
122  LocalPoint( x*cosPhi - y*sinPhi,
123  x*sinPhi + y*cosPhi, 0);
124 
125 
126 }
static LocalPoint positionOnly(const GlobalPoint &startingPos, const GlobalVector &startingDir, float rho, const Plane &plane)
T y() const
Definition: PV3DBase.h:63
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Definition: Plane.h:17
tuple d
Definition: ztail.py:151
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
HelixBarrelPlaneCrossing2OrderLocal(const GlobalPoint &startingPos, const GlobalVector &startingDir, float rho, const Plane &plane)
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62