CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HelixArbitraryPlaneCrossing2Order Class Reference

#include <HelixArbitraryPlaneCrossing2Order.h>

Inheritance diagram for HelixArbitraryPlaneCrossing2Order:
HelixPlaneCrossing

Public Types

typedef Basic3DVector< double > DirectionTypeDouble
 
typedef Basic3DVector< double > PositionTypeDouble
 
- Public Types inherited from HelixPlaneCrossing
typedef Basic3DVector< float > DirectionType
 
typedef Basic3DVector< float > PositionType
 the helix is passed to the constructor and does not appear in the interface More...
 

Public Member Functions

virtual DirectionType direction (double s) const
 
DirectionTypeDouble directionInDouble (double s) const
 
 HelixArbitraryPlaneCrossing2Order (const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum)
 
 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)
 
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
 

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().

13  :
14  theX0(point.x()),
15  theY0(point.y()),
16  theZ0(point.z()),
18  thePropDir(propDir)
19 {
20  //
21  // Components of direction vector (with correct normalisation)
22  //
23  double px = direction.x();
24  double py = direction.y();
25  double pz = direction.z();
26  double pt2 = px*px+py*py;
27  double p2 = pt2+pz*pz;
28  double pI = 1./sqrt(p2);
29  double ptI = 1./sqrt(pt2);
30  theCosPhi0 = px*ptI;
31  theSinPhi0 = py*ptI;
32  theCosTheta = pz*pI;
33  theSinThetaI = p2*pI*ptI; // (1/(pt/p)) = p/pt = p*ptI and p = p2/p = p2*pI
34 }
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
T curvature(T InversePt, const edm::EventSetup &iSetup)
T z() const
Cartesian z coordinate.
T sqrt(T t)
Definition: SSEVec.h:48
double p2[4]
Definition: TauolaWrapper.h:90
virtual DirectionType direction(double s) 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
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
virtual HelixArbitraryPlaneCrossing2Order::~HelixArbitraryPlaneCrossing2Order ( )
inlinevirtual

Definition at line 34 of file HelixArbitraryPlaneCrossing2Order.h.

34 {}

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().

122  {
123  // use double precision result
125  return DirectionType(dir.x(),dir.y(),dir.z());
126 }
DirectionTypeDouble directionInDouble(double s) const
Basic3DVector< float > DirectionType
dbl *** dir
Definition: mlp_gen.cc:35
HelixArbitraryPlaneCrossing2Order::DirectionTypeDouble HelixArbitraryPlaneCrossing2Order::directionInDouble ( double  s) const
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 funct::abs(), alignCSCRings::e, likely, Plane::localZ(), Plane::normalVector(), solutionByDirection(), mathSSE::sqrt(), theCosPhi0, theCosTheta, theRho, theSinPhi0, theSinThetaI, theX0, theY0, theZ0, unlikely, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by PixelForwardLayer::computeCrossings(), PixelForwardLayerPhase1::computeCrossings(), and HelixArbitraryPlaneCrossing::pathLength().

40  {
41  //
42  // get local z-vector in global co-ordinates and
43  // distance to starting point
44  //
45  GlobalVector normalToPlane = plane.normalVector();
46  double nPx = normalToPlane.x();
47  double nPy = normalToPlane.y();
48  double nPz = normalToPlane.z();
49  double cP = plane.localZ(GlobalPoint(theX0,theY0,theZ0));
50  //
51  // coefficients of 2nd order equation to obtain intersection point
52  // in approximation (without curvature-related factors).
53  //
54  double ceq1 = theRho*(nPx*theSinPhi0-nPy*theCosPhi0);
55  double ceq2 = nPx*theCosPhi0 + nPy*theSinPhi0 + nPz*theCosTheta*theSinThetaI;
56  double ceq3 = cP;
57  //
58  // Check for degeneration to linear equation (zero
59  // curvature, forward plane or direction perp. to plane)
60  //
61  double dS1,dS2;
62  if likely( std::abs(ceq1)>FLT_MIN ) {
63  double deq1 = ceq2*ceq2;
64  double deq2 = ceq1*ceq3;
65  if ( std::abs(deq1)<FLT_MIN || std::abs(deq2/deq1)>1.e-6 ) {
66  //
67  // Standard solution for quadratic equations
68  //
69  double deq = deq1+2*deq2;
70  if unlikely( deq<0. ) return std::pair<bool,double>(false,0);
71  double ceq = ceq2+std::copysign(std::sqrt(deq),ceq2);
72  dS1 = (ceq/ceq1)*theSinThetaI;
73  dS2 = -2.*(ceq3/ceq)*theSinThetaI;
74  }
75  else {
76  //
77  // Solution by expansion of sqrt(1+deq)
78  //
79  double ceq = (ceq2/ceq1)*theSinThetaI;
80  double deq = deq2/deq1;
81  deq *= (1-0.5*deq);
82  dS1 = -ceq*deq;
83  dS2 = ceq*(2+deq);
84  }
85  }
86  else {
87  //
88  // Special case: linear equation
89  //
90  dS1 = dS2 = -(ceq3/ceq2)*theSinThetaI;
91  }
92  //
93  // Choose and return solution
94  //
95  return solutionByDirection(dS1,dS2);
96 }
GlobalVector normalVector() const
Definition: Plane.h:45
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:49
return((rh^lh)&mask)
else
Definition: XrdSource.cc:104
#define unlikely(x)
#define likely(x)
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< bool, double > solutionByDirection(const double dS1, const double dS2) const
volatile std::atomic< bool > shutdown_flag false
T x() const
Definition: PV3DBase.h:62
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 positionInDouble(), Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by PixelForwardLayer::computeCrossings(), and PixelForwardLayerPhase1::computeCrossings().

102  {
103  // use double precision result
105  return PositionType(pos.x(),pos.y(),pos.z());
106 }
PositionTypeDouble positionInDouble(double s) const
Basic3DVector< float > PositionType
the helix is passed to the constructor and does not appear in the interface
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().

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().

66  {
67  return fabs(firstPathLength)<fabs(secondPathLength) ? firstPathLength : secondPathLength;
68  }
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, cmsHarvester::path, indexGen::s2, smallestPathLength(), std::swap(), and thePropDir.

Referenced by pathLength().

143  {
144  bool valid = false;
145  double path = 0;
146  if ( thePropDir == anyDirection ) {
147  valid = true;
148  path = smallestPathLength(dS1,dS2);
149  }
150  else {
151  // use same logic for both directions (invert if necessary)
152  double propSign = thePropDir==alongMomentum ? 1 : -1;
153  double s1(propSign*dS1);
154  double s2(propSign*dS2);
155  // sort
156  if ( s1 > s2 ) std::swap(s1,s2);
157  // choose solution (if any with positive sign)
158  if ( (s1<0) & (s2>=0) ) {
159  // First solution in backward direction: choose second one.
160  valid = true;
161  path = propSign*s2;
162  }
163  else if ( s1>=0 ) {
164  // First solution in forward direction: choose it (s2 is further away!).
165  valid = true;
166  path = propSign*s1;
167  }
168  }
169  return std::pair<bool,double>(valid,path);
170 }
double smallestPathLength(const double firstPathLength, const double secondPathLength) const
tuple s2
Definition: indexGen.py:106
tuple path
else: Piece not in the list, fine.
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)

Member Data Documentation

double HelixArbitraryPlaneCrossing2Order::theCosPhi0
private
double HelixArbitraryPlaneCrossing2Order::theCosTheta
private
const PropagationDirection HelixArbitraryPlaneCrossing2Order::thePropDir
private

Definition at line 81 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by solutionByDirection().

const double HelixArbitraryPlaneCrossing2Order::theRho
private
double HelixArbitraryPlaneCrossing2Order::theSinPhi0
private
double HelixArbitraryPlaneCrossing2Order::theSinThetaI
private
const double HelixArbitraryPlaneCrossing2Order::theX0
private

Definition at line 77 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by pathLength(), and positionInDouble().

const double HelixArbitraryPlaneCrossing2Order::theY0
private

Definition at line 77 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by pathLength(), and positionInDouble().

const double HelixArbitraryPlaneCrossing2Order::theZ0
private

Definition at line 77 of file HelixArbitraryPlaneCrossing2Order.h.

Referenced by pathLength(), and positionInDouble().