test
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 Referencefinal

#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 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 33 of file HelixArbitraryPlaneCrossing.cc.

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

36  :
38  theX0(point.x()),
39  theY0(point.y()),
40  theZ0(point.z()),
42  thePropDir(propDir),
43  theCachedS(0),
44  theCachedDPhi(0.),
45  theCachedSDPhi(0.),
46  theCachedCDPhi(1.)
47 {
48  //
49  // Components of direction vector (with correct normalisation)
50  //
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);
58  theCosPhi0 = px*ptI;
59  theSinPhi0 = py*ptI;
60  theCosTheta = pz*pI;
61  theSinTheta = pt2*ptI*pI;
62 }
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:18
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 200 of file HelixArbitraryPlaneCrossing.cc.

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

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

200  {
201  // use result in double precision
203  return DirectionType(dir.x(),dir.y(),dir.z());
204 }
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 209 of file HelixArbitraryPlaneCrossing.cc.

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

Referenced by direction(), and pathLength().

209  {
210  //
211  // Calculate delta phi (if not already available)
212  //
213  if unlikely( s!=theCachedS ) { // very very unlikely!
214  theCachedS = s;
216  vdt::fast_sincos(theCachedDPhi,theCachedSDPhi,theCachedCDPhi);
217  }
218 
219  if ( std::abs(theCachedDPhi)>1.e-4 ) {
220  // full helix formula
222  theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi,
224  }
225  else {
226  // 2nd order
228  }
229 }
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
DirectionTypeDouble directionInDouble(double s) const
#define unlikely(x)
Abs< T >::type abs(const T &t)
Definition: Abs.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 232 of file HelixArbitraryPlaneCrossing.cc.

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

Referenced by pathLength().

234  {
235  float dz = plane.localZ(Surface::GlobalPoint(point.x(),point.y(),point.z()));
236  return std::abs(dz)>maxDist;
237 }
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
*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 67 of file HelixArbitraryPlaneCrossing.cc.

References funct::abs(), alongMomentum, anyDirection, constexpr, directionInDouble(), align_cfg::iteration, Plane::localZ(), LogDebug, Basic3DVector< T >::mag(), maxiter, notAtSurface(), oppositeToMomentum, HelixArbitraryPlaneCrossing2Order::pathLength(), GloballyPositioned< T >::position(), positionInDouble(), theCosTheta, theMaxDistToPlane, theNumericalPrecision, thePropDir, theQuadraticCrossingFromStart, theRho, theSinTheta, theX0, theY0, theZ0, and unlikely.

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

67  {
68  //
69  // Constants used for control of convergence
70  //
71  constexpr int maxIterations = 20;
72  //
73  // maximum distance to plane (taking into account numerical precision)
74  //
75  float maxNumDz = theNumericalPrecision*plane.position().mag();
76  float safeMaxDist = (theMaxDistToPlane>maxNumDz?theMaxDistToPlane:maxNumDz);
77  //
78  // Prepare internal value of the propagation direction and position / direction vectors for iteration
79  //
80 
81  float dz = plane.localZ(Surface::GlobalPoint(theX0,theY0,theZ0));
82  if (std::abs(dz)<safeMaxDist) return std::make_pair(true,0.);
83 
84  bool notFail;
85  double dSTotal;
86  // Use existing 2nd order object at first pass
87  std::tie(notFail,dSTotal) = theQuadraticCrossingFromStart.pathLength(plane);
88  if unlikely(!notFail) return std::make_pair(notFail,dSTotal);
89  auto xnew = positionInDouble(dSTotal);
90 
91  auto propDir = thePropDir;
92  auto newDir = dSTotal>=0 ? alongMomentum : oppositeToMomentum;
93  if ( propDir == anyDirection ) {
94  propDir = newDir;
95  } else {
96  if unlikely( newDir!=propDir ) return std::pair<bool,double>(false,0);
97  }
98 
99 
100  //
101  // Prepare iterations: count and total pathlength
102  //
103  auto iteration = maxIterations;
104  while ( notAtSurface(plane,xnew,safeMaxDist) ) {
105  //
106  // return empty solution vector if no convergence after maxIterations iterations
107  //
108  if unlikely( --iteration == 0 ) {
109  LogDebug("HelixArbitraryPlaneCrossing") << "pathLength : no convergence";
110  return std::pair<bool,double>(false,0);
111  }
112 
113  //
114  // create temporary object for subsequent passes.
115  auto pnew = directionInDouble(dSTotal);
116  HelixArbitraryPlaneCrossing2Order quadraticCrossing(xnew.x(),xnew.y(),xnew.z(),
117  pnew.x(),pnew.y(),
119  theRho,
120  anyDirection);
121 
122  auto deltaS2 = quadraticCrossing.pathLength(plane);
123 
124 
125  if unlikely( !deltaS2.first ) return deltaS2;
126  //
127  // Calculate and sort total pathlength (max. 2 solutions)
128  //
129  dSTotal += deltaS2.second;
130  auto newDir = dSTotal>=0 ? alongMomentum : oppositeToMomentum;
131  if ( propDir == anyDirection ) {
132  propDir = newDir;
133  }
134  else {
135  if unlikely( newDir!=propDir ) return std::pair<bool,double>(false,0);
136  }
137  //
138  // Step forward by dSTotal.
139  //
140  xnew = positionInDouble(dSTotal);
141  }
142  //
143  // Return result
144  //
146 
147  return std::make_pair(true,dSTotal);
148 }
#define LogDebug(id)
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 &)
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
const PropagationDirection thePropDir
#define constexpr
#define unlikely(x)
U second(std::pair< T, U > const &p)
tuple iteration
Definition: align_cfg.py:5
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const MaxIter maxiter
PositionTypeDouble positionInDouble(double s) const
return(e1-e2)*(e1-e2)+dp *dp
if(dp >Float(M_PI)) dp-
volatile std::atomic< bool > shutdown_flag false
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 153 of file HelixArbitraryPlaneCrossing.cc.

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

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

153  {
154  // use result in double precision
156  return PositionType(pos.x(),pos.y(),pos.z());
157 }
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 162 of file HelixArbitraryPlaneCrossing.cc.

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

Referenced by pathLength(), and position().

162  {
163  //
164  // Calculate delta phi (if not already available)
165  //
166  if unlikely( s!=theCachedS ) {
167  theCachedS = s;
169  vdt::fast_sincos(theCachedDPhi,theCachedSDPhi,theCachedCDPhi);
170  }
171  //
172  // Calculate with appropriate formulation of full helix formula or with
173  // 2nd order approximation.
174  //
175 // if ( fabs(theCachedDPhi)>1.e-1 ) {
176  if ( std::abs(theCachedDPhi)>1.e-4 ) {
177  // "standard" helix formula
178  double o = 1./theRho;
180  theY0+( theCosPhi0*(1.-theCachedCDPhi)+theSinPhi0*theCachedSDPhi)*o,
182  }
183 // else if ( fabs(theCachedDPhi)>theNumericalPrecision ) {
184 // // full helix formula, but avoiding (1-cos(deltaPhi)) for small angles
185 // return PositionTypeDouble(theX0+(-theSinPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
186 // theCosPhi0*theCachedSDPhi)/theRho,
187 // theY0+(theCosPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
188 // theSinPhi0*theCachedSDPhi)/theRho,
189 // theZ0+theCachedS*theCosTheta);
190 // }
191  else {
192  // Use 2nd order.
194  }
195 }
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
Basic3DVector< double > PositionTypeDouble
#define unlikely(x)
Abs< T >::type abs(const T &t)
Definition: Abs.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().