6 #include <vdt/vdtMath.h>
18 while(not
v.compare_exchange_weak(old,t)) {
22 mutable std::atomic<int>
v {100};
33 HelixArbitraryPlaneCrossing::HelixArbitraryPlaneCrossing(
const PositionType&
point,
34 const DirectionType& direction,
37 theQuadraticCrossingFromStart(point,direction,curvature,propDir),
51 double px = direction.x();
52 double py = direction.y();
53 double pz = direction.z();
54 double pt2 = px*px+py*py;
55 double p2 = pt2+pz*pz;
56 double pI = 1./
sqrt(p2);
57 double ptI = 1./
sqrt(pt2);
61 theSinTheta = pt2*ptI*pI;
66 std::pair<bool,double>
67 HelixArbitraryPlaneCrossing::pathLength(
const Plane& plane) {
75 float maxNumDz = theNumericalPrecision*plane.
position().
mag();
76 float safeMaxDist = (theMaxDistToPlane>maxNumDz?theMaxDistToPlane:maxNumDz);
82 if (
std::abs(dz)<safeMaxDist)
return std::make_pair(
true,0.);
87 std::tie(notFail,dSTotal) = theQuadraticCrossingFromStart.pathLength(plane);
89 auto xnew = positionInDouble(dSTotal);
91 auto propDir = thePropDir;
104 while ( notAtSurface(plane,xnew,safeMaxDist) ) {
109 LogDebug(
"HelixArbitraryPlaneCrossing") <<
"pathLength : no convergence";
110 return std::pair<bool,double>(
false,0);
115 auto pnew = directionInDouble(dSTotal);
116 HelixArbitraryPlaneCrossing2Order quadraticCrossing(xnew.x(),xnew.y(),xnew.z(),
118 theCosTheta,theSinTheta,
122 auto deltaS2 = quadraticCrossing.pathLength(plane);
129 dSTotal += deltaS2.
second;
135 if unlikely( newDir!=propDir )
return std::pair<
bool,
double>(false,0);
140 xnew = positionInDouble(dSTotal);
153 HelixArbitraryPlaneCrossing::
position (
double s)
const {
155 PositionTypeDouble pos = positionInDouble(s);
161 HelixArbitraryPlaneCrossing::PositionTypeDouble
162 HelixArbitraryPlaneCrossing::positionInDouble (
double s)
const {
168 theCachedDPhi = theCachedS*theRho*theSinTheta;
169 vdt::fast_sincos(theCachedDPhi,theCachedSDPhi,theCachedCDPhi);
178 double o = 1./theRho;
179 return PositionTypeDouble(theX0+(-theSinPhi0*(1.-theCachedCDPhi)+theCosPhi0*theCachedSDPhi)*o,
180 theY0+( theCosPhi0*(1.-theCachedCDPhi)+theSinPhi0*theCachedSDPhi)*o,
181 theZ0+theCachedS*theCosTheta);
193 return theQuadraticCrossingFromStart.positionInDouble(theCachedS);
200 HelixArbitraryPlaneCrossing::direction (
double s)
const {
202 DirectionTypeDouble
dir = directionInDouble(s);
203 return DirectionType(dir.x(),dir.y(),dir.z());
208 HelixArbitraryPlaneCrossing::DirectionTypeDouble
209 HelixArbitraryPlaneCrossing::directionInDouble (
double s)
const {
215 theCachedDPhi = theCachedS*theRho*theSinTheta;
216 vdt::fast_sincos(theCachedDPhi,theCachedSDPhi,theCachedCDPhi);
221 return DirectionTypeDouble(theCosPhi0*theCachedCDPhi-theSinPhi0*theCachedSDPhi,
222 theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi,
223 theCosTheta/theSinTheta);
227 return theQuadraticCrossingFromStart.directionInDouble(theCachedS);
232 bool HelixArbitraryPlaneCrossing::notAtSurface (
const Plane& plane,
233 const PositionTypeDouble&
point,
239 const float HelixArbitraryPlaneCrossing::theNumericalPrecision = 5.e-7
f;
240 const float HelixArbitraryPlaneCrossing::theMaxDistToPlane = 1.e-4
f;
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)
Abs< T >::type abs(const T &t)
static const MaxIter maxiter
return(e1-e2)*(e1-e2)+dp *dp
void operator()(int) const
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