Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:28

0001 #ifndef StraightLineCylinderCrossing_H
0002 #define StraightLineCylinderCrossing_H
0003 
0004 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0005 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0006 #include "DataFormats/GeometryVector/interface/Basic2DVector.h"
0007 
0008 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
0009 
0010 #include <utility>
0011 
0012 class Cylinder;
0013 
0014 /** Calculates the intersection of a straight line with a barrel cylinder.
0015  */
0016 
0017 class StraightLineCylinderCrossing {
0018 public:
0019   /** Constructor in local frame
0020    */
0021   StraightLineCylinderCrossing(const LocalPoint& startingPos,
0022                                const LocalVector& startingDir,
0023                                const PropagationDirection propDir = alongMomentum,
0024                                double tolerance = 0);
0025 
0026   /** Propagation status (true if valid) and (signed) path length 
0027    *  along the line from the starting point to the cylinder.
0028    */
0029   std::pair<bool, double> pathLength(const Cylinder& cyl) const;
0030 
0031   /** Returns the position along the line that corresponds to path
0032    *  length "s" from the starting point. If s is obtained from the
0033    *  pathLength method the position is the intersection point
0034    *  with the cylinder.
0035    */
0036   LocalPoint position(const double s) const { return LocalPoint(theX0 + s * theP0); }
0037 
0038 private:
0039   /// Chooses the right solution w.r.t. the propagation direction.
0040   std::pair<bool, double> chooseSolution(const double s1, const double s2) const;
0041 
0042 private:
0043   //
0044   // single precision is sufficient for intermediate vectors
0045   //
0046   typedef LocalPoint PositionType;
0047   typedef LocalVector DirectionType;
0048   typedef Basic2DVector<float> PositionType2D;
0049   typedef Basic2DVector<float> DirectionType2D;
0050 
0051   const PositionType theX0;
0052   const DirectionType theP0;
0053   const PropagationDirection thePropDir;
0054   double theTolerance;
0055 };
0056 
0057 #endif