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 }
Vector3DBase
Definition: Vector3DBase.h:8
HelixBarrelPlaneCrossing2OrderLocal::LocalVector
Surface::LocalVector LocalVector
Definition: HelixBarrelPlaneCrossing2OrderLocal.h:17
HelixBarrelPlaneCrossing2OrderLocal::thePos
LocalPoint thePos
Definition: HelixBarrelPlaneCrossing2OrderLocal.h:33
DDAxes::y
HelixBarrelPlaneCrossing2OrderLocal.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
pos
Definition: PixelAliasList.h:18
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
DDAxes::x
HelixBarrelPlaneCrossing2OrderLocal::theDir
LocalVector theDir
Definition: HelixBarrelPlaneCrossing2OrderLocal.h:34
HelixBarrelPlaneCrossing2OrderLocal::HelixBarrelPlaneCrossing2OrderLocal
HelixBarrelPlaneCrossing2OrderLocal(const GlobalPoint &startingPos, const GlobalVector &startingDir, float rho, const Plane &plane)
Definition: HelixBarrelPlaneCrossing2OrderLocal.cc:5
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
HelixBarrelPlaneCrossing2OrderLocal::LocalPoint
Surface::LocalPoint LocalPoint
Definition: HelixBarrelPlaneCrossing2OrderLocal.h:16
Point3DBase< float, GlobalTag >
DDAxes::rho
Basic2DVector< float >
Vector2D
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
HelixBarrelPlaneCrossing2OrderLocal::GlobalVector
Surface::GlobalVector GlobalVector
Definition: HelixBarrelPlaneCrossing2OrderLocal.h:15
Plane
Definition: Plane.h:16
toLocal
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Definition: ConversionProducer.h:199
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HelixBarrelPlaneCrossing2OrderLocal::positionOnly
static LocalPoint positionOnly(const GlobalPoint &startingPos, const GlobalVector &startingDir, float rho, const Plane &plane)
Definition: HelixBarrelPlaneCrossing2OrderLocal.cc:61
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23