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 Types | Private Member Functions | Private Attributes
HelixBarrelCylinderCrossing Class Reference

#include <HelixBarrelCylinderCrossing.h>

Public Types

typedef GlobalVector DirectionType
 
typedef GlobalPoint PositionType
 

Public Member Functions

DirectionType direction () const
 
bool hasSolution () const
 
 HelixBarrelCylinderCrossing (const GlobalPoint &startingPos, const GlobalVector &startingDir, double rho, PropagationDirection propDir, const Cylinder &cyl)
 
double pathLength () const
 
PositionType position () const
 

Private Types

typedef Basic2DVector< TmpTypePoint
 
typedef double TmpType
 
typedef Basic2DVector< TmpTypeVector
 

Private Member Functions

void chooseSolution (const Point &p1, const Point &p2, const PositionType &startingPos, const DirectionType &startingDir, PropagationDirection propDir)
 

Private Attributes

int theActualDir
 
Vector theD
 
DirectionType theDir
 
PositionType thePos
 
double theS
 
bool theSolExists
 

Detailed Description

Calculates the crossing of a helix with a barrel cylinder.

Definition at line 14 of file HelixBarrelCylinderCrossing.h.

Member Typedef Documentation

Definition at line 23 of file HelixBarrelCylinderCrossing.h.

Definition at line 17 of file HelixBarrelCylinderCrossing.h.

Definition at line 22 of file HelixBarrelCylinderCrossing.h.

typedef double HelixBarrelCylinderCrossing::TmpType
private

Definition at line 16 of file HelixBarrelCylinderCrossing.h.

Definition at line 18 of file HelixBarrelCylinderCrossing.h.

Constructor & Destructor Documentation

HelixBarrelCylinderCrossing::HelixBarrelCylinderCrossing ( const GlobalPoint startingPos,
const GlobalVector startingDir,
double  rho,
PropagationDirection  propDir,
const Cylinder cyl 
)

Definition at line 14 of file HelixBarrelCylinderCrossing.cc.

References abs, funct::C, chooseSolution(), debug_cff::d1, python.Vispa.Plugins.EdmBrowser.EdmDataAccessor::eq(), RealQuadEquation::first, RealQuadEquation::hasSolution, PV3DBase< T, PVType, FrameType >::mag(), Basic2DVector< T >::mag(), p2, StraightLineCylinderCrossing::pathLength(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::perp2(), dttmaxenums::R, Cylinder::radius(), rho, RealQuadEquation::second, mathSSE::sqrt(), theActualDir, theD, theDir, thePos, theS, theSolExists, tmp, Surface::toGlobal(), GloballyPositioned< T >::toLocal(), Basic2DVector< T >::x(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), Basic2DVector< T >::y(), and PV3DBase< T, PVType, FrameType >::z().

18 {
19  // assumes the cylinder is centered at 0,0
20  double R = cyl.radius();
21 
22  // protect for zero curvature case
23  const double sraightLineCutoff = 1.e-7;
24  if (fabs(rho)*R < sraightLineCutoff &&
25  fabs(rho)*startingPos.perp() < sraightLineCutoff) {
26  // switch to straight line case
27  StraightLineCylinderCrossing slc( cyl.toLocal(startingPos),
28  cyl.toLocal(startingDir), propDir);
29  std::pair<bool,double> pl = slc.pathLength( cyl);
30  if (pl.first) {
31  theSolExists = true;
32  theS = pl.second;
33  thePos = cyl.toGlobal(slc.position(theS));
34  theDir = startingDir;
35  }
36  else theSolExists = false;
37  return; // all needed data members have been set
38  }
39 
40  double R2cyl = R*R;
41  double pt = startingDir.perp();
42  Point center( startingPos.x()-startingDir.y()/(pt*rho),
43  startingPos.y()+startingDir.x()/(pt*rho));
44  double p2 = startingPos.perp2();
45  bool solveForX;
46  double B, C, E, F;
47  if (fabs(center.x()) > fabs(center.y())) {
48  solveForX = false;
49  E = (R2cyl - p2) / (2.*center.x());
50  F = center.y()/center.x();
51  B = 2.*( startingPos.y() - F*startingPos.x() - E*F);
52  C = 2.*E*startingPos.x() + E*E + p2 - R2cyl;
53  }
54  else {
55  solveForX = true;
56  E = (R2cyl - p2) / (2.*center.y());
57  F = center.x()/center.y();
58  B = 2.*( startingPos.x() - F*startingPos.y() - E*F);
59  C = 2.*E*startingPos.y() + E*E + p2 - R2cyl;
60  }
61 
62  RealQuadEquation eq( 1+F*F, B, C);
63  if (!eq.hasSolution) {
64  theSolExists = false;
65  return;
66  }
67 
68  Vector d1, d2;;
69  if (solveForX) {
70  d1 = Point(eq.first, E-F*eq.first);
71  d2 = Point(eq.second, E-F*eq.second);
72  }
73  else {
74  d1 = Point( E-F*eq.first, eq.first);
75  d2 = Point( E-F*eq.second, eq.second);
76  }
77 
78  chooseSolution(d1, d2, startingPos, startingDir, propDir);
79  if (!theSolExists) return;
80 
81  double ipabs = 1./startingDir.mag();
82  double sinTheta = pt * ipabs;
83  double cosTheta = startingDir.z() * ipabs;
84 
85  double dMag = theD.mag();
86  double tmp = 0.5 * dMag * rho;
87  if (std::abs(tmp)>1.) tmp = ::copysign(1.,tmp);
88  theS = theActualDir * 2.* asin( tmp ) / (rho*sinTheta);
89  thePos = GlobalPoint( startingPos.x() + theD.x(),
90  startingPos.y() + theD.y(),
91  startingPos.z() + theS*cosTheta);
92 
93  if (theS < 0) tmp = -tmp;
94  double sinPhi = 2.*tmp*sqrt(1.-tmp*tmp);
95  double cosPhi = 1.-2.*tmp*tmp;
96  theDir = DirectionType(startingDir.x()*cosPhi-startingDir.y()*sinPhi,
97  startingDir.x()*sinPhi+startingDir.y()*cosPhi,
98  startingDir.z());
99 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
void chooseSolution(const Point &p1, const Point &p2, const PositionType &startingPos, const DirectionType &startingDir, PropagationDirection propDir)
T perp() const
Definition: PV3DBase.h:66
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:28
double_binary B
Definition: DDStreamer.cc:235
Definition: DDAxes.h:10
std::pair< bool, double > pathLength(const Cylinder &cyl) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:57
#define abs(x)
Definition: mlp_lapack.h:159
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T perp2() const
Definition: PV3DBase.h:65
tuple d1
Definition: debug_cff.py:7
T mag() const
Definition: PV3DBase.h:61
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:55
T sqrt(T t)
Definition: SSEVec.h:28
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:58
math::XYZPoint Point
double p2[4]
Definition: TauolaWrapper.h:90
T y() const
Cartesian y coordinate.
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
T x() const
Definition: PV3DBase.h:56
T x() const
Cartesian x coordinate.

Member Function Documentation

void HelixBarrelCylinderCrossing::chooseSolution ( const Point p1,
const Point p2,
const PositionType startingPos,
const DirectionType startingDir,
PropagationDirection  propDir 
)
private

Definition at line 101 of file HelixBarrelCylinderCrossing.cc.

References alongMomentum, anyDirection, debug_cff::d1, Basic2DVector< T >::mag2(), theActualDir, theD, theSolExists, Basic2DVector< T >::x(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and Basic2DVector< T >::y().

Referenced by HelixBarrelCylinderCrossing().

105 {
106  double momProj1 = startingDir.x()*d1.x() + startingDir.y()*d1.y();
107  double momProj2 = startingDir.x()*d2.x() + startingDir.y()*d2.y();
108 
109  if ( propDir == anyDirection ) {
110  theSolExists = true;
111  if (d1.mag2()<d2.mag2()) {
112  theD = d1;
113  theActualDir = (momProj1 > 0) ? 1 : -1;
114  }
115  else {
116  theD = d2;
117  theActualDir = (momProj2 > 0) ? 1 : -1;
118  }
119  }
120  else {
121  int propSign = propDir==alongMomentum ? 1 : -1;
122  if (momProj1*momProj2 < 0) {
123  // if different signs return the positive one
124  theSolExists = true;
125  theD = (momProj1*propSign > 0) ? d1 : d2;
126  theActualDir = propSign;
127  }
128  else if (momProj1*propSign > 0) {
129  // if both positive, return the shortest
130  theSolExists = true;
131  theD = (d1.mag2()<d2.mag2()) ? d1 : d2;
132  theActualDir = propSign;
133  }
134  else theSolExists = false;
135  }
136 }
tuple d1
Definition: debug_cff.py:7
DirectionType HelixBarrelCylinderCrossing::direction ( ) const
inline

Returns the direction along the helix that corresponds to path length "s" from the starting point. As for position, the direction of the crossing with a cylinder (if it exists!) is given by direction( pathLength( cylinder)).

Definition at line 51 of file HelixBarrelCylinderCrossing.h.

References theDir.

51 { return theDir;}
bool HelixBarrelCylinderCrossing::hasSolution ( ) const
inline
double HelixBarrelCylinderCrossing::pathLength ( ) const
inline

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

Definition at line 36 of file HelixBarrelCylinderCrossing.h.

References theS.

Referenced by AnalyticalPropagator::propagateParametersOnCylinder().

PositionType HelixBarrelCylinderCrossing::position ( ) const
inline

Returns the position along the helix that corresponds to path length "s" from the starting point. If s is obtained from the pathLength method the position is the destination point, i.e. the position of the crossing with a cylinder (if it exists!) is given by position( pathLength( cylinder)).

Definition at line 44 of file HelixBarrelCylinderCrossing.h.

References thePos.

Referenced by TIBLayer::computeCrossings(), TOBLayer::computeCrossings(), and PixelBarrelLayer::computeCrossings().

44 { return thePos;}

Member Data Documentation

int HelixBarrelCylinderCrossing::theActualDir
private

Definition at line 60 of file HelixBarrelCylinderCrossing.h.

Referenced by chooseSolution(), and HelixBarrelCylinderCrossing().

Vector HelixBarrelCylinderCrossing::theD
private

Definition at line 59 of file HelixBarrelCylinderCrossing.h.

Referenced by chooseSolution(), and HelixBarrelCylinderCrossing().

DirectionType HelixBarrelCylinderCrossing::theDir
private

Definition at line 58 of file HelixBarrelCylinderCrossing.h.

Referenced by direction(), and HelixBarrelCylinderCrossing().

PositionType HelixBarrelCylinderCrossing::thePos
private

Definition at line 57 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and position().

double HelixBarrelCylinderCrossing::theS
private

Definition at line 56 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and pathLength().

bool HelixBarrelCylinderCrossing::theSolExists
private