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
 

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 9 of file HelixArbitraryPlaneCrossing.h.

Member Typedef Documentation

Definition at line 37 of file HelixArbitraryPlaneCrossing.h.

Definition at line 36 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 8 of file HelixArbitraryPlaneCrossing.cc.

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

11  :
13  theX0(point.x()),
14  theY0(point.y()),
15  theZ0(point.z()),
17  thePropDir(propDir),
18  theCachedS(0),
19  theCachedDPhi(0.),
20  theCachedSDPhi(0.),
21  theCachedCDPhi(1.)
22 {
23  //
24  // Components of direction vector (with correct normalisation)
25  //
26  double px = direction.x();
27  double py = direction.y();
28  double pz = direction.z();
29  double pt2 = px*px+py*py;
30  double p2 = pt2+pz*pz;
31  double pI = 1./sqrt(p2);
32  double ptI = 1./sqrt(pt2);
33  theCosPhi0 = px*ptI;
34  theSinPhi0 = py*ptI;
35  theCosTheta = pz*pI;
36  theSinTheta = pt2*ptI*pI;
37 }
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:28
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 18 of file HelixArbitraryPlaneCrossing.h.

18 {}

Member Function Documentation

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

Direction at pathlength s from the starting point.

Implements HelixPlaneCrossing.

Definition at line 168 of file HelixArbitraryPlaneCrossing.cc.

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

168  {
169  // use result in double precision
171  return DirectionType(dir.x(),dir.y(),dir.z());
172 }
DirectionTypeDouble directionInDouble(double s) const
Basic3DVector< float > DirectionType
Basic3DVector< double > DirectionTypeDouble
string s
Definition: asciidump.py:422
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 177 of file HelixArbitraryPlaneCrossing.cc.

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

Referenced by direction(), and pathLength().

177  {
178  //
179  // Calculate delta phi (if not already available)
180  //
181  if ( s!=theCachedS ) {
182  theCachedS = s;
186  }
187 
188  if ( std::abs(theCachedDPhi)>1.e-4 ) {
189  // full helix formula
191  theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi,
193  }
194  else {
195  // 2nd order
197  }
198 }
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
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Basic3DVector< double > DirectionTypeDouble
string s
Definition: asciidump.py:422
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 201 of file HelixArbitraryPlaneCrossing.cc.

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

Referenced by pathLength().

203  {
204  float dz = plane.localZ(Surface::GlobalPoint(point.x(),point.y(),point.z()));
205  return std::abs(dz)>maxDist;
206 }
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 42 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, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by PathToPlane2Order::operator()().

42  {
43  //
44  // Constants used for control of convergence
45  //
46  const int maxIterations(100);
47  //
48  // maximum distance to plane (taking into account numerical precision)
49  //
50  float maxNumDz = theNumericalPrecision*plane.position().mag();
51  float safeMaxDist = (theMaxDistToPlane>maxNumDz?theMaxDistToPlane:maxNumDz);
52  //
53  // Prepare internal value of the propagation direction and position / direction vectors for iteration
54  //
58  //
59  // Prepare iterations: count and total pathlength
60  //
61  int iteration(maxIterations);
62  double dSTotal(0.);
63  //
64  bool first = true;
65  while ( notAtSurface(plane,xnew,safeMaxDist) ) {
66  //
67  // return empty solution vector if no convergence after maxIterations iterations
68  //
69  if ( --iteration<0 ) {
70  edm::LogInfo("HelixArbitraryPlaneCrossing") << "pathLength : no convergence";
71  return std::pair<bool,double>(false,0);
72  }
73 
74  //
75  // Use existing 2nd order object at first pass, create temporary object
76  // for subsequent passes.
77  //
78  std::pair<bool,double> deltaS2;
79  if ( first ) {
80  first = false;
82  }
83  else {
84  HelixArbitraryPlaneCrossing2Order quadraticCrossing(xnew.x(),xnew.y(),xnew.z(),
85  pnew.x(),pnew.y(),
87  theRho,
88  anyDirection);
89 
90  deltaS2 = quadraticCrossing.pathLength(plane);
91  }
92 
93  if ( !deltaS2.first ) return deltaS2;
94  //
95  // Calculate and sort total pathlength (max. 2 solutions)
96  //
97  dSTotal += deltaS2.second;
99  if ( propDir == anyDirection ) {
100  propDir = newDir;
101  }
102  else {
103  if ( newDir!=propDir ) return std::pair<bool,double>(false,0);
104  }
105  //
106  // Step forward by dSTotal.
107  //
108  xnew = positionInDouble(dSTotal);
109  pnew = directionInDouble(dSTotal);
110  }
111  //
112  // Return result
113  //
114  return std::pair<bool,double>(true,dSTotal);
115 }
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
tuple iteration
Definition: align_cfg.py:5
PositionTypeDouble positionInDouble(double s) const
bool first
Definition: L1TdeRCT.cc:79
Basic3DVector< double > DirectionTypeDouble
bool notAtSurface(const Plane &, const PositionTypeDouble &, const float) const
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 120 of file HelixArbitraryPlaneCrossing.cc.

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

120  {
121  // use result in double precision
123  return PositionType(pos.x(),pos.y(),pos.z());
124 }
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
string s
Definition: asciidump.py:422
HelixArbitraryPlaneCrossing::PositionTypeDouble HelixArbitraryPlaneCrossing::positionInDouble ( double  s) const

Position at pathlength s from the starting point.

Definition at line 129 of file HelixArbitraryPlaneCrossing.cc.

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

Referenced by pathLength(), and position().

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

Member Data Documentation

double HelixArbitraryPlaneCrossing::theCachedCDPhi
mutableprivate

Definition at line 68 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

double HelixArbitraryPlaneCrossing::theCachedDPhi
mutableprivate

Definition at line 66 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

double HelixArbitraryPlaneCrossing::theCachedS
mutableprivate

Definition at line 65 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

double HelixArbitraryPlaneCrossing::theCachedSDPhi
mutableprivate

Definition at line 67 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 71 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

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

Definition at line 70 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

const PropagationDirection HelixArbitraryPlaneCrossing::thePropDir
private

Definition at line 63 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

HelixArbitraryPlaneCrossing2Order HelixArbitraryPlaneCrossing::theQuadraticCrossingFromStart
private

Definition at line 55 of file HelixArbitraryPlaneCrossing.h.

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

const double HelixArbitraryPlaneCrossing::theRho
private

Definition at line 61 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 58 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().

const double HelixArbitraryPlaneCrossing::theY0
private

Definition at line 58 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().

const double HelixArbitraryPlaneCrossing::theZ0
private

Definition at line 58 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().