CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/TrackingTools/GeomPropagators/src/StraightLinePlaneCrossing.cc

Go to the documentation of this file.
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 //   cout << "StraightLinePlaneCrossing: x0 = " << point
00015 //        << ", p0 = " << momentum << endl;
00016 }
00017 //
00018 // Propagation status  and path length to intersection
00019 //
00020 std::pair<bool,double>
00021 StraightLinePlaneCrossing::pathLength (const Plane& plane) const {
00022   //
00023   // Protect against p_normal=0 and calculate path length
00024   //
00025   PositionTypeDouble planePosition(plane.position());
00026   DirectionTypeDouble planeNormal(plane.normalVector());
00027 //   double pz = plane.localZ(GlobalVector(theP0));
00028   double pz = planeNormal.dot(theP0);
00029 //   cout << "pz = " << pz << endl;
00030   if ( fabs(pz)<FLT_MIN )  return std::pair<bool,double>(false,0);
00031 //   double dS = -plane.localZ(GlobalPoint(theX0))/pz;
00032   double dS = -planeNormal.dot(theX0-planePosition)/pz;
00033 //   if ( thePropDir==alongMomentum )  cout << "alongMomentum ";
00034 //   else if ( thePropDir==oppositeToMomentum )  cout << "oppositeToMomentum ";
00035 //   else  cout << "anyDirection ";
00036 //   cout << dS << endl;
00037   if ( (thePropDir==alongMomentum && dS<0.) ||
00038        (thePropDir==oppositeToMomentum && dS>0.) )  return std::pair<bool,double>(false,0);
00039   //
00040   // Return result
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