CMS 3D CMS Logo

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