test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

Definition at line 48 of file StraightLineCylinderCrossing.h.

Definition at line 50 of file StraightLineCylinderCrossing.h.

Definition at line 47 of file StraightLineCylinderCrossing.h.

Definition at line 49 of file StraightLineCylinderCrossing.h.

Constructor & Destructor Documentation

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

Constructor in local frame

Definition at line 11 of file StraightLineCylinderCrossing.cc.

12  :
13  theX0(startingPos),
14  theP0(startingDir.unit()),
15  thePropDir(propDir),
16  theTolerance(tolerance) {}
const PropagationDirection thePropDir
Vector3DBase unit() const
Definition: Vector3DBase.h:57

Member Function Documentation

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 54 of file StraightLineCylinderCrossing.cc.

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

Referenced by pathLength().

56 {
57  //
58  // follows the logic implemented in HelixBarrelCylinderCrossing
59  //
60  if ( thePropDir==anyDirection ) {
61  return std::pair<bool,double>(true,(fabs(s1)<fabs(s2)?s1:s2));
62  }
63  else {
64  int propSign = thePropDir==alongMomentum ? 1 : -1;
65  if ( s1*s2 < 0) {
66  // if different signs return the positive one
67  return std::pair<bool,double>(true,((s1*propSign>0)?s1:s2));
68  }
69  else if ( s1*propSign>0 ) {
70  // if both positive, return the shortest
71  return std::pair<bool,double>(true,(fabs(s1)<fabs(s2)?s1:s2));
72  }
73  else {
74  // if both negative, check if the smaller (abs value) is smaller then tolerance
75  double shorter = std::min( fabs(s1), fabs(s2));
76  if (shorter < theTolerance) return std::pair<bool,double>(true,0);
77  else return std::pair<bool,double>(false,0.);
78  }
79  }
80 }
const PropagationDirection thePropDir
tuple s2
Definition: indexGen.py:106
T min(T a, T b)
Definition: MathUtil.h:58
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 19 of file StraightLineCylinderCrossing.cc.

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

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

20 {
21  //
22  // radius of cylinder and transversal position relative to axis
23  //
24  double R(cylinder.radius());
25  PositionType2D xt2d(theX0.x(),theX0.y());
26  //
27  // transverse direction
28  //
29  DirectionType2D pt2d(theP0.x(),theP0.y());
30  //
31  // solution of quadratic equation for s - assume |theP0|=1
32  //
33  RealQuadEquation eq(pt2d.mag2(),2.*xt2d.dot(pt2d),xt2d.mag2()-R*R);
34  if ( !eq.hasSolution ) {
35  /*
36  double A= pt2d.mag2();
37  double B= 2.*xt2d.dot(pt2d);
38  double C= xt2d.mag2()-R*R;
39  cout << "A= " << pt2d.mag2()
40  << " B= " << 2.*xt2d.dot(pt2d)
41  << " C= " << xt2d.mag2()-R*R
42  << " D= " << B*B - 4*A*C
43  << endl;
44  */
45  return std::pair<bool,double>(false,0.);
46  }
47  //
48  // choice of solution and verification of direction
49  //
50  return chooseSolution(eq.first,eq.second);
51 }
T y() const
Definition: PV3DBase.h:63
std::pair< bool, double > chooseSolution(const double s1, const double s2) const
Chooses the right solution w.r.t. the propagation direction.
T x() const
Definition: PV3DBase.h:62
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 37 of file StraightLineCylinderCrossing.h.

References theP0, and theX0.

37 { return LocalPoint(theX0+s*theP0);}
Local3DPoint LocalPoint
Definition: LocalPoint.h:11

Member Data Documentation

const DirectionType StraightLineCylinderCrossing::theP0
private

Definition at line 53 of file StraightLineCylinderCrossing.h.

Referenced by pathLength(), and position().

const PropagationDirection StraightLineCylinderCrossing::thePropDir
private

Definition at line 54 of file StraightLineCylinderCrossing.h.

Referenced by chooseSolution().

double StraightLineCylinderCrossing::theTolerance
private

Definition at line 55 of file StraightLineCylinderCrossing.h.

Referenced by chooseSolution().

const PositionType StraightLineCylinderCrossing::theX0
private

Definition at line 52 of file StraightLineCylinderCrossing.h.

Referenced by pathLength(), and position().