CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PropagationDirectionChooser.cc
Go to the documentation of this file.
4 
8 
10 
11 #include <cmath>
12 
14  const Surface& surface) const {
15  // understand the surface type (expect cylinder/plane)
16  // unfortunately dynamic_cast on Sun is broken -- cannot deal with const
17  // so here we get rid of const
18  const Surface* sur = (const Surface*)&surface;
19  const Cylinder* bc = dynamic_cast<const Cylinder*>(sur);
20  const Plane* bp = dynamic_cast<const Plane*>(sur);
21  if (bc != nullptr) {
22  //
23  // cylinder
24  //
25  return (*this)(fts, *bc);
26  } else if (bp != nullptr) {
27  //
28  // plane
29  //
30  return (*this)(fts, *bp);
31  } else {
32  throw PropagationException("The surface is neither Cylinder nor Plane");
33  }
34 }
35 
37  // propagation towards arbitrary plane
38  // need computation of intersection point between plane
39  // and track (straight line approximation) to set direction
40  // Copied from BidirectionalPropagator.
42 
43  GlobalPoint x = fts.position();
44  GlobalVector p = fts.momentum().unit();
45  GlobalPoint sp = plane.toGlobal(LocalPoint(0., 0.));
46  GlobalVector v = plane.toGlobal(LocalVector(1., 0., 0.));
47  GlobalVector w = plane.toGlobal(LocalVector(0., 1., 0.));
49  a(0, 0) = v.x();
50  a(0, 1) = w.x();
51  a(0, 2) = -p.x();
52  a(1, 0) = v.y();
53  a(1, 1) = w.y();
54  a(1, 2) = -p.y();
55  a(2, 0) = v.z();
56  a(2, 1) = w.z();
57  a(2, 2) = -p.z();
59  b[0] = x.x() - sp.x();
60  b[1] = x.y() - sp.y();
61  b[2] = x.z() - sp.z();
62 
63  int ifail = !a.Invert();
64  if (ifail == 0) {
65  // plane and momentum are not parallel
66  b = a * b;
67  // b[2] nb of steps along unit vector parallel to momentum to reach plane
68 
69  const double small = 1.e-4; // 1 micron distance
70  if (fabs(b[2]) < small) {
71  // already on plane, choose forward as default
72  dir = alongMomentum;
73  } else if (b[2] < 0.) {
74  dir = oppositeToMomentum;
75  } else {
76  dir = alongMomentum;
77  }
78  }
79  return dir;
80 }
81 
83  const Cylinder& cylinder) const {
84  // propagation to cylinder with axis along z
85  // Copied from BidirectionalPropagator.
87 
88  GlobalPoint sp = cylinder.toGlobal(LocalPoint(0., 0.));
89  if (sp.x() != 0. || sp.y() != 0.) {
90  throw PropagationException("Cannot propagate to an arbitrary cylinder");
91  }
92 
93  GlobalPoint x = fts.position();
94  GlobalVector p = fts.momentum();
95 
96  const double small = 1.e-4; // 1 micron distance
97  double rdiff = x.perp() - cylinder.radius();
98 
99  if (fabs(rdiff) < small) {
100  // already on cylinder, choose forward as default
101  dir = alongMomentum;
102  } else {
103  int rSign = (rdiff >= 0.) ? 1 : -1;
104  if (rSign == -1) {
105  // starting point inside cylinder
106  // propagate always in direction of momentum
107  dir = alongMomentum;
108  } else {
109  // starting point outside cylinder
110  // choose direction so as to approach cylinder surface
111  double proj = (x.x() * p.x() + x.y() * p.y()) * rSign;
112  if (proj < 0.) {
113  dir = alongMomentum;
114  } else {
115  dir = oppositeToMomentum;
116  }
117  }
118  }
119  return dir;
120 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
Local3DVector LocalVector
Definition: LocalVector.h:12
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
T perp() const
Definition: PV3DBase.h:69
const double w
Definition: UKUtility.cc:23
T y() const
Definition: PV3DBase.h:60
PropagationDirection
Definition: Plane.h:16
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:64
T z() const
Definition: PV3DBase.h:61
Common base class.
PropagationDirection operator()(const FreeTrajectoryState &, const Surface &) const
GlobalVector momentum() const
Vector3DBase unit() const
Definition: Vector3DBase.h:54
GlobalPoint position() const
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
ROOT::Math::SVector< double, 3 > AlgebraicVector3
T x() const
Definition: PV3DBase.h:59