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 | Static Private Attributes
HelixArbitraryPlaneCrossing Class Reference

#include <HelixArbitraryPlaneCrossing.h>

Inheritance diagram for HelixArbitraryPlaneCrossing:
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
 
 HelixArbitraryPlaneCrossing (const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum)
 
virtual std::pair< bool, double > pathLength (const Plane &plane)
 
virtual PositionType position (double s) const
 
PositionTypeDouble positionInDouble (double s) const
 
virtual ~HelixArbitraryPlaneCrossing ()
 

Private Member Functions

bool notAtSurface (const Plane &, const PositionTypeDouble &, const float) const dso_internal
 

Private Attributes

double theCachedCDPhi
 
double theCachedDPhi
 
double theCachedS
 
double theCachedSDPhi
 
double theCosPhi0
 
double theCosTheta
 
const PropagationDirection thePropDir
 
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
 
const double theRho
 
double theSinPhi0
 
double theSinTheta
 
const double theX0
 
const double theY0
 
const double theZ0
 

Static Private Attributes

static const float theMaxDistToPlane = 1.e-4f
 
static const float theNumericalPrecision = 5.e-7f
 

Detailed Description

Calculates intersections of a helix with planes of any orientation.

Definition at line 10 of file HelixArbitraryPlaneCrossing.h.

Member Typedef Documentation

Definition at line 38 of file HelixArbitraryPlaneCrossing.h.

Definition at line 37 of file HelixArbitraryPlaneCrossing.h.

Constructor & Destructor Documentation

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

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

Definition at line 9 of file HelixArbitraryPlaneCrossing.cc.

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

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

Definition at line 19 of file HelixArbitraryPlaneCrossing.h.

19 {}

Member Function Documentation

HelixPlaneCrossing::DirectionType HelixArbitraryPlaneCrossing::direction ( double  s) const
virtual

Direction at pathlength s from the starting point.

Implements HelixPlaneCrossing.

Definition at line 169 of file HelixArbitraryPlaneCrossing.cc.

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

Referenced by AnalyticalPropagator::propagateParametersOnPlane().

169  {
170  // use result in double precision
172  return DirectionType(dir.x(),dir.y(),dir.z());
173 }
DirectionTypeDouble directionInDouble(double s) const
Basic3DVector< float > DirectionType
Basic3DVector< double > DirectionTypeDouble
dbl *** dir
Definition: mlp_gen.cc:35
HelixArbitraryPlaneCrossing::DirectionTypeDouble HelixArbitraryPlaneCrossing::directionInDouble ( double  s) const

Direction at pathlength s from the starting point.

Definition at line 178 of file HelixArbitraryPlaneCrossing.cc.

References abs, funct::cos(), HelixArbitraryPlaneCrossing2Order::directionInDouble(), alignCSCRings::e, alignCSCRings::s, funct::sin(), theCachedCDPhi, theCachedDPhi, theCachedS, theCachedSDPhi, theCosPhi0, theCosTheta, theQuadraticCrossingFromStart, theRho, theSinPhi0, theSinTheta, and unlikely.

Referenced by direction(), and pathLength().

178  {
179  //
180  // Calculate delta phi (if not already available)
181  //
182  if unlikely( s!=theCachedS ) {
183  theCachedS = s;
187  }
188 
189  if ( std::abs(theCachedDPhi)>1.e-4 ) {
190  // full helix formula
192  theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi,
194  }
195  else {
196  // 2nd order
198  }
199 }
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
DirectionTypeDouble directionInDouble(double s) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define abs(x)
Definition: mlp_lapack.h:159
#define unlikely(x)
Definition: Likely.h:21
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Basic3DVector< double > DirectionTypeDouble
bool HelixArbitraryPlaneCrossing::notAtSurface ( const Plane plane,
const PositionTypeDouble point,
const float  maxDist 
) const
inlineprivate

Iteration control: check for significant distance to plane.

Definition at line 202 of file HelixArbitraryPlaneCrossing.cc.

References abs, Plane::localZ(), insertMaterial::maxDist, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by pathLength().

204  {
205  float dz = plane.localZ(Surface::GlobalPoint(point.x(),point.y(),point.z()));
206  return std::abs(dz)>maxDist;
207 }
float localZ(const GlobalPoint &gp) const
Fast access to distance from plane for a point.
Definition: Plane.h:52
#define abs(x)
Definition: mlp_lapack.h:159
*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
std::pair< bool, double > HelixArbitraryPlaneCrossing::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 43 of file HelixArbitraryPlaneCrossing.cc.

References alongMomentum, anyDirection, directionInDouble(), first, align_cfg::iteration, Basic3DVector< T >::mag(), notAtSurface(), oppositeToMomentum, HelixArbitraryPlaneCrossing2Order::pathLength(), GloballyPositioned< T >::position(), positionInDouble(), theCosPhi0, theCosTheta, theMaxDistToPlane, theNumericalPrecision, thePropDir, theQuadraticCrossingFromStart, theRho, theSinPhi0, theSinTheta, theX0, theY0, theZ0, unlikely, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by PathToPlane2Order::operator()().

43  {
44  //
45  // Constants used for control of convergence
46  //
47  const int maxIterations(100);
48  //
49  // maximum distance to plane (taking into account numerical precision)
50  //
51  float maxNumDz = theNumericalPrecision*plane.position().mag();
52  float safeMaxDist = (theMaxDistToPlane>maxNumDz?theMaxDistToPlane:maxNumDz);
53  //
54  // Prepare internal value of the propagation direction and position / direction vectors for iteration
55  //
59  //
60  // Prepare iterations: count and total pathlength
61  //
62  unsigned int iteration(maxIterations+1);
63  double dSTotal(0.);
64  //
65  bool first = true;
66  while ( notAtSurface(plane,xnew,safeMaxDist) ) {
67  //
68  // return empty solution vector if no convergence after maxIterations iterations
69  //
70  if unlikely( --iteration == 0 ) {
71  edm::LogInfo("HelixArbitraryPlaneCrossing") << "pathLength : no convergence";
72  return std::pair<bool,double>(false,0);
73  }
74 
75  //
76  // Use existing 2nd order object at first pass, create temporary object
77  // for subsequent passes.
78  //
79  std::pair<bool,double> deltaS2;
80  if unlikely( first ) {
81  first = false;
83  }
84  else {
85  HelixArbitraryPlaneCrossing2Order quadraticCrossing(xnew.x(),xnew.y(),xnew.z(),
86  pnew.x(),pnew.y(),
88  theRho,
89  anyDirection);
90 
91  deltaS2 = quadraticCrossing.pathLength(plane);
92  }
93 
94  if unlikely( !deltaS2.first ) return deltaS2;
95  //
96  // Calculate and sort total pathlength (max. 2 solutions)
97  //
98  dSTotal += deltaS2.second;
100  if ( propDir == anyDirection ) {
101  propDir = newDir;
102  }
103  else {
104  if unlikely( newDir!=propDir ) return std::pair<bool,double>(false,0);
105  }
106  //
107  // Step forward by dSTotal.
108  //
109  xnew = positionInDouble(dSTotal);
110  pnew = directionInDouble(dSTotal);
111  }
112  //
113  // Return result
114  //
115  return std::pair<bool,double>(true,dSTotal);
116 }
DirectionTypeDouble directionInDouble(double s) const
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
virtual std::pair< bool, double > pathLength(const Plane &)
Basic3DVector< double > PositionTypeDouble
const PropagationDirection thePropDir
PropagationDirection
U second(std::pair< T, U > const &p)
#define unlikely(x)
Definition: Likely.h:21
tuple iteration
Definition: align_cfg.py:5
bool notAtSurface(const Plane &, const PositionTypeDouble &, const float) const dso_internal
PositionTypeDouble positionInDouble(double s) const
bool first
Definition: L1TdeRCT.cc:94
Basic3DVector< double > DirectionTypeDouble
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
const PositionType & position() const
HelixPlaneCrossing::PositionType HelixArbitraryPlaneCrossing::position ( double  s) const
virtual

Position at pathlength s from the starting point.

Implements HelixPlaneCrossing.

Definition at line 121 of file HelixArbitraryPlaneCrossing.cc.

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

Referenced by AnalyticalPropagator::propagateParametersOnPlane().

121  {
122  // use result in double precision
124  return PositionType(pos.x(),pos.y(),pos.z());
125 }
Basic3DVector< double > PositionTypeDouble
PositionTypeDouble positionInDouble(double s) const
Basic3DVector< float > PositionType
the helix is passed to the constructor and does not appear in the interface
HelixArbitraryPlaneCrossing::PositionTypeDouble HelixArbitraryPlaneCrossing::positionInDouble ( double  s) const

Position at pathlength s from the starting point.

Definition at line 130 of file HelixArbitraryPlaneCrossing.cc.

References abs, funct::cos(), alignCSCRings::e, python.connectstrParser::o, HelixArbitraryPlaneCrossing2Order::positionInDouble(), alignCSCRings::s, funct::sin(), theCachedCDPhi, theCachedDPhi, theCachedS, theCachedSDPhi, theCosPhi0, theCosTheta, theQuadraticCrossingFromStart, theRho, theSinPhi0, theSinTheta, theX0, theY0, theZ0, and unlikely.

Referenced by pathLength(), and position().

130  {
131  //
132  // Calculate delta phi (if not already available)
133  //
134  if unlikely( s!=theCachedS ) {
135  theCachedS = s;
139  }
140  //
141  // Calculate with appropriate formulation of full helix formula or with
142  // 2nd order approximation.
143  //
144 // if ( fabs(theCachedDPhi)>1.e-1 ) {
145  if ( std::abs(theCachedDPhi)>1.e-4 ) {
146  // "standard" helix formula
147  double o = 1./theRho;
149  theY0+( theCosPhi0*(1.-theCachedCDPhi)+theSinPhi0*theCachedSDPhi)*o,
151  }
152 // else if ( fabs(theCachedDPhi)>theNumericalPrecision ) {
153 // // full helix formula, but avoiding (1-cos(deltaPhi)) for small angles
154 // return PositionTypeDouble(theX0+(-theSinPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
155 // theCosPhi0*theCachedSDPhi)/theRho,
156 // theY0+(theCosPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
157 // theSinPhi0*theCachedSDPhi)/theRho,
158 // theZ0+theCachedS*theCosTheta);
159 // }
160  else {
161  // Use 2nd order.
163  }
164 }
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Basic3DVector< double > PositionTypeDouble
#define abs(x)
Definition: mlp_lapack.h:159
#define unlikely(x)
Definition: Likely.h:21
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
PositionTypeDouble positionInDouble(double s) const

Member Data Documentation

double HelixArbitraryPlaneCrossing::theCachedCDPhi
mutableprivate

Definition at line 69 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

double HelixArbitraryPlaneCrossing::theCachedDPhi
mutableprivate

Definition at line 67 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

double HelixArbitraryPlaneCrossing::theCachedS
mutableprivate

Definition at line 66 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

double HelixArbitraryPlaneCrossing::theCachedSDPhi
mutableprivate

Definition at line 68 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

double HelixArbitraryPlaneCrossing::theCosPhi0
private
double HelixArbitraryPlaneCrossing::theCosTheta
private
const float HelixArbitraryPlaneCrossing::theMaxDistToPlane = 1.e-4f
staticprivate

Definition at line 72 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

const float HelixArbitraryPlaneCrossing::theNumericalPrecision = 5.e-7f
staticprivate

Definition at line 71 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

const PropagationDirection HelixArbitraryPlaneCrossing::thePropDir
private

Definition at line 64 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

HelixArbitraryPlaneCrossing2Order HelixArbitraryPlaneCrossing::theQuadraticCrossingFromStart
private

Definition at line 56 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), pathLength(), and positionInDouble().

const double HelixArbitraryPlaneCrossing::theRho
private

Definition at line 62 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), pathLength(), and positionInDouble().

double HelixArbitraryPlaneCrossing::theSinPhi0
private
double HelixArbitraryPlaneCrossing::theSinTheta
private
const double HelixArbitraryPlaneCrossing::theX0
private

Definition at line 59 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().

const double HelixArbitraryPlaneCrossing::theY0
private

Definition at line 59 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().

const double HelixArbitraryPlaneCrossing::theZ0
private

Definition at line 59 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().