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
 
PositionType position1 () const
 Method to access separately each solution of the helix-cylinder crossing equations. More...
 
PositionType position2 () const
 Method to access separately each solution of the helix-cylinder crossing equations. More...
 

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) dso_internal
 

Private Attributes

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

Detailed Description

Calculates the crossing of a helix with a barrel cylinder.

Definition at line 16 of file HelixBarrelCylinderCrossing.h.

Member Typedef Documentation

Definition at line 25 of file HelixBarrelCylinderCrossing.h.

Definition at line 19 of file HelixBarrelCylinderCrossing.h.

Definition at line 24 of file HelixBarrelCylinderCrossing.h.

typedef double HelixBarrelCylinderCrossing::TmpType
private

Definition at line 18 of file HelixBarrelCylinderCrossing.h.

Definition at line 20 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, alongMomentum, funct::C, chooseSolution(), Vispa.Plugins.EdmBrowser.EdmDataAccessor::eq(), F(), 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, rho, RealQuadEquation::second, mathSSE::sqrt(), theActualDir, theD, theDir, thePos, thePos1, thePos2, theS, theSolExists, tmp, PV3DBase< T, PVType, FrameType >::x(), Basic2DVector< T >::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 
86  //----- BM
87  //double momProj1 = startingDir.x()*d1.x() + startingDir.y()*d1.y();
88  //double momProj2 = startingDir.x()*d2.x() + startingDir.y()*d2.y();
89 
90 
91  int theActualDir1 = propDir==alongMomentum ? 1 : -1;
92  int theActualDir2 = propDir==alongMomentum ? 1 : -1;
93 
94 
95  double dMag1 = d1.mag();
96  double tmp1 = 0.5 * dMag1 * rho;
97  if (std::abs(tmp1)>1.) tmp1 = ::copysign(1.,tmp1);
98  double theS1 = theActualDir1 * 2.* asin( tmp1 ) / (rho*sinTheta);
99  thePos1 = GlobalPoint( startingPos.x() + d1.x(),
100  startingPos.y() + d1.y(),
101  startingPos.z() + theS1*cosTheta);
102 
103 
104  double dMag2 = d2.mag();
105  double tmp2 = 0.5 * dMag2 * rho;
106  if (std::abs(tmp2)>1.) tmp2 = ::copysign(1.,tmp2);
107  double theS2 = theActualDir2 * 2.* asin( tmp2 ) / (rho*sinTheta);
108  thePos2 = GlobalPoint( startingPos.x() + d2.x(),
109  startingPos.y() + d2.y(),
110  startingPos.z() + theS2*cosTheta);
111  // -------
112 
113  double dMag = theD.mag();
114  double tmp = 0.5 * dMag * rho;
115  if (std::abs(tmp)>1.) tmp = ::copysign(1.,tmp);
116  theS = theActualDir * 2.* asin( tmp ) / (rho*sinTheta);
117  thePos = GlobalPoint( startingPos.x() + theD.x(),
118  startingPos.y() + theD.y(),
119  startingPos.z() + theS*cosTheta);
120 
121  if (theS < 0) tmp = -tmp;
122  double sinPhi = 2.*tmp*sqrt(1.-tmp*tmp);
123  double cosPhi = 1.-2.*tmp*tmp;
124  theDir = DirectionType(startingDir.x()*cosPhi-startingDir.y()*sinPhi,
125  startingDir.x()*sinPhi+startingDir.y()*cosPhi,
126  startingDir.z());
127 }
void chooseSolution(const Point &p1, const Point &p2, const PositionType &startingPos, const DirectionType &startingDir, PropagationDirection propDir) dso_internal
T perp() const
Definition: PV3DBase.h:72
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
double_binary B
Definition: DDStreamer.cc:234
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:63
#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:71
T mag() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
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
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
T x() const
Definition: PV3DBase.h:62
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 129 of file HelixBarrelCylinderCrossing.cc.

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

Referenced by HelixBarrelCylinderCrossing().

133 {
134  double momProj1 = startingDir.x()*d1.x() + startingDir.y()*d1.y();
135  double momProj2 = startingDir.x()*d2.x() + startingDir.y()*d2.y();
136 
137  if ( propDir == anyDirection ) {
138  theSolExists = true;
139  if (d1.mag2()<d2.mag2()) {
140  theD = d1;
141  theActualDir = (momProj1 > 0) ? 1 : -1;
142  }
143  else {
144  theD = d2;
145  theActualDir = (momProj2 > 0) ? 1 : -1;
146  }
147  }
148  else {
149  int propSign = propDir==alongMomentum ? 1 : -1;
150  if (momProj1*momProj2 < 0) {
151  // if different signs return the positive one
152  theSolExists = true;
153  theD = (momProj1*propSign > 0) ? d1 : d2;
154  theActualDir = propSign;
155  }
156  else if (momProj1*propSign > 0) {
157  // if both positive, return the shortest
158  theSolExists = true;
159  theD = (d1.mag2()<d2.mag2()) ? d1 : d2;
160  theActualDir = propSign;
161  }
162  else theSolExists = false;
163  }
164 }
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 60 of file HelixBarrelCylinderCrossing.h.

References theDir.

60 { return theDir;}
bool HelixBarrelCylinderCrossing::hasSolution ( ) const
inline

Definition at line 32 of file HelixBarrelCylinderCrossing.h.

References theSolExists.

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 38 of file HelixBarrelCylinderCrossing.h.

References theS.

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 46 of file HelixBarrelCylinderCrossing.h.

References thePos.

46 { return thePos;}
PositionType HelixBarrelCylinderCrossing::position1 ( ) const
inline

Method to access separately each solution of the helix-cylinder crossing equations.

Definition at line 49 of file HelixBarrelCylinderCrossing.h.

References thePos1.

49 { return thePos1;}
PositionType HelixBarrelCylinderCrossing::position2 ( ) const
inline

Method to access separately each solution of the helix-cylinder crossing equations.

Definition at line 52 of file HelixBarrelCylinderCrossing.h.

References thePos2.

52 { return thePos2;}

Member Data Documentation

int HelixBarrelCylinderCrossing::theActualDir
private

Definition at line 69 of file HelixBarrelCylinderCrossing.h.

Referenced by chooseSolution(), and HelixBarrelCylinderCrossing().

Vector HelixBarrelCylinderCrossing::theD
private

Definition at line 68 of file HelixBarrelCylinderCrossing.h.

Referenced by chooseSolution(), and HelixBarrelCylinderCrossing().

DirectionType HelixBarrelCylinderCrossing::theDir
private

Definition at line 67 of file HelixBarrelCylinderCrossing.h.

Referenced by direction(), and HelixBarrelCylinderCrossing().

PositionType HelixBarrelCylinderCrossing::thePos
private

Definition at line 66 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and position().

PositionType HelixBarrelCylinderCrossing::thePos1
private

Definition at line 71 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and position1().

PositionType HelixBarrelCylinderCrossing::thePos2
private

Definition at line 72 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and position2().

double HelixBarrelCylinderCrossing::theS
private

Definition at line 65 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and pathLength().

bool HelixBarrelCylinderCrossing::theSolExists
private