#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. | |
Private Attributes | |
const DirectionType | theP0 |
const PropagationDirection | thePropDir |
double | theTolerance |
const PositionType | theX0 |
Calculates the intersection of a straight line with a barrel cylinder.
Definition at line 17 of file StraightLineCylinderCrossing.h.
typedef LocalVector StraightLineCylinderCrossing::DirectionType [private] |
Definition at line 48 of file StraightLineCylinderCrossing.h.
typedef Basic2DVector<float> StraightLineCylinderCrossing::DirectionType2D [private] |
Definition at line 50 of file StraightLineCylinderCrossing.h.
typedef LocalPoint StraightLineCylinderCrossing::PositionType [private] |
Definition at line 47 of file StraightLineCylinderCrossing.h.
typedef Basic2DVector<float> StraightLineCylinderCrossing::PositionType2D [private] |
Definition at line 49 of file StraightLineCylinderCrossing.h.
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.
: theX0(startingPos), theP0(startingDir.unit()), thePropDir(propDir), theTolerance(tolerance) {}
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().
{ // // follows the logic implemented in HelixBarrelCylinderCrossing // if ( thePropDir==anyDirection ) { return std::pair<bool,double>(true,(fabs(s1)<fabs(s2)?s1:s2)); } else { int propSign = thePropDir==alongMomentum ? 1 : -1; if ( s1*s2 < 0) { // if different signs return the positive one return std::pair<bool,double>(true,((s1*propSign>0)?s1:s2)); } else if ( s1*propSign>0 ) { // if both positive, return the shortest return std::pair<bool,double>(true,(fabs(s1)<fabs(s2)?s1:s2)); } else { // if both negative, check if the smaller (abs value) is smaller then tolerance double shorter = std::min( fabs(s1), fabs(s2)); if (shorter < theTolerance) return std::pair<bool,double>(true,0); else return std::pair<bool,double>(false,0.); } } }
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().
{ // // radius of cylinder and transversal position relative to axis // double R(cylinder.radius()); PositionType2D xt2d(theX0.x(),theX0.y()); // // transverse direction // DirectionType2D pt2d(theP0.x(),theP0.y()); // // solution of quadratic equation for s - assume |theP0|=1 // RealQuadEquation eq(pt2d.mag2(),2.*xt2d.dot(pt2d),xt2d.mag2()-R*R); if ( !eq.hasSolution ) { /* double A= pt2d.mag2(); double B= 2.*xt2d.dot(pt2d); double C= xt2d.mag2()-R*R; cout << "A= " << pt2d.mag2() << " B= " << 2.*xt2d.dot(pt2d) << " C= " << xt2d.mag2()-R*R << " D= " << B*B - 4*A*C << endl; */ return std::pair<bool,double>(false,0.); } // // choice of solution and verification of direction // return chooseSolution(eq.first,eq.second); }
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.
{ return LocalPoint(theX0+s*theP0);}
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().