CMS 3D CMS Logo

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