CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

HelixArbitraryPlaneCrossing2Order Class Reference

#include <HelixArbitraryPlaneCrossing2Order.h>

Inheritance diagram for HelixArbitraryPlaneCrossing2Order:
HelixPlaneCrossing

List of all members.

Public Types

typedef Basic3DVector< double > DirectionTypeDouble
typedef Basic3DVector< double > PositionTypeDouble

Public Member Functions

virtual DirectionType direction (double s) const
DirectionTypeDouble directionInDouble (double s) const
 HelixArbitraryPlaneCrossing2Order (const double &x0, const double &y0, const double &z0, const double &cosPhi0, const double &sinPhi0, const double &cosTheta, const double &sinTheta, const double &rho, const PropagationDirection propDir=alongMomentum)
 HelixArbitraryPlaneCrossing2Order (const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum)
virtual std::pair< bool, double > pathLength (const Plane &)
virtual PositionType position (double s) const
PositionTypeDouble positionInDouble (double s) const
double smallestPathLength (const double firstPathLength, const double secondPathLength) const
virtual ~HelixArbitraryPlaneCrossing2Order ()

Private Member Functions

std::pair< bool, double > solutionByDirection (const double dS1, const double dS2) const dso_internal

Private Attributes

double theCosPhi0
double theCosTheta
const PropagationDirection thePropDir
const double theRho
double theSinPhi0
double theSinThetaI
const double theX0
const double theY0
const double theZ0

Detailed Description

Calculates intersections of a helix with planes of any orientation using a parabolic approximation.

Definition at line 10 of file HelixArbitraryPlaneCrossing2Order.h.


Member Typedef Documentation

Definition at line 53 of file HelixArbitraryPlaneCrossing2Order.h.

Definition at line 52 of file HelixArbitraryPlaneCrossing2Order.h.


Constructor & Destructor Documentation

HelixArbitraryPlaneCrossing2Order::HelixArbitraryPlaneCrossing2Order ( const PositionType point,
const DirectionType direction,
const float  curvature,
const PropagationDirection  propDir = alongMomentum 
)

Constructor using point, direction and (transverse!) curvature.

Definition at line 10 of file HelixArbitraryPlaneCrossing2Order.cc.

References p2, mathSSE::sqrt(), theCosPhi0, theCosTheta, theSinPhi0, theSinThetaI, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

                                                                                                         :
  theX0(point.x()),
  theY0(point.y()),
  theZ0(point.z()),
  theRho(curvature),
  thePropDir(propDir)
{
  //
  // Components of direction vector (with correct normalisation)
  //
  double px = direction.x();
  double py = direction.y();
  double pz = direction.z();
  double pt2 = px*px+py*py;
  double p2 = pt2+pz*pz;
  double pI = 1./sqrt(p2);
  double ptI = 1./sqrt(pt2);
  theCosPhi0 = px*ptI;
  theSinPhi0 = py*ptI;
  theCosTheta = pz*pI;
  theSinThetaI = p2*pI*ptI; //  (1/(pt/p)) = p/pt = p*ptI and p = p2/p = p2*pI
}
HelixArbitraryPlaneCrossing2Order::HelixArbitraryPlaneCrossing2Order ( const double &  x0,
const double &  y0,
const double &  z0,
const double &  cosPhi0,
const double &  sinPhi0,
const double &  cosTheta,
const double &  sinTheta,
const double &  rho,
const PropagationDirection  propDir = alongMomentum 
) [inline]

Fast constructor (for use by HelixArbitraryPlaneCrossing).

Definition at line 22 of file HelixArbitraryPlaneCrossing2Order.h.

                                                                                        :
    theX0(x0), theY0(y0), theZ0(z0),
    theCosPhi0(cosPhi0), theSinPhi0(sinPhi0),
    theCosTheta(cosTheta), theSinThetaI(1./sinTheta),
    theRho(rho), 
    thePropDir(propDir) {}
virtual HelixArbitraryPlaneCrossing2Order::~HelixArbitraryPlaneCrossing2Order ( ) [inline, virtual]

Definition at line 34 of file HelixArbitraryPlaneCrossing2Order.h.

{}

Member Function Documentation

HelixPlaneCrossing::DirectionType HelixArbitraryPlaneCrossing2Order::direction ( double  s) const [virtual]

Direction at pathlength s from the starting point.

Implements HelixPlaneCrossing.

Definition at line 122 of file HelixArbitraryPlaneCrossing2Order.cc.

References dir, directionInDouble(), Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

                                                            {
  // use double precision result
  DirectionTypeDouble dir = directionInDouble(s);
  return DirectionType(dir.x(),dir.y(),dir.z());
}
HelixArbitraryPlaneCrossing2Order::DirectionTypeDouble HelixArbitraryPlaneCrossing2Order::directionInDouble ( double  s) const

Direction at pathlength s from the starting point in double precision.

Definition at line 131 of file HelixArbitraryPlaneCrossing2Order.cc.

References theCosPhi0, theCosTheta, theRho, theSinPhi0, and theSinThetaI.

Referenced by direction(), and HelixArbitraryPlaneCrossing::directionInDouble().

                                                                    {
  // based on delta phi
  double dph = s*theRho/theSinThetaI;
  return DirectionTypeDouble(theCosPhi0-(theSinPhi0+0.5*dph*theCosPhi0)*dph,
                             theSinPhi0+(theCosPhi0-0.5*dph*theSinPhi0)*dph,
                             theCosTheta*theSinThetaI);
}
std::pair< bool, double > HelixArbitraryPlaneCrossing2Order::pathLength ( const Plane plane) [virtual]

Propagation status (true if valid) and (signed) path length along the helix from the starting point to the plane. The starting point is given in the constructor.

Implements HelixPlaneCrossing.

Definition at line 40 of file HelixArbitraryPlaneCrossing2Order.cc.

References alignCSCRings::e, likely, Plane::localZ(), Plane::normalVector(), solutionByDirection(), mathSSE::sqrt(), theCosPhi0, theCosTheta, theRho, theSinPhi0, theSinThetaI, theX0, theY0, theZ0, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by HelixArbitraryPlaneCrossing::pathLength().

                                                                {
  //
  // get local z-vector in global co-ordinates and
  // distance to starting point
  //
  GlobalVector normalToPlane = plane.normalVector();
  double nPx = normalToPlane.x();
  double nPy = normalToPlane.y();
  double nPz = normalToPlane.z();
  double cP = plane.localZ(GlobalPoint(theX0,theY0,theZ0));
  //
  // coefficients of 2nd order equation to obtain intersection point
  // in approximation (without curvature-related factors).
  //
  double ceq1 = theRho*(nPx*theSinPhi0-nPy*theCosPhi0);
  double ceq2 = nPx*theCosPhi0 + nPy*theSinPhi0 + nPz*theCosTheta*theSinThetaI;
  double ceq3 = cP;
  //
  // Check for degeneration to linear equation (zero
  //   curvature, forward plane or direction perp. to plane)
  //
  double dS1,dS2;
  if likely( fabs(ceq1)>FLT_MIN ) {
    double deq1 = ceq2*ceq2;
    double deq2 = ceq1*ceq3;
    if ( fabs(deq1)<FLT_MIN || fabs(deq2/deq1)>1.e-6 ) {
      //
      // Standard solution for quadratic equations
      //
      double deq = deq1+2*deq2;
      if likely( deq<0. )  return std::pair<bool,double>(false,0);
      double ceq = -0.5*(ceq2+(ceq2>0?1:-1)*sqrt(deq));
      dS1 = -2*(ceq/ceq1)*theSinThetaI;
      dS2 = (ceq3/ceq)*theSinThetaI;
    }
    else {
      //
      // Solution by expansion of sqrt(1+deq)
      //
      double ceq = (ceq2/ceq1)*theSinThetaI;
      double deq = deq2/deq1;
      deq *= (1-0.5*deq);
      dS1 = -ceq*deq;
      dS2 = ceq*(2+deq);
    }
  }
  else {
    //
    // Special case: linear equation
    //
    dS1 = dS2 = -(ceq3/ceq2)*theSinThetaI;
  }
  //
  // Choose and return solution
  //
  return solutionByDirection(dS1,dS2);
}
HelixPlaneCrossing::PositionType HelixArbitraryPlaneCrossing2Order::position ( double  s) const [virtual]

Position at pathlength s from the starting point.

Implements HelixPlaneCrossing.

Definition at line 102 of file HelixArbitraryPlaneCrossing2Order.cc.

References pos, positionInDouble(), Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

                                                           {
  // use double precision result
  PositionTypeDouble pos = positionInDouble(s);
  return PositionType(pos.x(),pos.y(),pos.z());
}
HelixArbitraryPlaneCrossing2Order::PositionTypeDouble HelixArbitraryPlaneCrossing2Order::positionInDouble ( double  s) const

Position at pathlength s from the starting point in double precision.

Definition at line 111 of file HelixArbitraryPlaneCrossing2Order.cc.

References theCosPhi0, theCosTheta, theRho, theSinPhi0, theSinThetaI, theX0, theY0, and theZ0.

Referenced by position(), and HelixArbitraryPlaneCrossing::positionInDouble().

                                                                   {
  // based on path length in the transverse plane
  double st = s/theSinThetaI;
  return PositionTypeDouble(theX0+(theCosPhi0-(st*0.5*theRho)*theSinPhi0)*st,
                            theY0+(theSinPhi0+(st*0.5*theRho)*theCosPhi0)*st,
                            theZ0+st*theCosTheta*theSinThetaI);
}
double HelixArbitraryPlaneCrossing2Order::smallestPathLength ( const double  firstPathLength,
const double  secondPathLength 
) const [inline]

Pathlength to closest solution.

Definition at line 65 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by solutionByDirection().

                                                                         {
    return fabs(firstPathLength)<fabs(secondPathLength) ? firstPathLength : secondPathLength;
  }
std::pair< bool, double > HelixArbitraryPlaneCrossing2Order::solutionByDirection ( const double  dS1,
const double  dS2 
) const [private]

Choice of one of two solutions according to the propagation direction.

Definition at line 142 of file HelixArbitraryPlaneCrossing2Order.cc.

References alongMomentum, anyDirection, printConversionInfo::aux, getHLTPrescaleColumns::path, indexGen::s2, smallestPathLength(), thePropDir, and TrackValidation_HighPurity_cff::valid.

Referenced by pathLength().

                                                                               {
  bool valid = false;
  double path = 0;
  if ( thePropDir == anyDirection ) {
    valid = true;
    path = smallestPathLength(dS1,dS2);
  }
  else {
    // use same logic for both directions (invert if necessary)
    double propSign = thePropDir==alongMomentum ? 1 : -1;
    double s1(propSign*dS1);
    double s2(propSign*dS2);
    // sort
    if ( s1 > s2 ) {
      double aux = s1;
      s1 = s2;
      s2 = aux;
    }
    // choose solution (if any with positive sign)
    if ( s1<0 && s2>=0 ) {
      // First solution in backward direction: choose second one.
      valid = true;
      path = propSign*s2;
    }
    else if ( s1>=0 ) {
      // First solution in forward direction: choose it (s2 is further away!).
      valid = true;
      path = propSign*s1;
    }
  }
  return std::pair<bool,double>(valid,path);
}

Member Data Documentation

Definition at line 81 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by solutionByDirection().

Definition at line 77 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by pathLength(), and positionInDouble().

Definition at line 77 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by pathLength(), and positionInDouble().

Definition at line 77 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by pathLength(), and positionInDouble().