CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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,
GlobalPoint
points () const
 
double secondAngle () const
 
 TwoTrackMinimumDistanceHelixLine ()
 
 ~TwoTrackMinimumDistanceHelixLine ()
 

Private Member Functions

void finalPoints () const
 
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
 
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
 
GlobalTrajectoryParameterssecondGTP
 
double thecosPhiH0
 
GlobalTrajectoryParameterstheH
 
double theh
 
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.

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

References j, LogDebug, and M_PI.

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

Definition at line 174 of file TwoTrackMinimumDistanceHelixLine.cc.

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

175 {
177  theH->position().x() + theh * ( sin ( thePhiH) - thesinPhiH0 ),
178  theH->position().y() + theh * ( - cos ( thePhiH) + thecosPhiH0 ),
179  theH->position().z() + theh * ( thetanlambdaH * ( thePhiH- thePhiH0 ))
180  );
182 
183  GlobalVector diff((theL->position() -helixPoint).basicVector());
184  tL = ( - diff.dot(theLp)) / (Ln*Ln);
186  theL->position().x() + tL * px,
187  theL->position().y() + tL * py,
188  theL->position().z() + tL * pz );
189  linePath = tL * theLp.mag();
190  pointsUpdated = true;
191 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:57
T mag() const
Definition: PV3DBase.h:61
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T x() const
Definition: PV3DBase.h:56
double TwoTrackMinimumDistanceHelixLine::firstAngle ( ) const

Definition at line 145 of file TwoTrackMinimumDistanceHelixLine.cc.

146 {
147  if (firstGTP==theL) return theL->momentum().phi();
148  else return thePhiH;
149 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
bool TwoTrackMinimumDistanceHelixLine::oneIteration ( double &  thePhiH,
double &  fct,
double &  derivative 
) const
private

Definition at line 79 of file TwoTrackMinimumDistanceHelixLine.cc.

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

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

159 {
160  if (!pointsUpdated)finalPoints();
161  if (firstGTP==theL)
162  return pair<GlobalPoint, GlobalPoint> (linePoint, helixPoint);
163  else return pair<GlobalPoint, GlobalPoint> (helixPoint, linePoint);
164 }
double TwoTrackMinimumDistanceHelixLine::secondAngle ( ) const

Definition at line 151 of file TwoTrackMinimumDistanceHelixLine.cc.

152 {
153  if (secondGTP==theL) return theL->momentum().phi();
154  else return thePhiH;
155 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
bool TwoTrackMinimumDistanceHelixLine::updateCoeffs ( )
private

Definition at line 10 of file TwoTrackMinimumDistanceHelixLine.cc.

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

11 {
12 
13  if (firstGTP->charge() == 0. && secondGTP->charge() != 0.) {
14  theL= firstGTP;
15  theH= secondGTP;
16  } else if (firstGTP->charge() != 0. && secondGTP->charge() == 0.) {
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  {
32  edm::LogWarning ("TwoTrackMinimumDistanceHelixLine")
33  << "Momentum of input trajectory is zero.";
34  return true;
35  };
36 
37  GlobalPoint lOrig = theL->position();
38  GlobalPoint hOrig = theH->position();
39  posDiff = GlobalVector((lOrig - hOrig).basicVector());
40  X = posDiff.x();
41  Y = posDiff.y();
42  Z = posDiff.z();
43  theLp = theL->momentum();
44  px = theLp.x(); px2 = px*px;
45  py = theLp.y(); py2 = py*py;
46  pz = theLp.z(); pz2 = pz*pz;
47 
48  const double Bc2kH = theH->magneticField().inTesla(hOrig).z() * 2.99792458e-3;
49 // MagneticField::inInverseGeV ( hOrig ).z();
50 
51  if ( Bc2kH == 0. )
52  {
53  edm::LogWarning ("TwoTrackMinimumDistanceHelixLine")
54  << "Magnetic field at point " << hOrig << " is zero.";
55  return true;
56  };
57 
58  theh= - Hn / (theH->charge() * Bc2kH ) *
59  sqrt( 1 - ( ( (theH->momentum().z()*theH->momentum().z()) / (Hn*Hn) )));
60 
61  thetanlambdaH = - theH->momentum().z() / ( theH->charge() * Bc2kH * theh);
62 
63  thePhiH0 = theH->momentum().phi();
66 
67  aa = (X + theh*thesinPhiH0)*(py2 + pz2) - px*(py*Y + pz*Z);
68  bb = (Y - theh*thecosPhiH0)*(px2 + pz2) - py*(px*X + pz*Z);
69  cc = pz*theh*thetanlambdaH;
70  dd = theh* px *py;
71  ee = theh*(px2 - py2);
72  ff = (px2 + py2)*theh*thetanlambdaH*thetanlambdaH;
73 
74  baseFct = thetanlambdaH * (Z*(px2+py2) - pz*(px*X + py*Y));
75  baseDer = - ff;
76  return false;
77 }
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
T y() const
Definition: PV3DBase.h:57
T mag() const
Definition: PV3DBase.h:61
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const MagneticField & magneticField() const
T x() const
Definition: PV3DBase.h:56
Global3DVector GlobalVector
Definition: GlobalVector.h:10

Member Data Documentation

double TwoTrackMinimumDistanceHelixLine::aa
private

Definition at line 55 of file TwoTrackMinimumDistanceHelixLine.h.

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

Definition at line 55 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::cc
private

Definition at line 55 of file TwoTrackMinimumDistanceHelixLine.h.

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.

GlobalTrajectoryParameters * TwoTrackMinimumDistanceHelixLine::firstGTP
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::helixPath
mutableprivate

Definition at line 62 of file TwoTrackMinimumDistanceHelixLine.h.

GlobalPoint TwoTrackMinimumDistanceHelixLine::helixPoint
mutableprivate

Definition at line 61 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::Hn
private

Definition at line 54 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::linePath
mutableprivate

Definition at line 62 of file TwoTrackMinimumDistanceHelixLine.h.

GlobalPoint TwoTrackMinimumDistanceHelixLine::linePoint
mutableprivate

Definition at line 61 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::Ln
private

Definition at line 54 of file TwoTrackMinimumDistanceHelixLine.h.

bool TwoTrackMinimumDistanceHelixLine::pointsUpdated
mutableprivate

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.

GlobalTrajectoryParameters * TwoTrackMinimumDistanceHelixLine::secondGTP
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::thecosPhiH0
private

Definition at line 52 of file TwoTrackMinimumDistanceHelixLine.h.

GlobalTrajectoryParameters* TwoTrackMinimumDistanceHelixLine::theH
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixLine.h.

double TwoTrackMinimumDistanceHelixLine::theh
private

Definition at line 52 of file TwoTrackMinimumDistanceHelixLine.h.

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
mutableprivate

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.