CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
StraightLineCylinderCrossing Class Reference

#include <StraightLineCylinderCrossing.h>

Public Member Functions

std::pair< bool, double > pathLength (const Cylinder &cyl) const
 
LocalPoint position (const double s) const
 
 StraightLineCylinderCrossing (const LocalPoint &startingPos, const LocalVector &startingDir, const PropagationDirection propDir=alongMomentum, double tolerance=0)
 

Private Types

typedef LocalVector DirectionType
 
typedef Basic2DVector< float > DirectionType2D
 
typedef LocalPoint PositionType
 
typedef Basic2DVector< float > PositionType2D
 

Private Member Functions

std::pair< bool, double > chooseSolution (const double s1, const double s2) const
 Chooses the right solution w.r.t. the propagation direction. More...
 

Private Attributes

const DirectionType theP0
 
const PropagationDirection thePropDir
 
double theTolerance
 
const PositionType theX0
 

Detailed Description

Calculates the intersection of a straight line with a barrel cylinder.

Definition at line 17 of file StraightLineCylinderCrossing.h.

Member Typedef Documentation

◆ DirectionType

Definition at line 47 of file StraightLineCylinderCrossing.h.

◆ DirectionType2D

Definition at line 49 of file StraightLineCylinderCrossing.h.

◆ PositionType

Definition at line 46 of file StraightLineCylinderCrossing.h.

◆ PositionType2D

Definition at line 48 of file StraightLineCylinderCrossing.h.

Constructor & Destructor Documentation

◆ StraightLineCylinderCrossing()

StraightLineCylinderCrossing::StraightLineCylinderCrossing ( const LocalPoint startingPos,
const LocalVector startingDir,
const PropagationDirection  propDir = alongMomentum,
double  tolerance = 0 
)

Constructor in local frame

Definition at line 10 of file StraightLineCylinderCrossing.cc.

14  : theX0(startingPos), theP0(startingDir.unit()), thePropDir(propDir), theTolerance(tolerance) {}

Member Function Documentation

◆ chooseSolution()

std::pair< bool, double > StraightLineCylinderCrossing::chooseSolution ( const double  s1,
const double  s2 
) const
private

Chooses the right solution w.r.t. the propagation direction.

Definition at line 49 of file StraightLineCylinderCrossing.cc.

49  {
50  //
51  // follows the logic implemented in HelixBarrelCylinderCrossing
52  //
53  if (thePropDir == anyDirection) {
54  return std::pair<bool, double>(true, (fabs(s1) < fabs(s2) ? s1 : s2));
55  } else {
56  int propSign = thePropDir == alongMomentum ? 1 : -1;
57  if (s1 * s2 < 0) {
58  // if different signs return the positive one
59  return std::pair<bool, double>(true, ((s1 * propSign > 0) ? s1 : s2));
60  } else if (s1 * propSign > 0) {
61  // if both positive, return the shortest
62  return std::pair<bool, double>(true, (fabs(s1) < fabs(s2) ? s1 : s2));
63  } else {
64  // if both negative, check if the smaller (abs value) is smaller then tolerance
65  double shorter = std::min(fabs(s1), fabs(s2));
66  if (shorter < theTolerance)
67  return std::pair<bool, double>(true, 0);
68  else
69  return std::pair<bool, double>(false, 0.);
70  }
71  }
72 }

References alongMomentum, anyDirection, min(), indexGen::s2, thePropDir, and theTolerance.

Referenced by pathLength().

◆ pathLength()

std::pair< bool, double > StraightLineCylinderCrossing::pathLength ( const Cylinder cyl) const

Propagation status (true if valid) and (signed) path length along the line from the starting point to the cylinder.

Definition at line 16 of file StraightLineCylinderCrossing.cc.

16  {
17  //
18  // radius of cylinder and transversal position relative to axis
19  //
20  double R(cylinder.radius());
21  PositionType2D xt2d(theX0.x(), theX0.y());
22  //
23  // transverse direction
24  //
25  DirectionType2D pt2d(theP0.x(), theP0.y());
26  //
27  // solution of quadratic equation for s - assume |theP0|=1
28  //
29  RealQuadEquation eq(pt2d.mag2(), 2. * xt2d.dot(pt2d), xt2d.mag2() - R * R);
30  if (!eq.hasSolution) {
31  /*
32  double A= pt2d.mag2();
33  double B= 2.*xt2d.dot(pt2d);
34  double C= xt2d.mag2()-R*R;
35  cout << "A= " << pt2d.mag2()
36  << " B= " << 2.*xt2d.dot(pt2d)
37  << " C= " << xt2d.mag2()-R*R
38  << " D= " << B*B - 4*A*C
39  << endl;
40  */
41  return std::pair<bool, double>(false, 0.);
42  }
43  //
44  // choice of solution and verification of direction
45  //
46  return chooseSolution(eq.first, eq.second);
47 }

References chooseSolution(), edm::eq(), dttmaxenums::R, Cylinder::radius(), theP0, theX0, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by HelixBarrelCylinderCrossing::HelixBarrelCylinderCrossing(), and RKPropagatorInS::propagateParametersOnCylinder().

◆ position()

LocalPoint StraightLineCylinderCrossing::position ( const double  s) const
inline

Returns the position along the line that corresponds to path length "s" from the starting point. If s is obtained from the pathLength method the position is the intersection point with the cylinder.

Definition at line 36 of file StraightLineCylinderCrossing.h.

36 { return LocalPoint(theX0 + s * theP0); }

References alignCSCRings::s, theP0, and theX0.

Member Data Documentation

◆ theP0

const DirectionType StraightLineCylinderCrossing::theP0
private

Definition at line 52 of file StraightLineCylinderCrossing.h.

Referenced by pathLength(), and position().

◆ thePropDir

const PropagationDirection StraightLineCylinderCrossing::thePropDir
private

Definition at line 53 of file StraightLineCylinderCrossing.h.

Referenced by chooseSolution().

◆ theTolerance

double StraightLineCylinderCrossing::theTolerance
private

Definition at line 54 of file StraightLineCylinderCrossing.h.

Referenced by chooseSolution().

◆ theX0

const PositionType StraightLineCylinderCrossing::theX0
private

Definition at line 51 of file StraightLineCylinderCrossing.h.

Referenced by pathLength(), and position().

StraightLineCylinderCrossing::theTolerance
double theTolerance
Definition: StraightLineCylinderCrossing.h:54
anyDirection
Definition: PropagationDirection.h:4
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
min
T min(T a, T b)
Definition: MathUtil.h:58
StraightLineCylinderCrossing::theX0
const PositionType theX0
Definition: StraightLineCylinderCrossing.h:51
indexGen.s2
s2
Definition: indexGen.py:107
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
alignCSCRings.s
s
Definition: alignCSCRings.py:92
StraightLineCylinderCrossing::DirectionType2D
Basic2DVector< float > DirectionType2D
Definition: StraightLineCylinderCrossing.h:49
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
RealQuadEquation
Definition: RealQuadEquation.h:11
StraightLineCylinderCrossing::theP0
const DirectionType theP0
Definition: StraightLineCylinderCrossing.h:52
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:27
StraightLineCylinderCrossing::PositionType2D
Basic2DVector< float > PositionType2D
Definition: StraightLineCylinderCrossing.h:48
edm::eq
bool eq(const ELstring &s1, const ELstring s2)
Definition: ELstring.cc:39
StraightLineCylinderCrossing::thePropDir
const PropagationDirection thePropDir
Definition: StraightLineCylinderCrossing.h:53
dttmaxenums::R
Definition: DTTMax.h:29
StraightLineCylinderCrossing::chooseSolution
std::pair< bool, double > chooseSolution(const double s1, const double s2) const
Chooses the right solution w.r.t. the propagation direction.
Definition: StraightLineCylinderCrossing.cc:49
alongMomentum
Definition: PropagationDirection.h:4