test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StraightLineBarrelCylinderCrossing.cc
Go to the documentation of this file.
4 
5 #include <cmath>
6 
8 (const GlobalPoint& startingPos, const GlobalVector& startingDir,
9  const PropagationDirection propDir) :
10  theX0(startingPos),
11  theP0(startingDir.unit()),
12  thePropDir(propDir) {}
13 
14 std::pair<bool,double>
16 {
17  //
18  // radius of cylinder and transversal position relative to axis
19  //
20  double R(cylinder.radius());
21  GlobalPoint axis(cylinder.toGlobal(Cylinder::LocalPoint(0.,0.)));
22  PositionType2D xt2d(theX0.x()-axis.x(),theX0.y()-axis.y());
23  //
24  // transverse direction
25  //
26  DirectionType2D pt2d(theP0.x(),theP0.y());
27  //
28  // solution of quadratic equation for s - assume |theP0|=1
29  //
30  RealQuadEquation eq(pt2d.mag2(),2.*xt2d.dot(pt2d),xt2d.mag2()-R*R);
31  if ( !eq.hasSolution ) return std::pair<bool,double>(false,0.);
32  //
33  // choice of solution and verification of direction
34  //
35  return chooseSolution(eq.first,eq.second);
36 }
37 
38 std::pair<bool,double>
40  const double s2) const
41 {
42  //
43  // follows the logic implemented in HelixBarrelCylinderCrossing
44  //
45  if ( thePropDir==anyDirection ) {
46  return std::pair<bool,double>(true,(fabs(s1)<fabs(s2)?s1:s2));
47  }
48  else {
49  int propSign = thePropDir==alongMomentum ? 1 : -1;
50  if ( s1*s2 < 0) {
51  // if different signs return the positive one
52  return std::pair<bool,double>(true,((s1*propSign>0)?s1:s2));
53  }
54  else if ( s1*propSign>0 ) {
55  // if both positive, return the shortest
56  return std::pair<bool,double>(true,(fabs(s1)<fabs(s2)?s1:s2));
57  }
58  }
59  return std::pair<bool,double>(false,0.);
60 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T y() const
Definition: PV3DBase.h:63
std::pair< bool, double > chooseSolution(const double s1, const double s2) const
Chooses the right solution w.r.t. the propagation direction.
PropagationDirection
tuple s2
Definition: indexGen.py:106
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:67
Vector3DBase unit() const
Definition: Vector3DBase.h:57
StraightLineBarrelCylinderCrossing(const GlobalPoint &startingPos, const GlobalVector &startingDir, const PropagationDirection propDir)
std::pair< bool, double > pathLength(const Cylinder &cyl) const
T x() const
Definition: PV3DBase.h:62