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
StraightLineBarrelCylinderCrossing Class Reference

#include <StraightLineBarrelCylinderCrossing.h>

Public Member Functions

std::pair< bool, double > pathLength (const Cylinder &cyl) const
 
GlobalPoint position (const double s) const
 
 StraightLineBarrelCylinderCrossing (const GlobalPoint &startingPos, const GlobalVector &startingDir, const PropagationDirection propDir)
 

Private Types

typedef GlobalVector DirectionType
 
typedef Basic2DVector< float > DirectionType2D
 
typedef GlobalPoint 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
 
const PositionType theX0
 

Detailed Description

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

Definition at line 17 of file StraightLineBarrelCylinderCrossing.h.

Member Typedef Documentation

Definition at line 48 of file StraightLineBarrelCylinderCrossing.h.

Definition at line 50 of file StraightLineBarrelCylinderCrossing.h.

Definition at line 47 of file StraightLineBarrelCylinderCrossing.h.

Definition at line 49 of file StraightLineBarrelCylinderCrossing.h.

Constructor & Destructor Documentation

StraightLineBarrelCylinderCrossing::StraightLineBarrelCylinderCrossing ( const GlobalPoint startingPos,
const GlobalVector startingDir,
const PropagationDirection  propDir 
)

Constructor uses global frame (barrel cylinders are by definition in global co-ordinates)

Definition at line 8 of file StraightLineBarrelCylinderCrossing.cc.

9  :
10  theX0(startingPos),
11  theP0(startingDir.unit()),
12  thePropDir(propDir) {}
Vector3DBase unit() const
Definition: Vector3DBase.h:57

Member Function Documentation

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

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

Definition at line 39 of file StraightLineBarrelCylinderCrossing.cc.

References alongMomentum, anyDirection, indexGen::s2, and thePropDir.

Referenced by pathLength().

41 {
42  //
43  // follows the logic implemented in HelixBarrelCylinderCrossing
44  //
45  if ( thePropDir==anyDirection ) {
46  return std::pair<bool,double>(true,(fabs(s1)<fabs(s2)?s1:s2));
47  }
48  else {
49  int propSign = thePropDir==alongMomentum ? 1 : -1;
50  if ( s1*s2 < 0) {
51  // if different signs return the positive one
52  return std::pair<bool,double>(true,((s1*propSign>0)?s1:s2));
53  }
54  else if ( s1*propSign>0 ) {
55  // if both positive, return the shortest
56  return std::pair<bool,double>(true,(fabs(s1)<fabs(s2)?s1:s2));
57  }
58  }
59  return std::pair<bool,double>(false,0.);
60 }
tuple s2
Definition: indexGen.py:106
std::pair< bool, double > StraightLineBarrelCylinderCrossing::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 15 of file StraightLineBarrelCylinderCrossing.cc.

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

16 {
17  //
18  // radius of cylinder and transversal position relative to axis
19  //
20  double R(cylinder.radius());
21  GlobalPoint axis(cylinder.toGlobal(Cylinder::LocalPoint(0.,0.)));
22  PositionType2D xt2d(theX0.x()-axis.x(),theX0.y()-axis.y());
23  //
24  // transverse direction
25  //
26  DirectionType2D pt2d(theP0.x(),theP0.y());
27  //
28  // solution of quadratic equation for s - assume |theP0|=1
29  //
30  RealQuadEquation eq(pt2d.mag2(),2.*xt2d.dot(pt2d),xt2d.mag2()-R*R);
31  if ( !eq.hasSolution ) return std::pair<bool,double>(false,0.);
32  //
33  // choice of solution and verification of direction
34  //
35  return chooseSolution(eq.first,eq.second);
36 }
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.
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
T x() const
Definition: PV3DBase.h:62
GlobalPoint StraightLineBarrelCylinderCrossing::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 StraightLineBarrelCylinderCrossing.h.

References theP0, and theX0.

Member Data Documentation

const DirectionType StraightLineBarrelCylinderCrossing::theP0
private

Definition at line 53 of file StraightLineBarrelCylinderCrossing.h.

Referenced by pathLength(), and position().

const PropagationDirection StraightLineBarrelCylinderCrossing::thePropDir
private

Definition at line 54 of file StraightLineBarrelCylinderCrossing.h.

Referenced by chooseSolution().

const PositionType StraightLineBarrelCylinderCrossing::theX0
private

Definition at line 52 of file StraightLineBarrelCylinderCrossing.h.

Referenced by pathLength(), and position().