00001 #include "TrackingTools/GeomPropagators/interface/StraightLinePlaneCrossing.h"
00002
00003 #include "DataFormats/GeometrySurface/interface/Plane.h"
00004
00005 #include <cmath>
00006 #include <cfloat>
00007
00008 StraightLinePlaneCrossing::StraightLinePlaneCrossing(const PositionType& point,
00009 const DirectionType& momentum,
00010 const PropagationDirection propDir) :
00011 theX0(point),
00012 theP0(momentum.unit()),
00013 thePropDir(propDir) {
00014
00015
00016 }
00017
00018
00019
00020 std::pair<bool,double>
00021 StraightLinePlaneCrossing::pathLength (const Plane& plane) const {
00022
00023
00024
00025 PositionTypeDouble planePosition(plane.position());
00026 DirectionTypeDouble planeNormal(plane.normalVector());
00027
00028 double pz = planeNormal.dot(theP0);
00029
00030 if ( fabs(pz)<FLT_MIN ) return std::pair<bool,double>(false,0);
00031
00032 double dS = -planeNormal.dot(theX0-planePosition)/pz;
00033
00034
00035
00036
00037 if ( (thePropDir==alongMomentum && dS<0.) ||
00038 (thePropDir==oppositeToMomentum && dS>0.) ) return std::pair<bool,double>(false,0);
00039
00040
00041
00042 return std::pair<bool,double>(true,dS);
00043 }
00044
00045 std::pair<bool,StraightLinePlaneCrossing::PositionType>
00046 StraightLinePlaneCrossing::position(const Plane& plane) const
00047 {
00048 std::pair<bool,double> crossed = pathLength(plane);
00049 if (crossed.first) return std::pair<bool,PositionType>(true, position(crossed.second));
00050 else return std::pair<bool,PositionType>(false, PositionType());
00051 }
00052