TrackingTools
GeomPropagators
src
PropagationDirectionChooser.cc
Go to the documentation of this file.
1
#include "
TrackingTools/GeomPropagators/interface/PropagationDirectionChooser.h
"
2
#include "
TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h
"
3
#include "
TrackingTools/GeomPropagators/interface/PropagationExceptions.h
"
4
5
#include "
DataFormats/GeometrySurface/interface/Surface.h
"
6
#include "
DataFormats/GeometrySurface/interface/Cylinder.h
"
7
#include "
DataFormats/GeometrySurface/interface/Plane.h
"
8
9
#include "
MagneticField/Engine/interface/MagneticField.h
"
10
11
#include <cmath>
12
13
PropagationDirection
PropagationDirectionChooser::operator()
(
const
FreeTrajectoryState
& fts,
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
36
PropagationDirection
PropagationDirectionChooser::operator()
(
const
FreeTrajectoryState
& fts,
const
Plane
& plane)
const
{
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.
41
PropagationDirection
dir
=
anyDirection
;
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.));
48
AlgebraicMatrix33
a
;
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();
58
AlgebraicVector3
b
;
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
82
PropagationDirection
PropagationDirectionChooser::operator()
(
const
FreeTrajectoryState
& fts,
83
const
Cylinder
& cylinder)
const
{
84
// propagation to cylinder with axis along z
85
// Copied from BidirectionalPropagator.
86
PropagationDirection
dir
=
anyDirection
;
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
}
Vector3DBase
Definition:
Vector3DBase.h:8
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition:
FreeTrajectoryState.h:68
TrajectoryStateOnSurface.h
AlgebraicVector3
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Definition:
AlgebraicROOTObjects.h:12
anyDirection
Definition:
PropagationDirection.h:4
Cylinder.h
Cylinder::radius
Scalar radius() const
Radius of the cylinder.
Definition:
Cylinder.h:64
PV3DBase::x
T x() const
Definition:
PV3DBase.h:59
PropagationException
Common base class.
Definition:
PropagationExceptions.h:14
AlCaHLTBitMon_ParallelJobs.p
p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
PropagationDirectionChooser.h
oppositeToMomentum
Definition:
PropagationDirection.h:4
Surface
Definition:
Surface.h:36
AlgebraicMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
Definition:
AlgebraicROOTObjects.h:41
DDAxes::x
FreeTrajectoryState::position
GlobalPoint position() const
Definition:
FreeTrajectoryState.h:67
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition:
Definitions.h:30
findQualityFiles.v
v
Definition:
findQualityFiles.py:179
PV3DBase::z
T z() const
Definition:
PV3DBase.h:61
Plane.h
Vector3DBase::unit
Vector3DBase unit() const
Definition:
Vector3DBase.h:54
Surface.h
w
const double w
Definition:
UKUtility.cc:23
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition:
Surface.h:79
Point3DBase< float, GlobalTag >
b
double b
Definition:
hdecay.h:118
amptDefault_cfi.proj
proj
Definition:
amptDefault_cfi.py:13
a
double a
Definition:
hdecay.h:119
PV3DBase::y
T y() const
Definition:
PV3DBase.h:60
LocalVector
Local3DVector LocalVector
Definition:
LocalVector.h:12
MagneticField.h
FreeTrajectoryState
Definition:
FreeTrajectoryState.h:27
PropagationDirection
PropagationDirection
Definition:
PropagationDirection.h:4
Plane
Definition:
Plane.h:16
Cylinder
Definition:
Cylinder.h:19
PropagationDirectionChooser::operator()
PropagationDirection operator()(const FreeTrajectoryState &, const Surface &) const
Definition:
PropagationDirectionChooser.cc:13
PropagationExceptions.h
alongMomentum
Definition:
PropagationDirection.h:4
DeadROC_duringRun.dir
dir
Definition:
DeadROC_duringRun.py:23
Generated for CMSSW Reference Manual by
1.8.16