6 #include <vdt/vdtMath.h>
10 HelixArbitraryPlaneCrossing::HelixArbitraryPlaneCrossing(
const PositionType&
point,
11 const DirectionType& direction,
14 theQuadraticCrossingFromStart(point,direction,curvature,propDir),
28 double px = direction.x();
29 double py = direction.y();
30 double pz = direction.z();
31 double pt2 = px*px+py*py;
32 double p2 = pt2+pz*pz;
33 double pI = 1./
sqrt(p2);
34 double ptI = 1./
sqrt(pt2);
38 theSinTheta = pt2*ptI*pI;
43 std::pair<bool,double>
44 HelixArbitraryPlaneCrossing::pathLength(
const Plane& plane) {
48 const int maxIterations(100);
52 float maxNumDz = theNumericalPrecision*plane.
position().
mag();
53 float safeMaxDist = (theMaxDistToPlane>maxNumDz?theMaxDistToPlane:maxNumDz);
58 PositionTypeDouble xnew(theX0,theY0,theZ0);
59 DirectionTypeDouble pnew(theCosPhi0,theSinPhi0,theCosTheta/theSinTheta);
67 while ( notAtSurface(plane,xnew,safeMaxDist) ) {
72 edm::LogInfo(
"HelixArbitraryPlaneCrossing") <<
"pathLength : no convergence";
73 return std::pair<bool,double>(
false,0);
80 std::pair<bool,double> deltaS2;
83 deltaS2 = theQuadraticCrossingFromStart.pathLength(plane);
86 HelixArbitraryPlaneCrossing2Order quadraticCrossing(xnew.x(),xnew.y(),xnew.z(),
88 theCosTheta,theSinTheta,
92 deltaS2 = quadraticCrossing.pathLength(plane);
110 xnew = positionInDouble(dSTotal);
111 pnew = directionInDouble(dSTotal);
122 HelixArbitraryPlaneCrossing::
position (
double s)
const {
124 PositionTypeDouble pos = positionInDouble(s);
130 HelixArbitraryPlaneCrossing::PositionTypeDouble
131 HelixArbitraryPlaneCrossing::positionInDouble (
double s)
const {
137 theCachedDPhi = theCachedS*theRho*theSinTheta;
138 vdt::fast_sincos(theCachedDPhi,theCachedSDPhi,theCachedCDPhi);
147 double o = 1./theRho;
148 return PositionTypeDouble(theX0+(-theSinPhi0*(1.-theCachedCDPhi)+theCosPhi0*theCachedSDPhi)*o,
149 theY0+( theCosPhi0*(1.-theCachedCDPhi)+theSinPhi0*theCachedSDPhi)*o,
150 theZ0+theCachedS*theCosTheta);
162 return theQuadraticCrossingFromStart.positionInDouble(theCachedS);
169 HelixArbitraryPlaneCrossing::direction (
double s)
const {
171 DirectionTypeDouble
dir = directionInDouble(s);
172 return DirectionType(dir.x(),dir.y(),dir.z());
177 HelixArbitraryPlaneCrossing::DirectionTypeDouble
178 HelixArbitraryPlaneCrossing::directionInDouble (
double s)
const {
184 theCachedDPhi = theCachedS*theRho*theSinTheta;
185 theCachedSDPhi =
sin(theCachedDPhi);
186 theCachedCDPhi =
cos(theCachedDPhi);
191 return DirectionTypeDouble(theCosPhi0*theCachedCDPhi-theSinPhi0*theCachedSDPhi,
192 theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi,
193 theCosTheta/theSinTheta);
197 return theQuadraticCrossingFromStart.directionInDouble(theCachedS);
202 bool HelixArbitraryPlaneCrossing::notAtSurface (
const Plane& plane,
203 const PositionTypeDouble& point,
209 const float HelixArbitraryPlaneCrossing::theNumericalPrecision = 5.e-7
f;
210 const float HelixArbitraryPlaneCrossing::theMaxDistToPlane = 1.e-4
f;
Sin< T >::type sin(const T &t)
float localZ(const GlobalPoint &gp) const
static int position[TOTALCHAMBERS][3]
Point3DBase< Scalar, GlobalTag > PositionType
U second(std::pair< T, U > const &p)
T curvature(T InversePt, const edm::EventSetup &iSetup)
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
return(e1-e2)*(e1-e2)+dp *dp
volatile std::atomic< bool > shutdown_flag false
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