TrackingTools
GeomPropagators
src
StraightLineBarrelCylinderCrossing.cc
Go to the documentation of this file.
1
#include "
TrackingTools/GeomPropagators/interface/StraightLineBarrelCylinderCrossing.h
"
2
#include "
DataFormats/GeometrySurface/interface/Cylinder.h
"
3
#include "
TrackingTools/GeomPropagators/src/RealQuadEquation.h
"
4
5
#include <cmath>
6
7
StraightLineBarrelCylinderCrossing::StraightLineBarrelCylinderCrossing
(
const
GlobalPoint
& startingPos,
8
const
GlobalVector
& startingDir,
9
const
PropagationDirection
propDir)
10
: theX0(startingPos), theP0(startingDir.
unit
()), thePropDir(propDir) {}
11
12
std::pair<bool, double>
StraightLineBarrelCylinderCrossing::pathLength
(
const
Cylinder
& cylinder)
const
{
13
//
14
// radius of cylinder and transversal position relative to axis
15
//
16
double
R
(cylinder.
radius
());
17
GlobalPoint
axis(cylinder.
toGlobal
(
Cylinder::LocalPoint
(0., 0.)));
18
PositionType2D
xt2d(
theX0
.
x
() - axis.x(),
theX0
.
y
() - axis.y());
19
//
20
// transverse direction
21
//
22
DirectionType2D
pt2d(
theP0
.
x
(),
theP0
.
y
());
23
//
24
// solution of quadratic equation for s - assume |theP0|=1
25
//
26
RealQuadEquation
eq
(pt2d.mag2(), 2. * xt2d.dot(pt2d), xt2d.mag2() -
R
*
R
);
27
if
(!
eq
.hasSolution)
28
return
std::pair<bool, double>(
false
, 0.);
29
//
30
// choice of solution and verification of direction
31
//
32
return
chooseSolution
(
eq
.first,
eq
.second);
33
}
34
35
std::pair<bool, double>
StraightLineBarrelCylinderCrossing::chooseSolution
(
const
double
s1,
const
double
s2
)
const
{
36
//
37
// follows the logic implemented in HelixBarrelCylinderCrossing
38
//
39
if
(
thePropDir
==
anyDirection
) {
40
return
std::pair<bool, double>(
true
, (fabs(s1) < fabs(
s2
) ? s1 :
s2
));
41
}
else
{
42
int
propSign =
thePropDir
==
alongMomentum
? 1 : -1;
43
if
(s1 *
s2
< 0) {
44
// if different signs return the positive one
45
return
std::pair<bool, double>(
true
, ((s1 * propSign > 0) ? s1 :
s2
));
46
}
else
if
(s1 * propSign > 0) {
47
// if both positive, return the shortest
48
return
std::pair<bool, double>(
true
, (fabs(s1) < fabs(
s2
) ? s1 :
s2
));
49
}
50
}
51
return
std::pair<bool, double>(
false
, 0.);
52
}
Vector3DBase
Definition:
Vector3DBase.h:8
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
StraightLineBarrelCylinderCrossing::chooseSolution
std::pair< bool, double > chooseSolution(const double s1, const double s2) const
Chooses the right solution w.r.t. the propagation direction.
Definition:
StraightLineBarrelCylinderCrossing.cc:35
StraightLineBarrelCylinderCrossing::theP0
const DirectionType theP0
Definition:
StraightLineBarrelCylinderCrossing.h:52
indexGen.s2
s2
Definition:
indexGen.py:107
RealQuadEquation
Definition:
RealQuadEquation.h:11
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition:
Surface.h:79
Point3DBase< float, GlobalTag >
Basic2DVector< float >
StraightLineBarrelCylinderCrossing.h
PV3DBase::y
T y() const
Definition:
PV3DBase.h:60
StraightLineBarrelCylinderCrossing::theX0
const PositionType theX0
Definition:
StraightLineBarrelCylinderCrossing.h:51
edm::eq
bool eq(const ELstring &s1, const ELstring s2)
Definition:
ELstring.cc:39
unit
Basic3DVector unit() const
Definition:
Basic3DVectorLD.h:162
StraightLineBarrelCylinderCrossing::thePropDir
const PropagationDirection thePropDir
Definition:
StraightLineBarrelCylinderCrossing.h:53
StraightLineBarrelCylinderCrossing::pathLength
std::pair< bool, double > pathLength(const Cylinder &cyl) const
Definition:
StraightLineBarrelCylinderCrossing.cc:12
PropagationDirection
PropagationDirection
Definition:
PropagationDirection.h:4
StraightLineBarrelCylinderCrossing::StraightLineBarrelCylinderCrossing
StraightLineBarrelCylinderCrossing(const GlobalPoint &startingPos, const GlobalVector &startingDir, const PropagationDirection propDir)
Definition:
StraightLineBarrelCylinderCrossing.cc:7
RealQuadEquation.h
Cylinder
Definition:
Cylinder.h:19
dttmaxenums::R
Definition:
DTTMax.h:29
alongMomentum
Definition:
PropagationDirection.h:4
Generated for CMSSW Reference Manual by
1.8.16