#include <TrackingTools/GeomPropagators/interface/HelixBarrelCylinderCrossing.h>
Public Types | |
typedef GlobalVector | DirectionType |
typedef GlobalPoint | PositionType |
Public Member Functions | |
DirectionType | direction () const |
Returns the direction along the helix that corresponds to path length "s" from the starting point. | |
bool | hasSolution () const |
HelixBarrelCylinderCrossing (const GlobalPoint &startingPos, const GlobalVector &startingDir, double rho, PropagationDirection propDir, const Cylinder &cyl) | |
double | pathLength () const |
Propagation status (true if valid) and (signed) path length along the helix from the starting point to the cylinder. | |
PositionType | position () const |
Returns the position along the helix that corresponds to path length "s" from the starting point. | |
Private Types | |
typedef Basic2DVector< TmpType > | Point |
typedef double | TmpType |
typedef Basic2DVector< TmpType > | Vector |
Private Member Functions | |
void | chooseSolution (const Point &p1, const Point &p2, const PositionType &startingPos, const DirectionType &startingDir, PropagationDirection propDir) |
Private Attributes | |
int | theActualDir |
Vector | theD |
DirectionType | theDir |
PositionType | thePos |
double | theS |
bool | theSolExists |
Definition at line 14 of file HelixBarrelCylinderCrossing.h.
Definition at line 23 of file HelixBarrelCylinderCrossing.h.
typedef Basic2DVector<TmpType> HelixBarrelCylinderCrossing::Point [private] |
Definition at line 17 of file HelixBarrelCylinderCrossing.h.
Definition at line 22 of file HelixBarrelCylinderCrossing.h.
typedef double HelixBarrelCylinderCrossing::TmpType [private] |
Definition at line 16 of file HelixBarrelCylinderCrossing.h.
typedef Basic2DVector<TmpType> HelixBarrelCylinderCrossing::Vector [private] |
Definition at line 18 of file HelixBarrelCylinderCrossing.h.
HelixBarrelCylinderCrossing::HelixBarrelCylinderCrossing | ( | const GlobalPoint & | startingPos, | |
const GlobalVector & | startingDir, | |||
double | rho, | |||
PropagationDirection | propDir, | |||
const Cylinder & | cyl | |||
) |
Definition at line 14 of file HelixBarrelCylinderCrossing.cc.
References funct::C, chooseSolution(), d1, d2, edm::eq(), RealQuadEquation::first, RealQuadEquation::hasSolution, Basic2DVector< T >::mag(), PV3DBase< T, PVType, FrameType >::mag(), p2, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::perp2(), dttmaxenums::R, Cylinder::radius(), RealQuadEquation::second, funct::sqrt(), theActualDir, theD, theDir, thePos, theS, theSolExists, tmp, Surface::toGlobal(), GloballyPositioned< T >::toLocal(), PV3DBase< T, PVType, FrameType >::x(), Basic2DVector< T >::x(), PV3DBase< T, PVType, FrameType >::y(), Basic2DVector< T >::y(), and PV3DBase< T, PVType, FrameType >::z().
00018 { 00019 // assumes the cylinder is centered at 0,0 00020 double R = cyl.radius(); 00021 00022 // protect for zero curvature case 00023 const double sraightLineCutoff = 1.e-7; 00024 if (fabs(rho)*R < sraightLineCutoff && 00025 fabs(rho)*startingPos.perp() < sraightLineCutoff) { 00026 // switch to straight line case 00027 StraightLineCylinderCrossing slc( cyl.toLocal(startingPos), 00028 cyl.toLocal(startingDir), propDir); 00029 std::pair<bool,double> pl = slc.pathLength( cyl); 00030 if (pl.first) { 00031 theSolExists = true; 00032 theS = pl.second; 00033 thePos = cyl.toGlobal(slc.position(theS)); 00034 theDir = startingDir; 00035 } 00036 else theSolExists = false; 00037 return; // all needed data members have been set 00038 } 00039 00040 double R2cyl = R*R; 00041 double pt = startingDir.perp(); 00042 Point center( startingPos.x()-startingDir.y()/(pt*rho), 00043 startingPos.y()+startingDir.x()/(pt*rho)); 00044 double p2 = startingPos.perp2(); 00045 bool solveForX; 00046 double B, C, E, F; 00047 if (fabs(center.x()) > fabs(center.y())) { 00048 solveForX = false; 00049 E = (R2cyl - p2) / (2.*center.x()); 00050 F = center.y()/center.x(); 00051 B = 2.*( startingPos.y() - F*startingPos.x() - E*F); 00052 C = 2.*E*startingPos.x() + E*E + p2 - R2cyl; 00053 } 00054 else { 00055 solveForX = true; 00056 E = (R2cyl - p2) / (2.*center.y()); 00057 F = center.x()/center.y(); 00058 B = 2.*( startingPos.x() - F*startingPos.y() - E*F); 00059 C = 2.*E*startingPos.y() + E*E + p2 - R2cyl; 00060 } 00061 00062 RealQuadEquation eq( 1+F*F, B, C); 00063 if (!eq.hasSolution) { 00064 theSolExists = false; 00065 return; 00066 } 00067 00068 Vector d1, d2;; 00069 if (solveForX) { 00070 d1 = Point(eq.first, E-F*eq.first); 00071 d2 = Point(eq.second, E-F*eq.second); 00072 } 00073 else { 00074 d1 = Point( E-F*eq.first, eq.first); 00075 d2 = Point( E-F*eq.second, eq.second); 00076 } 00077 00078 chooseSolution(d1, d2, startingPos, startingDir, propDir); 00079 if (!theSolExists) return; 00080 00081 double pabs = startingDir.mag(); 00082 double sinTheta = pt / pabs; 00083 double cosTheta = startingDir.z() / pabs; 00084 00085 double dMag = theD.mag(); 00086 theS = theActualDir * 2.* asin( dMag*rho/2.) / (rho*sinTheta); 00087 thePos = GlobalPoint( startingPos.x() + theD.x(), 00088 startingPos.y() + theD.y(), 00089 startingPos.z() + theS*cosTheta); 00090 00091 double tmp = 0.5 * dMag * rho; 00092 if (theS < 0) tmp = -tmp; 00093 double sinPhi = 2.*tmp*sqrt(1.-tmp*tmp); 00094 double cosPhi = 1.-2.*tmp*tmp; 00095 theDir = DirectionType(startingDir.x()*cosPhi-startingDir.y()*sinPhi, 00096 startingDir.x()*sinPhi+startingDir.y()*cosPhi, 00097 startingDir.z()); 00098 }
void HelixBarrelCylinderCrossing::chooseSolution | ( | const Point & | p1, | |
const Point & | p2, | |||
const PositionType & | startingPos, | |||
const DirectionType & | startingDir, | |||
PropagationDirection | propDir | |||
) | [private] |
Definition at line 99 of file HelixBarrelCylinderCrossing.cc.
References alongMomentum, anyDirection, Basic2DVector< T >::mag2(), theActualDir, theD, theSolExists, PV3DBase< T, PVType, FrameType >::x(), Basic2DVector< T >::x(), PV3DBase< T, PVType, FrameType >::y(), and Basic2DVector< T >::y().
Referenced by HelixBarrelCylinderCrossing().
00103 { 00104 double momProj1 = startingDir.x()*d1.x() + startingDir.y()*d1.y(); 00105 double momProj2 = startingDir.x()*d2.x() + startingDir.y()*d2.y(); 00106 00107 if ( propDir == anyDirection ) { 00108 theSolExists = true; 00109 if (d1.mag2()<d2.mag2()) { 00110 theD = d1; 00111 theActualDir = (momProj1 > 0) ? 1 : -1; 00112 } 00113 else { 00114 theD = d2; 00115 theActualDir = (momProj2 > 0) ? 1 : -1; 00116 } 00117 } 00118 else { 00119 int propSign = propDir==alongMomentum ? 1 : -1; 00120 if (momProj1*momProj2 < 0) { 00121 // if different signs return the positive one 00122 theSolExists = true; 00123 theD = (momProj1*propSign > 0) ? d1 : d2; 00124 theActualDir = propSign; 00125 } 00126 else if (momProj1*propSign > 0) { 00127 // if both positive, return the shortest 00128 theSolExists = true; 00129 theD = (d1.mag2()<d2.mag2()) ? d1 : d2; 00130 theActualDir = propSign; 00131 } 00132 else theSolExists = false; 00133 } 00134 }
DirectionType HelixBarrelCylinderCrossing::direction | ( | void | ) | const [inline] |
Returns the direction along the helix that corresponds to path length "s" from the starting point.
As for position, the direction of the crossing with a cylinder (if it exists!) is given by direction( pathLength( cylinder)).
Definition at line 51 of file HelixBarrelCylinderCrossing.h.
References theDir.
00051 { return theDir;}
bool HelixBarrelCylinderCrossing::hasSolution | ( | ) | const [inline] |
Definition at line 30 of file HelixBarrelCylinderCrossing.h.
References theSolExists.
Referenced by PixelBarrelLayer::computeCrossings(), TOBLayer::computeCrossings(), and TIBLayer::computeCrossings().
00030 { return theSolExists;}
double HelixBarrelCylinderCrossing::pathLength | ( | ) | const [inline] |
Propagation status (true if valid) and (signed) path length along the helix from the starting point to the cylinder.
The starting point and the cylinder are given in the constructor.
Definition at line 36 of file HelixBarrelCylinderCrossing.h.
References theS.
00036 { return theS;}
PositionType HelixBarrelCylinderCrossing::position | ( | void | ) | const [inline] |
Returns the position along the helix that corresponds to path length "s" from the starting point.
If s is obtained from the pathLength method the position is the destination point, i.e. the position of the crossing with a cylinder (if it exists!) is given by position( pathLength( cylinder)).
Definition at line 44 of file HelixBarrelCylinderCrossing.h.
References thePos.
Referenced by PixelBarrelLayer::computeCrossings(), TOBLayer::computeCrossings(), and TIBLayer::computeCrossings().
00044 { return thePos;}
int HelixBarrelCylinderCrossing::theActualDir [private] |
Definition at line 60 of file HelixBarrelCylinderCrossing.h.
Referenced by chooseSolution(), and HelixBarrelCylinderCrossing().
Vector HelixBarrelCylinderCrossing::theD [private] |
Definition at line 59 of file HelixBarrelCylinderCrossing.h.
Referenced by chooseSolution(), and HelixBarrelCylinderCrossing().
Definition at line 58 of file HelixBarrelCylinderCrossing.h.
Referenced by direction(), and HelixBarrelCylinderCrossing().
Definition at line 57 of file HelixBarrelCylinderCrossing.h.
Referenced by HelixBarrelCylinderCrossing(), and position().
double HelixBarrelCylinderCrossing::theS [private] |
Definition at line 56 of file HelixBarrelCylinderCrossing.h.
Referenced by HelixBarrelCylinderCrossing(), and pathLength().
Definition at line 55 of file HelixBarrelCylinderCrossing.h.
Referenced by chooseSolution(), hasSolution(), and HelixBarrelCylinderCrossing().