CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
HelixBarrelPlaneCrossingByCircle Class Referencefinal

#include <HelixBarrelPlaneCrossingByCircle.h>

Inheritance diagram for HelixBarrelPlaneCrossingByCircle:
HelixPlaneCrossing

Public Member Functions

DirectionType direction (double s) const override
 
 HelixBarrelPlaneCrossingByCircle (const GlobalPoint &pos, const GlobalVector &dir, double rho, PropagationDirection propDir=alongMomentum)
 
 HelixBarrelPlaneCrossingByCircle (const PositionType &pos, const DirectionType &dir, double rho, PropagationDirection propDir=alongMomentum)
 
std::pair< bool, double > pathLength (const Plane &) override
 
PositionType position (double s) const override
 
- Public Member Functions inherited from HelixPlaneCrossing
virtual ~HelixPlaneCrossing ()=default
 

Private Types

typedef Basic2DVector< double > Vector2D
 

Private Member Functions

bool chooseSolution (const Vector2D &d1, const Vector2D &d2)
 
void init ()
 

Private Attributes

double theActualDir
 
double theCosTheta
 
Vector2D theD
 
double theDmag
 
PropagationDirection thePropDir
 
double theRho
 
double theS
 
double theSinTheta
 
DirectionType theStartingDir
 
PositionType theStartingPos
 
double theXCenter
 
double theYCenter
 
bool useStraightLine
 

Additional Inherited Members

- 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...
 

Detailed Description

Computes the crossing of a helix with a barrel plane. Exact if the magnetic field is parallel to the plane.

Definition at line 13 of file HelixBarrelPlaneCrossingByCircle.h.

Member Typedef Documentation

◆ Vector2D

Definition at line 32 of file HelixBarrelPlaneCrossingByCircle.h.

Constructor & Destructor Documentation

◆ HelixBarrelPlaneCrossingByCircle() [1/2]

HelixBarrelPlaneCrossingByCircle::HelixBarrelPlaneCrossingByCircle ( const PositionType pos,
const DirectionType dir,
double  rho,
PropagationDirection  propDir = alongMomentum 
)

Definition at line 10 of file HelixBarrelPlaneCrossingByCircle.cc.

15  init();
16 }

References init().

◆ HelixBarrelPlaneCrossingByCircle() [2/2]

HelixBarrelPlaneCrossingByCircle::HelixBarrelPlaneCrossingByCircle ( const GlobalPoint pos,
const GlobalVector dir,
double  rho,
PropagationDirection  propDir = alongMomentum 
)

Definition at line 18 of file HelixBarrelPlaneCrossingByCircle.cc.

22  : theStartingPos(pos.basicVector()), theStartingDir(dir.basicVector()), theRho(rho), thePropDir(propDir) {
23  init();
24 }

References init().

Member Function Documentation

◆ chooseSolution()

bool HelixBarrelPlaneCrossingByCircle::chooseSolution ( const Vector2D d1,
const Vector2D d2 
)
private

Definition at line 116 of file HelixBarrelPlaneCrossingByCircle.cc.

116  {
117  bool solved;
118  double momProj1 = theStartingDir.x() * d1.x() + theStartingDir.y() * d1.y();
119  double momProj2 = theStartingDir.x() * d2.x() + theStartingDir.y() * d2.y();
120 
121  if (thePropDir == anyDirection) {
122  solved = true;
123  if (d1.mag2() < d2.mag2()) {
124  theD = d1;
125  theActualDir = (momProj1 > 0) ? 1. : -1.;
126  } else {
127  theD = d2;
128  theActualDir = (momProj2 > 0) ? 1. : -1.;
129  }
130 
131  } else {
132  double propSign = thePropDir == alongMomentum ? 1 : -1;
133  if (!mathSSE::samesign(momProj1, momProj2)) {
134  // if different signs return the positive one
135  solved = true;
136  theD = mathSSE::samesign(momProj1, propSign) ? d1 : d2;
137  theActualDir = propSign;
138  } else if (mathSSE::samesign(momProj1, propSign)) {
139  // if both positive, return the shortest
140  solved = true;
141  theD = (d1.mag2() < d2.mag2()) ? d1 : d2;
142  theActualDir = propSign;
143  } else
144  solved = false;
145  }
146  return solved;
147 }

References alongMomentum, anyDirection, d1, Basic2DVector< T >::mag2(), mathSSE::samesign(), theActualDir, theD, thePropDir, theStartingDir, Basic2DVector< T >::x(), Basic3DVector< T >::x(), Basic2DVector< T >::y(), and Basic3DVector< T >::y().

Referenced by pathLength().

◆ direction()

HelixPlaneCrossing::DirectionType HelixBarrelPlaneCrossingByCircle::direction ( double  s) const
overridevirtual

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 plane (if it exists!) is given by direction( pathLength( plane)).

Implements HelixPlaneCrossing.

Definition at line 168 of file HelixBarrelPlaneCrossingByCircle.cc.

168  {
169  if (useStraightLine) {
170  return theStartingDir;
171  } else {
172  double sinPhi, cosPhi;
173  if (s == theS) {
174  double tmp = 0.5 * theDmag * theRho;
175  if (s < 0)
176  tmp = -tmp;
177  // protect sqrt
178  sinPhi = 1. - (tmp * tmp);
179  if (sinPhi < 0)
180  sinPhi = 0.;
181  sinPhi = 2. * tmp * sqrt(sinPhi);
182  cosPhi = 1. - 2. * (tmp * tmp);
183  } else {
184  double phi = s * theSinTheta * theRho;
185  sinPhi = sin(phi);
186  cosPhi = cos(phi);
187  }
188  return DirectionType(theStartingDir.x() * cosPhi - theStartingDir.y() * sinPhi,
189  theStartingDir.x() * sinPhi + theStartingDir.y() * cosPhi,
190  theStartingDir.z());
191  }
192 }

References funct::cos(), phi, alignCSCRings::s, funct::sin(), mathSSE::sqrt(), theDmag, theRho, theS, theSinTheta, theStartingDir, createJobs::tmp, useStraightLine, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by TSCPBuilderNoMaterial::createFTSatTransverseImpactPointCharged(), and TrackKinematicStatePropagator::propagateToTheTransversePCACharged().

◆ init()

void HelixBarrelPlaneCrossingByCircle::init ( void  )
private

Definition at line 26 of file HelixBarrelPlaneCrossingByCircle.cc.

26  {
27  double pabsI = 1. / theStartingDir.mag();
28  double pt = theStartingDir.perp();
29  theCosTheta = theStartingDir.z() * pabsI;
30  theSinTheta = pt * pabsI;
31 
32  // protect for zero curvature case
33  const double sraightLineCutoff = 1.e-7;
34  if (fabs(theRho) < sraightLineCutoff && fabs(theRho) * theStartingPos.perp() < sraightLineCutoff) {
35  useStraightLine = true;
36  } else {
37  // circle parameters
38  // position of center of curvature is on a line perpendicular
39  // to startingDir and at a distance 1/curvature.
40  double o = 1. / (pt * theRho);
43  useStraightLine = false;
44  }
45 }

References Basic3DVector< T >::mag(), EcalTangentSkim_cfg::o, Basic3DVector< T >::perp(), DiDispStaMuonMonitor_cfi::pt, theCosTheta, theRho, theSinTheta, theStartingDir, theStartingPos, theXCenter, theYCenter, useStraightLine, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by HelixBarrelPlaneCrossingByCircle().

◆ pathLength()

std::pair< bool, double > HelixBarrelPlaneCrossingByCircle::pathLength ( const Plane )
overridevirtual

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 47 of file HelixBarrelPlaneCrossingByCircle.cc.

47  {
48  typedef std::pair<bool, double> ResultType;
49 
50  if (useStraightLine) {
51  // switch to straight line case
53  return slc.pathLength(plane);
54  }
55 
56  // plane parameters
57  GlobalVector n = plane.normalVector();
58  double distToPlane = -plane.localZ(GlobalPoint(theStartingPos));
59  // double distToPlane = (plane.position().x()-theStartingPos.x()) * n.x() +
60  // (plane.position().y()-theStartingPos.y()) * n.y();
61  double nx = n.x(); // convert to double
62  double ny = n.y(); // convert to double
63  double distCx = theStartingPos.x() - theXCenter;
64  double distCy = theStartingPos.y() - theYCenter;
65 
66  double nfac, dfac;
67  double A, B, C;
68  bool solveForX;
69  if (fabs(nx) > fabs(ny)) {
70  solveForX = false;
71  nfac = ny / nx;
72  dfac = distToPlane / nx;
73  B = distCy - nfac * distCx; // only part of B, may have large cancelation
74  C = (2. * distCx + dfac) * dfac;
75  } else {
76  solveForX = true;
77  nfac = nx / ny;
78  dfac = distToPlane / ny;
79  B = distCx - nfac * distCy; // only part of B, may have large cancelation
80  C = (2. * distCy + dfac) * dfac;
81  }
82  B -= nfac * dfac;
83  B *= 2; // the rest of B (normally small)
84  A = 1. + nfac * nfac;
85 
86  double dx1, dx2, dy1, dy2;
87  RealQuadEquation equation(A, B, C);
88  if (!equation.hasSolution)
89  return ResultType(false, theS = 0.);
90  else {
91  if (solveForX) {
92  dx1 = equation.first;
93  dx2 = equation.second;
94  dy1 = dfac - nfac * dx1;
95  dy2 = dfac - nfac * dx2;
96  } else {
97  dy1 = equation.first;
98  dy2 = equation.second;
99  dx1 = dfac - nfac * dy1;
100  dx2 = dfac - nfac * dy2;
101  }
102  }
103  bool solved = chooseSolution(Vector2D(dx1, dy1), Vector2D(dx2, dy2));
104  if (solved) {
105  theDmag = theD.mag();
106  // protect asin
107  double sinAlpha = 0.5 * theDmag * theRho;
108  if (std::abs(sinAlpha) > 1.)
109  sinAlpha = std::copysign(1., sinAlpha);
110  theS = theActualDir * 2. / (theRho * theSinTheta) * asin(sinAlpha);
111  return ResultType(true, theS);
112  } else
113  return ResultType(false, theS = 0.);
114 }

References MaterialEffects_cfi::A, funct::abs(), TtFullHadDaughter::B, gen::C, chooseSolution(), RealQuadEquation::first, RealQuadEquation::hasSolution, Plane::localZ(), Basic2DVector< T >::mag(), dqmiodumpmetadata::n, Plane::normalVector(), StraightLinePlaneCrossing::pathLength(), RealQuadEquation::second, theActualDir, theD, theDmag, thePropDir, theRho, theS, theSinTheta, theStartingDir, theStartingPos, theXCenter, theYCenter, useStraightLine, Basic3DVector< T >::x(), and Basic3DVector< T >::y().

Referenced by TSCPBuilderNoMaterial::createFTSatTransverseImpactPointCharged(), TrackKinematicStatePropagator::propagateToTheTransversePCACharged(), and TrackKinematicStatePropagator::willPropagateToTheTransversePCA().

◆ position()

HelixPlaneCrossing::PositionType HelixBarrelPlaneCrossingByCircle::position ( double  s) const
overridevirtual

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 plane (if it exists!) is given by position( pathLength( plane)).

Implements HelixPlaneCrossing.

Definition at line 149 of file HelixBarrelPlaneCrossingByCircle.cc.

149  {
150  if (useStraightLine) {
152  } else {
153  if (s == theS) {
154  return PositionType(
156  } else {
157  double phi = s * theSinTheta * theRho;
158  double x1Shift = theStartingPos.x() - theXCenter;
159  double y1Shift = theStartingPos.y() - theYCenter;
160 
161  return PositionType(x1Shift * cos(phi) - y1Shift * sin(phi) + theXCenter,
162  x1Shift * sin(phi) + y1Shift * cos(phi) + theYCenter,
163  theStartingPos.z() + s * theCosTheta);
164  }
165  }
166 }

References funct::cos(), phi, alignCSCRings::s, funct::sin(), theCosTheta, theD, theRho, theS, theSinTheta, theStartingDir, theStartingPos, theXCenter, theYCenter, Basic3DVector< T >::unit(), useStraightLine, Basic2DVector< T >::x(), Basic3DVector< T >::x(), Basic2DVector< T >::y(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by TSCPBuilderNoMaterial::createFTSatTransverseImpactPointCharged(), and TrackKinematicStatePropagator::propagateToTheTransversePCACharged().

Member Data Documentation

◆ theActualDir

double HelixBarrelPlaneCrossingByCircle::theActualDir
private

Definition at line 50 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by chooseSolution(), and pathLength().

◆ theCosTheta

double HelixBarrelPlaneCrossingByCircle::theCosTheta
private

Definition at line 39 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by init(), and position().

◆ theD

Vector2D HelixBarrelPlaneCrossingByCircle::theD
private

Definition at line 46 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by chooseSolution(), pathLength(), and position().

◆ theDmag

double HelixBarrelPlaneCrossingByCircle::theDmag
private

Definition at line 47 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by direction(), and pathLength().

◆ thePropDir

PropagationDirection HelixBarrelPlaneCrossingByCircle::thePropDir
private

Definition at line 37 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by chooseSolution(), and pathLength().

◆ theRho

double HelixBarrelPlaneCrossingByCircle::theRho
private

Definition at line 36 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by direction(), init(), pathLength(), and position().

◆ theS

double HelixBarrelPlaneCrossingByCircle::theS
private

Definition at line 45 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by direction(), pathLength(), and position().

◆ theSinTheta

double HelixBarrelPlaneCrossingByCircle::theSinTheta
private

Definition at line 40 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by direction(), init(), pathLength(), and position().

◆ theStartingDir

DirectionType HelixBarrelPlaneCrossingByCircle::theStartingDir
private

◆ theStartingPos

PositionType HelixBarrelPlaneCrossingByCircle::theStartingPos
private

Definition at line 34 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by init(), pathLength(), and position().

◆ theXCenter

double HelixBarrelPlaneCrossingByCircle::theXCenter
private

Definition at line 41 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by init(), pathLength(), and position().

◆ theYCenter

double HelixBarrelPlaneCrossingByCircle::theYCenter
private

Definition at line 42 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by init(), pathLength(), and position().

◆ useStraightLine

bool HelixBarrelPlaneCrossingByCircle::useStraightLine
private

Definition at line 51 of file HelixBarrelPlaneCrossingByCircle.h.

Referenced by direction(), init(), pathLength(), and position().

Vector3DBase
Definition: Vector3DBase.h:8
anyDirection
Definition: PropagationDirection.h:4
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
HelixBarrelPlaneCrossingByCircle::Vector2D
Basic2DVector< double > Vector2D
Definition: HelixBarrelPlaneCrossingByCircle.h:32
HelixPlaneCrossing::DirectionType
Basic3DVector< float > DirectionType
Definition: HelixPlaneCrossing.h:23
pos
Definition: PixelAliasList.h:18
HelixBarrelPlaneCrossingByCircle::theRho
double theRho
Definition: HelixBarrelPlaneCrossingByCircle.h:36
Basic2DVector::mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: extBasic2DVector.h:73
Basic3DVector::mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: extBasic3DVector.h:116
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
alignCSCRings.s
s
Definition: alignCSCRings.py:92
Basic3DVector::y
T y() const
Cartesian y coordinate.
Definition: extBasic3DVector.h:97
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Basic2DVector::y
T y() const
Cartesian y coordinate.
Definition: extBasic2DVector.h:67
RealQuadEquation
Definition: RealQuadEquation.h:11
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HelixBarrelPlaneCrossingByCircle::init
void init()
Definition: HelixBarrelPlaneCrossingByCircle.cc:26
Basic2DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic2DVector.h:64
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
HelixBarrelPlaneCrossingByCircle::useStraightLine
bool useStraightLine
Definition: HelixBarrelPlaneCrossingByCircle.h:51
DDAxes::rho
HelixBarrelPlaneCrossingByCircle::theStartingDir
DirectionType theStartingDir
Definition: HelixBarrelPlaneCrossingByCircle.h:35
HelixBarrelPlaneCrossingByCircle::theXCenter
double theXCenter
Definition: HelixBarrelPlaneCrossingByCircle.h:41
A
HelixBarrelPlaneCrossingByCircle::theStartingPos
PositionType theStartingPos
Definition: HelixBarrelPlaneCrossingByCircle.h:34
HelixBarrelPlaneCrossingByCircle::theD
Vector2D theD
Definition: HelixBarrelPlaneCrossingByCircle.h:46
DDAxes::phi
HelixBarrelPlaneCrossingByCircle::theSinTheta
double theSinTheta
Definition: HelixBarrelPlaneCrossingByCircle.h:40
HelixBarrelPlaneCrossingByCircle::theDmag
double theDmag
Definition: HelixBarrelPlaneCrossingByCircle.h:47
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
MaterialEffects_cfi.A
A
Definition: MaterialEffects_cfi.py:11
mathSSE::samesign
bool samesign(T rh, T lh)
HelixBarrelPlaneCrossingByCircle::chooseSolution
bool chooseSolution(const Vector2D &d1, const Vector2D &d2)
Definition: HelixBarrelPlaneCrossingByCircle.cc:116
gen::C
C
Definition: PomwigHadronizer.cc:78
HelixBarrelPlaneCrossingByCircle::theYCenter
double theYCenter
Definition: HelixBarrelPlaneCrossingByCircle.h:42
Basic3DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic3DVector.h:94
HelixBarrelPlaneCrossingByCircle::theActualDir
double theActualDir
Definition: HelixBarrelPlaneCrossingByCircle.h:50
HelixBarrelPlaneCrossingByCircle::thePropDir
PropagationDirection thePropDir
Definition: HelixBarrelPlaneCrossingByCircle.h:37
HelixBarrelPlaneCrossingByCircle::theS
double theS
Definition: HelixBarrelPlaneCrossingByCircle.h:45
HelixBarrelPlaneCrossingByCircle::theCosTheta
double theCosTheta
Definition: HelixBarrelPlaneCrossingByCircle.h:39
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Basic3DVector::perp
T perp() const
Magnitude of transverse component.
Definition: extBasic3DVector.h:122
StraightLinePlaneCrossing
Definition: StraightLinePlaneCrossing.h:14
Basic3DVector::z
T z() const
Cartesian z coordinate.
Definition: extBasic3DVector.h:100
Basic3DVector::unit
Basic3DVector unit() const
Definition: extBasic3DVector.h:151
alongMomentum
Definition: PropagationDirection.h:4
d1
static constexpr float d1
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
HelixPlaneCrossing::PositionType
Basic3DVector< float > PositionType
the helix is passed to the constructor and does not appear in the interface
Definition: HelixPlaneCrossing.h:22