CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
TwoTrackMinimumDistanceHelixLine Class Reference

#include <TwoTrackMinimumDistanceHelixLine.h>

Public Member Functions

bool calculate (const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &, const float qual=.0001)
 
double firstAngle () const
 
std::pair< double, double > pathLength () const
 
std::pair< GlobalPoint, GlobalPointpoints () const
 
double secondAngle () const
 
 TwoTrackMinimumDistanceHelixLine ()
 
 ~TwoTrackMinimumDistanceHelixLine ()
 

Private Member Functions

void finalPoints ()
 
bool oneIteration (double &thePhiH, double &fct, double &derivative) const
 
bool updateCoeffs ()
 

Private Attributes

double aa
 
double baseDer
 
double baseFct
 
double bb
 
double cc
 
double dd
 
double ee
 
double ff
 
const GlobalTrajectoryParametersfirstGTP
 
double helixPath
 
GlobalPoint helixPoint
 
double Hn
 
double linePath
 
GlobalPoint linePoint
 
double Ln
 
bool pointsUpdated
 
GlobalVector posDiff
 
double px
 
double px2
 
double py
 
double py2
 
double pz
 
double pz2
 
const GlobalTrajectoryParameterssecondGTP
 
double thecosPhiH0
 
const GlobalTrajectoryParameterstheH
 
double theh
 
const GlobalTrajectoryParameterstheL
 
GlobalVector theLp
 
int themaxiter
 
double thePhiH
 
double thePhiH0
 
double thesinPhiH0
 
double thetanlambdaH
 
double tL
 
double X
 
double Y
 
double Z
 

Detailed Description

This is a helper class for TwoTrackMinimumDistance, for the case where one of the tracks is charged and the other not. No user should need direct access to this class. It implements a Newton method for finding the minimum distance between two tracks.

Definition at line 17 of file TwoTrackMinimumDistanceHelixLine.h.

Constructor & Destructor Documentation

◆ TwoTrackMinimumDistanceHelixLine()

TwoTrackMinimumDistanceHelixLine::TwoTrackMinimumDistanceHelixLine ( )
inline

◆ ~TwoTrackMinimumDistanceHelixLine()

TwoTrackMinimumDistanceHelixLine::~TwoTrackMinimumDistanceHelixLine ( )
inline

Definition at line 20 of file TwoTrackMinimumDistanceHelixLine.h.

20 {}

Member Function Documentation

◆ calculate()

bool TwoTrackMinimumDistanceHelixLine::calculate ( const GlobalTrajectoryParameters theFirstGTP,
const GlobalTrajectoryParameters theSecondGTP,
const float  qual = .0001 
)

Calculates the PCA between a charged particle (helix) and a neutral particle (line). The order of the trajectories (helix-line or line-helix) is irrelevent, and will be conserved.

Definition at line 105 of file TwoTrackMinimumDistanceHelixLine.cc.

References dqmiolumiharvest::j, LogDebug, M_PI, and l1tGTMenu_lepSeeds_cff::qual.

107  {
108  pointsUpdated = false;
109  firstGTP = &theFirstGTP;
110  secondGTP = &theSecondGTP;
111 
112  if (updateCoeffs()) {
113  finalPoints();
114  return true;
115  };
116 
117  double fctVal, derVal, dPhiH;
118  thePhiH = thePhiH0;
119 
120  double x1 = thePhiH0 - M_PI, x2 = thePhiH0 + M_PI;
121  for (int j = 1; j <= themaxiter; ++j) {
122  oneIteration(thePhiH, fctVal, derVal);
123  dPhiH = fctVal / derVal;
124  thePhiH -= dPhiH;
125  if ((x1 - thePhiH) * (thePhiH - x2) < 0.0) {
126  LogDebug("TwoTrackMinimumDistanceHelixLine") << "Jumped out of brackets in root finding. Will be moved closer.";
127  thePhiH += (dPhiH * 0.8);
128  }
129  if (fabs(dPhiH) < qual) {
130  finalPoints();
131  return false;
132  }
133  }
134  LogDebug("TwoTrackMinimumDistanceHelixLine") << "Number of steps exceeded. Has not converged.";
135  finalPoints();
136  return true;
137 }
bool oneIteration(double &thePhiH, double &fct, double &derivative) const
#define M_PI
const GlobalTrajectoryParameters * firstGTP
const GlobalTrajectoryParameters * secondGTP
#define LogDebug(id)

◆ finalPoints()

void TwoTrackMinimumDistanceHelixLine::finalPoints ( )
private

Definition at line 167 of file TwoTrackMinimumDistanceHelixLine.cc.

References funct::cos(), change_name::diff, PV3DBase< T, PVType, FrameType >::mag(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, funct::sin(), and mathSSE::sqrt().

167  {
168  if (pointsUpdated)
169  return;
171  theH->position().y() + theh * (-cos(thePhiH) + thecosPhiH0),
172  theH->position().z() + theh * (thetanlambdaH * (thePhiH - thePhiH0)));
174 
175  GlobalVector diff((theL->position() - helixPoint).basicVector());
176  tL = (-diff.dot(theLp)) / (Ln * Ln);
177  linePoint =
178  GlobalPoint(theL->position().x() + tL * px, theL->position().y() + tL * py, theL->position().z() + tL * pz);
179  linePath = tL * theLp.mag();
180  pointsUpdated = true;
181 }
const GlobalTrajectoryParameters * theH
T z() const
Definition: PV3DBase.h:61
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const GlobalTrajectoryParameters * theL
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T mag() const
Definition: PV3DBase.h:64

◆ firstAngle()

double TwoTrackMinimumDistanceHelixLine::firstAngle ( ) const

Definition at line 139 of file TwoTrackMinimumDistanceHelixLine.cc.

139  {
140  if (firstGTP == theL)
141  return theL->momentum().phi();
142  else
143  return thePhiH;
144 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const GlobalTrajectoryParameters * theL
const GlobalTrajectoryParameters * firstGTP

◆ oneIteration()

bool TwoTrackMinimumDistanceHelixLine::oneIteration ( double &  thePhiH,
double &  fct,
double &  derivative 
) const
private

Definition at line 77 of file TwoTrackMinimumDistanceHelixLine.cc.

References gpuPixelDoublets::cc, funct::cos(), createTree::dd, funct::derivative(), alignCSCRings::ff, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, and funct::sin().

77  {
78  double thesinPhiH = sin(thePhiH);
79  double thecosPhiH = cos(thePhiH);
80 
81  // Fonction of which the root is to be found:
82 
83  fct = baseFct;
84  fct -= ff * (thePhiH - thePhiH0);
85  fct += thecosPhiH * aa;
86  fct += thesinPhiH * bb;
87  fct += cc * (thePhiH - thePhiH0) * (px * thecosPhiH + py * thesinPhiH);
88  fct += cc * (px * (thesinPhiH - thesinPhiH0) - py * (thecosPhiH - thecosPhiH0));
89  fct += dd * (thesinPhiH * (thesinPhiH - thesinPhiH0) - thecosPhiH * (thecosPhiH - thecosPhiH0));
90  fct += ee * thecosPhiH * thesinPhiH;
91 
92  // Its derivative:
93 
95  derivative += -thesinPhiH * aa;
96  derivative += thecosPhiH * bb;
97  derivative += cc * (thePhiH - thePhiH0) * (py * thecosPhiH - px * thesinPhiH);
98  derivative += 2 * cc * (px * thecosPhiH + py * thesinPhiH);
99  derivative += dd * (4 * thecosPhiH * thesinPhiH - thecosPhiH * thesinPhiH0 - thesinPhiH * thecosPhiH0);
100  derivative += ee * (thecosPhiH * thecosPhiH - thesinPhiH * thesinPhiH);
101 
102  return false;
103 }
Derivative< X, A >::type derivative(const A &_)
Definition: Derivative.h:18
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

◆ pathLength()

pair< double, double > TwoTrackMinimumDistanceHelixLine::pathLength ( ) const

Definition at line 160 of file TwoTrackMinimumDistanceHelixLine.cc.

160  {
161  if (firstGTP == theL)
162  return pair<double, double>(linePath, helixPath);
163  else
164  return pair<double, double>(helixPath, linePath);
165 }
const GlobalTrajectoryParameters * theL
const GlobalTrajectoryParameters * firstGTP

◆ points()

pair< GlobalPoint, GlobalPoint > TwoTrackMinimumDistanceHelixLine::points ( ) const

Returns the PCA's on the two trajectories. The first point lies on the first trajectory, the second point on the second trajectory.

Definition at line 153 of file TwoTrackMinimumDistanceHelixLine.cc.

153  {
154  if (firstGTP == theL)
155  return pair<GlobalPoint, GlobalPoint>(linePoint, helixPoint);
156  else
157  return pair<GlobalPoint, GlobalPoint>(helixPoint, linePoint);
158 }
const GlobalTrajectoryParameters * theL
const GlobalTrajectoryParameters * firstGTP

◆ secondAngle()

double TwoTrackMinimumDistanceHelixLine::secondAngle ( ) const

Definition at line 146 of file TwoTrackMinimumDistanceHelixLine.cc.

146  {
147  if (secondGTP == theL)
148  return theL->momentum().phi();
149  else
150  return thePhiH;
151 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const GlobalTrajectoryParameters * theL
const GlobalTrajectoryParameters * secondGTP

◆ updateCoeffs()

bool TwoTrackMinimumDistanceHelixLine::updateCoeffs ( )
private

Definition at line 10 of file TwoTrackMinimumDistanceHelixLine.cc.

References gpuPixelDoublets::cc, funct::cos(), createTree::dd, alignCSCRings::ff, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, funct::sin(), mathSSE::sqrt(), X, beamSpotPI::Y, and beamSpotPI::Z.

10  {
11  bool isFirstALine = firstGTP->charge() == 0. || firstGTP->magneticField().inTesla(firstGTP->position()).z() == 0.;
12  bool isSecondALine = secondGTP->charge() == 0. || secondGTP->magneticField().inTesla(secondGTP->position()).z() == 0.;
13  if (isFirstALine && !isSecondALine) {
14  theL = firstGTP;
15  theH = secondGTP;
16  } else if (!isFirstALine && isSecondALine) {
17  theH = firstGTP;
18  theL = secondGTP;
19  } else {
20  edm::LogWarning("TwoTrackMinimumDistanceHelixLine")
21  << "Error in track charge: "
22  << "One of the tracks has to be charged, and the other not." << endl
23  << "Track Charges: " << firstGTP->charge() << " and " << secondGTP->charge();
24  return true;
25  }
26 
27  Hn = theH->momentum().mag();
28  Ln = theL->momentum().mag();
29 
30  if (Hn == 0. || Ln == 0.) {
31  edm::LogWarning("TwoTrackMinimumDistanceHelixLine") << "Momentum of input trajectory is zero.";
32  return true;
33  };
34 
35  GlobalPoint lOrig = theL->position();
36  GlobalPoint hOrig = theH->position();
37  posDiff = GlobalVector((lOrig - hOrig).basicVector());
38  X = posDiff.x();
39  Y = posDiff.y();
40  Z = posDiff.z();
41  theLp = theL->momentum();
42  px = theLp.x();
43  px2 = px * px;
44  py = theLp.y();
45  py2 = py * py;
46  pz = theLp.z();
47  pz2 = pz * pz;
48 
49  const double Bc2kH = theH->magneticField().inTesla(hOrig).z() * 2.99792458e-3;
50  // MagneticField::inInverseGeV ( hOrig ).z();
51 
52  if (Bc2kH == 0.) {
53  edm::LogWarning("TwoTrackMinimumDistanceHelixLine") << "Magnetic field at point " << hOrig << " is zero.";
54  return true;
55  };
56 
57  theh = -Hn / (theH->charge() * Bc2kH) * sqrt(1 - (((theH->momentum().z() * theH->momentum().z()) / (Hn * Hn))));
58 
59  thetanlambdaH = -theH->momentum().z() / (theH->charge() * Bc2kH * theh);
60 
61  thePhiH0 = theH->momentum().phi();
64 
65  aa = (X + theh * thesinPhiH0) * (py2 + pz2) - px * (py * Y + pz * Z);
66  bb = (Y - theh * thecosPhiH0) * (px2 + pz2) - py * (px * X + pz * Z);
67  cc = pz * theh * thetanlambdaH;
68  dd = theh * px * py;
69  ee = theh * (px2 - py2);
71 
72  baseFct = thetanlambdaH * (Z * (px2 + py2) - pz * (px * X + py * Y));
73  baseDer = -ff;
74  return false;
75 }
const GlobalTrajectoryParameters * theH
T z() const
Definition: PV3DBase.h:61
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const GlobalTrajectoryParameters * theL
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T mag() const
Definition: PV3DBase.h:64
const GlobalTrajectoryParameters * firstGTP
const MagneticField & magneticField() const
Log< level::Warning, false > LogWarning
const GlobalTrajectoryParameters * secondGTP
Global3DVector GlobalVector
Definition: GlobalVector.h:10

Member Data Documentation

◆ aa

double TwoTrackMinimumDistanceHelixLine::aa
private

◆ baseDer

double TwoTrackMinimumDistanceHelixLine::baseDer
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ baseFct

double TwoTrackMinimumDistanceHelixLine::baseFct
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ bb

double TwoTrackMinimumDistanceHelixLine::bb
private

◆ cc

double TwoTrackMinimumDistanceHelixLine::cc
private

◆ dd

double TwoTrackMinimumDistanceHelixLine::dd
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

◆ ee

double TwoTrackMinimumDistanceHelixLine::ee
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

◆ ff

double TwoTrackMinimumDistanceHelixLine::ff
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

◆ firstGTP

const GlobalTrajectoryParameters * TwoTrackMinimumDistanceHelixLine::firstGTP
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixLine.h.

◆ helixPath

double TwoTrackMinimumDistanceHelixLine::helixPath
private

Definition at line 58 of file TwoTrackMinimumDistanceHelixLine.h.

◆ helixPoint

GlobalPoint TwoTrackMinimumDistanceHelixLine::helixPoint
private

Definition at line 57 of file TwoTrackMinimumDistanceHelixLine.h.

◆ Hn

double TwoTrackMinimumDistanceHelixLine::Hn
private

Definition at line 50 of file TwoTrackMinimumDistanceHelixLine.h.

◆ linePath

double TwoTrackMinimumDistanceHelixLine::linePath
private

Definition at line 58 of file TwoTrackMinimumDistanceHelixLine.h.

◆ linePoint

GlobalPoint TwoTrackMinimumDistanceHelixLine::linePoint
private

Definition at line 57 of file TwoTrackMinimumDistanceHelixLine.h.

◆ Ln

double TwoTrackMinimumDistanceHelixLine::Ln
private

Definition at line 50 of file TwoTrackMinimumDistanceHelixLine.h.

◆ pointsUpdated

bool TwoTrackMinimumDistanceHelixLine::pointsUpdated
private

Definition at line 59 of file TwoTrackMinimumDistanceHelixLine.h.

◆ posDiff

GlobalVector TwoTrackMinimumDistanceHelixLine::posDiff
private

Definition at line 45 of file TwoTrackMinimumDistanceHelixLine.h.

◆ px

double TwoTrackMinimumDistanceHelixLine::px
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ px2

double TwoTrackMinimumDistanceHelixLine::px2
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ py

double TwoTrackMinimumDistanceHelixLine::py
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ py2

double TwoTrackMinimumDistanceHelixLine::py2
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ pz

double TwoTrackMinimumDistanceHelixLine::pz
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ pz2

double TwoTrackMinimumDistanceHelixLine::pz2
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ secondGTP

const GlobalTrajectoryParameters * TwoTrackMinimumDistanceHelixLine::secondGTP
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixLine.h.

◆ thecosPhiH0

double TwoTrackMinimumDistanceHelixLine::thecosPhiH0
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

◆ theH

const GlobalTrajectoryParameters* TwoTrackMinimumDistanceHelixLine::theH
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixLine.h.

◆ theh

double TwoTrackMinimumDistanceHelixLine::theh
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

◆ theL

const GlobalTrajectoryParameters * TwoTrackMinimumDistanceHelixLine::theL
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixLine.h.

◆ theLp

GlobalVector TwoTrackMinimumDistanceHelixLine::theLp
private

Definition at line 46 of file TwoTrackMinimumDistanceHelixLine.h.

◆ themaxiter

int TwoTrackMinimumDistanceHelixLine::themaxiter
private

Definition at line 53 of file TwoTrackMinimumDistanceHelixLine.h.

◆ thePhiH

double TwoTrackMinimumDistanceHelixLine::thePhiH
private

Definition at line 49 of file TwoTrackMinimumDistanceHelixLine.h.

◆ thePhiH0

double TwoTrackMinimumDistanceHelixLine::thePhiH0
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

◆ thesinPhiH0

double TwoTrackMinimumDistanceHelixLine::thesinPhiH0
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

◆ thetanlambdaH

double TwoTrackMinimumDistanceHelixLine::thetanlambdaH
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

◆ tL

double TwoTrackMinimumDistanceHelixLine::tL
private

Definition at line 58 of file TwoTrackMinimumDistanceHelixLine.h.

◆ X

double TwoTrackMinimumDistanceHelixLine::X
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

Referenced by svgfig.Curve.Sample::__repr__().

◆ Y

double TwoTrackMinimumDistanceHelixLine::Y
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.

◆ Z

double TwoTrackMinimumDistanceHelixLine::Z
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixLine.h.