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 <vdt/vdtMath.h>
6 #include <cfloat>
7 
8 HelixForwardPlaneCrossing::HelixForwardPlaneCrossing(const PositionType& point,
9  const DirectionType& direction,
10  const float curvature,
11  const PropagationDirection propDir) :
12  theX0(point.x()),
13  theY0(point.y()),
14  theZ0(point.z()),
15  theRho(curvature),
16  thePropDir(propDir),
17  theCachedS(0),
18  theCachedDPhi(0.),
19  theCachedSDPhi(0.),
20  theCachedCDPhi(1.)
21 {
22  //
23  // Components of direction vector (with correct normalisation)
24  //
25  double px = direction.x();
26  double py = direction.y();
27  double pz = direction.z();
28  double pt2 = px*px+py*py;
29  double p2 = pt2+pz*pz;
30  double pI = 1./sqrt(p2);
31  double ptI = 1./sqrt(pt2);
32  theCosPhi0 = px*ptI;
33  theSinPhi0 = py*ptI;
34  theCosTheta = pz*pI;
35  theSinTheta = pt2*ptI*pI;
36 
37 }
38 //
39 // Propagation status and path length to intersection
40 //
41 std::pair<bool,double>
42 HelixForwardPlaneCrossing::pathLength(const Plane& plane) {
43  //
44  // Protect against p_z=0 and calculate path length
45  //
46  if ( std::abs(theCosTheta/theSinTheta)<FLT_MIN ) return std::pair<bool,double>(false,0);
47 
48  double dS = (plane.position().z()-theZ0) / theCosTheta;
49 
50  if ( (thePropDir==alongMomentum && dS<0.) ||
51  (thePropDir==oppositeToMomentum && dS>0.) ) return std::pair<bool,double>(false,0);
52  //
53  // Return result
54  //
55  return std::pair<bool,double>(true,dS);
56 }
57 //
58 // Position on helix after a step of path length s.
59 //
62  //
63  // Calculate delta phi (if not already available)
64  //
65  if ( s!=theCachedS ) {
66  theCachedS = s;
67  theCachedDPhi = theCachedS*theRho*theSinTheta;
68  vdt::fast_sincos(theCachedDPhi,theCachedSDPhi,theCachedCDPhi);
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;
78  return PositionTypeDouble(theX0+(-theSinPhi0*(1.-theCachedCDPhi)+theCosPhi0*theCachedSDPhi)*o,
79  theY0+( theCosPhi0*(1.-theCachedCDPhi)+theSinPhi0*theCachedSDPhi)*o,
80  theZ0+theCachedS*theCosTheta);
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 //
94 HelixForwardPlaneCrossing::direction (double s) const {
95  //
96  // Calculate delta phi (if not already available)
97  //
98  if ( s!=theCachedS ) {
99  theCachedS = s;
100  theCachedDPhi = theCachedS*theRho*theSinTheta;
101  theCachedSDPhi = sin(theCachedDPhi);
102  theCachedCDPhi = cos(theCachedDPhi);
103  }
104 
105  if ( fabs(theCachedDPhi)>1.e-4 ) {
106  // full helix formula
107  return DirectionType(theCosPhi0*theCachedCDPhi-theSinPhi0*theCachedSDPhi,
108  theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi,
109  theCosTheta/theSinTheta);
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 
120 const float HelixForwardPlaneCrossing::theNumericalPrecision = 5.e-7;
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PropagationDirection
Definition: Plane.h:17
float float float z
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:30
T curvature(T InversePt, const edm::EventSetup &iSetup)
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double p2[4]
Definition: TauolaWrapper.h:90
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