CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HelixForwardPlaneCrossing.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <cfloat>
6 
8  const DirectionType& direction,
9  const float curvature,
10  const PropagationDirection propDir) :
11  theX0(point.x()),
12  theY0(point.y()),
13  theZ0(point.z()),
14  theRho(curvature),
15  thePropDir(propDir),
16  theCachedS(0),
17  theCachedDPhi(0.),
18  theCachedSDPhi(0.),
19  theCachedCDPhi(1.)
20 {
21  //
22  // Components of direction vector (with correct normalisation)
23  //
24  double px = direction.x();
25  double py = direction.y();
26  double pz = direction.z();
27  double pt2 = px*px+py*py;
28  double p2 = pt2+pz*pz;
29  double pI = 1./sqrt(p2);
30  double ptI = 1./sqrt(pt2);
31  theCosPhi0 = px*ptI;
32  theSinPhi0 = py*ptI;
33  theCosTheta = pz*pI;
34  theSinTheta = pt2*ptI*pI;
35 
36 }
37 //
38 // Propagation status and path length to intersection
39 //
40 std::pair<bool,double>
42  //
43  // Protect against p_z=0 and calculate path length
44  //
45  if ( std::abs(theCosTheta/theSinTheta)<FLT_MIN ) return std::pair<bool,double>(false,0);
46 
47  double dS = (plane.position().z()-theZ0) / theCosTheta;
48 
49  if ( (thePropDir==alongMomentum && dS<0.) ||
50  (thePropDir==oppositeToMomentum && dS>0.) ) return std::pair<bool,double>(false,0);
51  //
52  // Return result
53  //
54  return std::pair<bool,double>(true,dS);
55 }
56 //
57 // Position on helix after a step of path length s.
58 //
61  //
62  // Calculate delta phi (if not already available)
63  //
64  if ( s!=theCachedS ) {
65  theCachedS = s;
69  }
70  //
71  // Calculate with appropriate formulation of full helix formula or with
72  // 2nd order approximation.
73  //
74  if ( std::abs(theCachedDPhi)>1.e-4 ) {
75  // "standard" helix formula
76  // "standard" helix formula
77  double o = 1./theRho;
79  theY0+( theCosPhi0*(1.-theCachedCDPhi)+theSinPhi0*theCachedSDPhi)*o,
81  }
82  else {
83  // 2nd order
84  double st = theCachedS*theSinTheta;
85  return PositionType(theX0+(theCosPhi0-st*0.5*theRho*theSinPhi0)*st,
86  theY0+(theSinPhi0+st*0.5*theRho*theCosPhi0)*st,
87  theZ0+st*theCosTheta/theSinTheta);
88  }
89 }
90 //
91 // Direction vector on helix after a step of path length s.
92 //
95  //
96  // Calculate delta phi (if not already available)
97  //
98  if ( s!=theCachedS ) {
99  theCachedS = s;
103  }
104 
105  if ( fabs(theCachedDPhi)>1.e-4 ) {
106  // full helix formula
108  theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi,
110  }
111  else {
112  // 2nd order
113  double dph = theCachedS*theRho*theSinTheta;
114  return DirectionType(theCosPhi0-(theSinPhi0+0.5*theCosPhi0*dph)*dph,
115  theSinPhi0+(theCosPhi0-0.5*theSinPhi0*dph)*dph,
116  theCosTheta/theSinTheta);
117  }
118 }
119 
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
virtual PositionType position(double s) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define abs(x)
Definition: mlp_lapack.h:159
PropagationDirection
Definition: Plane.h:17
double double double z
static const float theNumericalPrecision
T curvature(T InversePt, const edm::EventSetup &iSetup)
T z() const
Cartesian z coordinate.
T sqrt(T t)
Definition: SSEVec.h:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
HelixForwardPlaneCrossing(const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum)
Basic3DVector< float > PositionType
the helix is passed to the constructor and does not appear in the interface
Basic3DVector< float > DirectionType
double p2[4]
Definition: TauolaWrapper.h:90
Basic3DVector< double > PositionTypeDouble
virtual DirectionType direction(double s) const
const PropagationDirection thePropDir
string s
Definition: asciidump.py:422
Definition: DDAxes.h:10
const PositionType & position() const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
virtual std::pair< bool, double > pathLength(const Plane &plane)