CMS 3D CMS Logo

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 ( )
inline
TwoTrackMinimumDistanceHelixLine::~TwoTrackMinimumDistanceHelixLine ( )
inline

Definition at line 23 of file TwoTrackMinimumDistanceHelixLine.h.

References calculate(), firstAngle(), pathLength(), points(), and secondAngle().

23 {}

Member Function Documentation

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 113 of file TwoTrackMinimumDistanceHelixLine.cc.

References LogDebug, M_PI, globals_cff::x1, and globals_cff::x2.

Referenced by ~TwoTrackMinimumDistanceHelixLine().

116 {
117  pointsUpdated = false;
118  firstGTP = &theFirstGTP;
119  secondGTP = &theSecondGTP;
120 
121  if ( updateCoeffs () )
122  {
123  finalPoints();
124  return true;
125  };
126 
127  double fctVal, derVal, dPhiH;
128  thePhiH = thePhiH0;
129 
130  double x1=thePhiH0-M_PI, x2=thePhiH0+M_PI;
131  for (int j=1; j<=themaxiter; ++j) {
132  oneIteration(thePhiH, fctVal, derVal);
133  dPhiH=fctVal/derVal;
134  thePhiH -= dPhiH;
135  if ((x1-thePhiH)*(thePhiH-x2) < 0.0) {
136  LogDebug ("TwoTrackMinimumDistanceHelixLine")
137  << "Jumped out of brackets in root finding. Will be moved closer.";
138  thePhiH += (dPhiH*0.8);
139  }
140  if (fabs(dPhiH) < qual) {
141  finalPoints();
142  return false;
143  }
144  }
145  LogDebug ("TwoTrackMinimumDistanceHelixLine")
146  <<"Number of steps exceeded. Has not converged.";
147  finalPoints();
148  return true;
149 }
#define LogDebug(id)
bool oneIteration(double &thePhiH, double &fct, double &derivative) const
#define M_PI
const GlobalTrajectoryParameters * firstGTP
const GlobalTrajectoryParameters * secondGTP
void TwoTrackMinimumDistanceHelixLine::finalPoints ( )
private

Definition at line 177 of file TwoTrackMinimumDistanceHelixLine.cc.

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

178 {
179  if (pointsUpdated) return;
181  theH->position().x() + theh * ( sin ( thePhiH) - thesinPhiH0 ),
182  theH->position().y() + theh * ( - cos ( thePhiH) + thecosPhiH0 ),
183  theH->position().z() + theh * ( thetanlambdaH * ( thePhiH- thePhiH0 ))
184  );
186 
187  GlobalVector diff((theL->position() -helixPoint).basicVector());
188  tL = ( - diff.dot(theLp)) / (Ln*Ln);
190  theL->position().x() + tL * px,
191  theL->position().y() + tL * py,
192  theL->position().z() + tL * pz );
193  linePath = tL * theLp.mag();
194  pointsUpdated = true;
195 }
const GlobalTrajectoryParameters * theH
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
const GlobalTrajectoryParameters * theL
T mag() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T x() const
Definition: PV3DBase.h:62
double TwoTrackMinimumDistanceHelixLine::firstAngle ( ) const

Definition at line 151 of file TwoTrackMinimumDistanceHelixLine.cc.

Referenced by ~TwoTrackMinimumDistanceHelixLine().

152 {
153  if (firstGTP==theL) return theL->momentum().phi();
154  else return thePhiH;
155 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const GlobalTrajectoryParameters * theL
const GlobalTrajectoryParameters * firstGTP
bool TwoTrackMinimumDistanceHelixLine::oneIteration ( double &  thePhiH,
double &  fct,
double &  derivative 
) const
private

Definition at line 80 of file TwoTrackMinimumDistanceHelixLine.cc.

References funct::cos(), createTree::dd, alignCSCRings::ff, and funct::sin().

82 {
83 
84  double thesinPhiH = sin(thePhiH);
85  double thecosPhiH = cos(thePhiH);
86 
87  // Fonction of which the root is to be found:
88 
89  fct = baseFct;
90  fct -= ff*(thePhiH - thePhiH0);
91  fct += thecosPhiH * aa;
92  fct += thesinPhiH * bb;
93  fct += cc*(thePhiH - thePhiH0)*(px * thecosPhiH + py * thesinPhiH);
94  fct += cc * (px * (thesinPhiH - thesinPhiH0) - py * (thecosPhiH - thecosPhiH0));
95  fct += dd * (thesinPhiH* (thesinPhiH - thesinPhiH0) -
96  thecosPhiH*(thecosPhiH - thecosPhiH0));
97  fct += ee * thecosPhiH * thesinPhiH;
98 
99  // Its derivative:
100 
102  derivative += - thesinPhiH * aa;
103  derivative += thecosPhiH * bb;
104  derivative += cc*(thePhiH - thePhiH0)*(py * thecosPhiH - px * thesinPhiH);
105  derivative += 2* cc*(px * thecosPhiH + py * thesinPhiH);
106  derivative += dd *(4 * thecosPhiH * thesinPhiH - thecosPhiH * thesinPhiH0 -
107  thesinPhiH * thecosPhiH0);
108  derivative += ee * (thecosPhiH*thecosPhiH-thesinPhiH*thesinPhiH);
109 
110  return false;
111 }
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
pair< double, double > TwoTrackMinimumDistanceHelixLine::pathLength ( ) const

Definition at line 170 of file TwoTrackMinimumDistanceHelixLine.cc.

Referenced by ~TwoTrackMinimumDistanceHelixLine().

171 {
172  if (firstGTP==theL)
173  return pair<double, double> (linePath, helixPath);
174  else return pair<double, double> (helixPath, linePath);
175 }
const GlobalTrajectoryParameters * theL
const GlobalTrajectoryParameters * firstGTP
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 163 of file TwoTrackMinimumDistanceHelixLine.cc.

Referenced by ~TwoTrackMinimumDistanceHelixLine().

164 {
165  if (firstGTP==theL)
166  return pair<GlobalPoint, GlobalPoint> (linePoint, helixPoint);
167  else return pair<GlobalPoint, GlobalPoint> (helixPoint, linePoint);
168 }
const GlobalTrajectoryParameters * theL
const GlobalTrajectoryParameters * firstGTP
double TwoTrackMinimumDistanceHelixLine::secondAngle ( ) const

Definition at line 157 of file TwoTrackMinimumDistanceHelixLine.cc.

Referenced by ~TwoTrackMinimumDistanceHelixLine().

158 {
159  if (secondGTP==theL) return theL->momentum().phi();
160  else return thePhiH;
161 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const GlobalTrajectoryParameters * theL
const GlobalTrajectoryParameters * secondGTP
bool TwoTrackMinimumDistanceHelixLine::updateCoeffs ( )
private

Definition at line 10 of file TwoTrackMinimumDistanceHelixLine.cc.

References funct::cos(), createTree::dd, alignCSCRings::ff, funct::sin(), mathSSE::sqrt(), X, DOFs::Y, and DOFs::Z.

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

Member Data Documentation

double TwoTrackMinimumDistanceHelixLine::aa
private
double TwoTrackMinimumDistanceHelixLine::baseDer
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::baseFct
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::bb
private
double TwoTrackMinimumDistanceHelixLine::cc
private
double TwoTrackMinimumDistanceHelixLine::dd
private

Definition at line 55 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::ee
private

Definition at line 55 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::ff
private

Definition at line 55 of file TwoTrackMinimumDistanceHelixLine.h.

const GlobalTrajectoryParameters * TwoTrackMinimumDistanceHelixLine::firstGTP
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::helixPath
private

Definition at line 62 of file TwoTrackMinimumDistanceHelixLine.h.

GlobalPoint TwoTrackMinimumDistanceHelixLine::helixPoint
private

Definition at line 61 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::Hn
private

Definition at line 54 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::linePath
private

Definition at line 62 of file TwoTrackMinimumDistanceHelixLine.h.

GlobalPoint TwoTrackMinimumDistanceHelixLine::linePoint
private

Definition at line 61 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::Ln
private

Definition at line 54 of file TwoTrackMinimumDistanceHelixLine.h.

bool TwoTrackMinimumDistanceHelixLine::pointsUpdated
private

Definition at line 63 of file TwoTrackMinimumDistanceHelixLine.h.

GlobalVector TwoTrackMinimumDistanceHelixLine::posDiff
private

Definition at line 49 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::px
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::px2
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::py
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::py2
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::pz
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::pz2
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

const GlobalTrajectoryParameters * TwoTrackMinimumDistanceHelixLine::secondGTP
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::thecosPhiH0
private

Definition at line 52 of file TwoTrackMinimumDistanceHelixLine.h.

const GlobalTrajectoryParameters* TwoTrackMinimumDistanceHelixLine::theH
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::theh
private

Definition at line 52 of file TwoTrackMinimumDistanceHelixLine.h.

const GlobalTrajectoryParameters * TwoTrackMinimumDistanceHelixLine::theL
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

GlobalVector TwoTrackMinimumDistanceHelixLine::theLp
private

Definition at line 50 of file TwoTrackMinimumDistanceHelixLine.h.

int TwoTrackMinimumDistanceHelixLine::themaxiter
private

Definition at line 57 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::thePhiH
private

Definition at line 53 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::thePhiH0
private

Definition at line 52 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::thesinPhiH0
private

Definition at line 52 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::thetanlambdaH
private

Definition at line 52 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::tL
private

Definition at line 62 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::X
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

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

double TwoTrackMinimumDistanceHelixLine::Y
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::Z
private

Definition at line 51 of file TwoTrackMinimumDistanceHelixLine.h.