CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TwoTrackMinimumDistanceLineLine Class Reference

#include <TwoTrackMinimumDistanceLineLine.h>

Public Member Functions

bool calculate (const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &)
 
double firstAngle () const
 
std::pair< double, double > pathLength () const
 
std::pair< GlobalPoint, GlobalPointpoints () const
 
double secondAngle () const
 

Private Attributes

GlobalPoint gPos
 
GlobalPoint hPos
 
double pathG
 
double pathH
 
double phiG
 
double phiH
 

Detailed Description

This is a helper class for TwoTrackMinimumDistance. No user should need direct access to this class. Exact solution.

Definition at line 17 of file TwoTrackMinimumDistanceLineLine.h.

Member Function Documentation

◆ calculate()

bool TwoTrackMinimumDistanceLineLine::calculate ( const GlobalTrajectoryParameters theG,
const GlobalTrajectoryParameters theH 
)

Calculates the point of closest approach on the two tracks.

Returns
false in case of success
true in case of failure. Possible failures:
  • Either of the Trajectories are charged
  • Either of the Trajectories is of zero momentum
  • Trajectories are parallel

Definition at line 7 of file TwoTrackMinimumDistanceLineLine.cc.

8  {
9  GlobalPoint gOrig = theG.position();
10  GlobalPoint hOrig = theH.position();
11  bool isLineG = theG.magneticField().inTesla(gOrig).z() == 0 || theG.charge() == 0;
12  bool isLineH = theH.magneticField().inTesla(hOrig).z() == 0 || theH.charge() == 0;
13  if (!(isLineG && isLineH)) {
14  edm::LogWarning("TwoTrackMinimumDistanceLineLine")
15  << "charge of input track is not zero or field non zero"
16  << "\n positions: " << gOrig << " , " << hOrig << "\n Bz fields: " << theG.magneticField().inTesla(gOrig).z()
17  << " , " << theH.magneticField().inTesla(hOrig).z() << "\n charges: " << theG.charge() << " , "
18  << theH.charge();
19  return true;
20  };
21 
22  GlobalVector gVec = theG.momentum();
23  const double gMag = theG.momentum().mag();
24  double gMag2 = gMag * gMag;
25  GlobalVector hVec = theH.momentum();
26  const double hMag = theH.momentum().mag();
27  double hMag2 = hMag * hMag;
28 
29  if (gMag == 0. || hMag == 0.) {
30  edm::LogWarning("TwoTrackMinimumDistanceLineLine") << "momentum of input trajectory is zero.";
31  return true;
32  };
33 
34  phiG = theG.momentum().phi();
35  phiH = theH.momentum().phi();
36 
37  double gVec_Dot_hVec = gVec.dot(hVec);
38  double norm = gVec_Dot_hVec * gVec_Dot_hVec - gMag2 * hMag2;
39 
40  if (norm == 0) {
41  edm::LogWarning("TwoTrackMinimumDistanceLineLine") << "Tracks are parallel.";
42  return true;
43  }
44 
45  GlobalVector posDiff = gOrig - hOrig;
46 
47  double tG = (posDiff.dot(gVec) * hMag2 - gVec_Dot_hVec * posDiff.dot(hVec)) / norm;
48  double tH = (gVec_Dot_hVec * posDiff.dot(gVec) - posDiff.dot(hVec) * gMag2) / norm;
49 
50  gPos = GlobalPoint(gOrig + tG * gVec);
51  hPos = GlobalPoint(hOrig + tH * hVec);
52  // cout << "TwoTrackMinimumDistanceLineLine "<<gPos<<hPos<<endl;
53 
54  pathG = tG * gMag;
55  pathH = tH * hMag;
56  return false;
57 }

References GlobalTrajectoryParameters::charge(), Vector3DBase< T, FrameTag >::dot(), gPos, hPos, MagneticField::inTesla(), PV3DBase< T, PVType, FrameType >::mag(), GlobalTrajectoryParameters::magneticField(), GlobalTrajectoryParameters::momentum(), pathG, pathH, PV3DBase< T, PVType, FrameType >::phi(), phiG, phiH, GlobalTrajectoryParameters::position(), and PV3DBase< T, PVType, FrameType >::z().

◆ firstAngle()

double TwoTrackMinimumDistanceLineLine::firstAngle ( ) const
inline

Definition at line 34 of file TwoTrackMinimumDistanceLineLine.h.

34 { return phiG; }

References phiG.

◆ pathLength()

std::pair< double, double > TwoTrackMinimumDistanceLineLine::pathLength ( ) const

Definition at line 63 of file TwoTrackMinimumDistanceLineLine.cc.

63  {
64  return std::pair<double, double>(pathG, pathH);
65 }

References pathG, and pathH.

◆ points()

std::pair< GlobalPoint, GlobalPoint > TwoTrackMinimumDistanceLineLine::points ( ) const

Definition at line 59 of file TwoTrackMinimumDistanceLineLine.cc.

59  {
60  return std::pair<GlobalPoint, GlobalPoint>(gPos, hPos);
61 }

References gPos, and hPos.

◆ secondAngle()

double TwoTrackMinimumDistanceLineLine::secondAngle ( ) const
inline

Definition at line 35 of file TwoTrackMinimumDistanceLineLine.h.

35 { return phiH; }

References phiH.

Member Data Documentation

◆ gPos

GlobalPoint TwoTrackMinimumDistanceLineLine::gPos
private

Definition at line 40 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and points().

◆ hPos

GlobalPoint TwoTrackMinimumDistanceLineLine::hPos
private

Definition at line 40 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and points().

◆ pathG

double TwoTrackMinimumDistanceLineLine::pathG
private

Definition at line 39 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and pathLength().

◆ pathH

double TwoTrackMinimumDistanceLineLine::pathH
private

Definition at line 39 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and pathLength().

◆ phiG

double TwoTrackMinimumDistanceLineLine::phiG
private

Definition at line 38 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and firstAngle().

◆ phiH

double TwoTrackMinimumDistanceLineLine::phiH
private

Definition at line 38 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and secondAngle().

Vector3DBase
Definition: Vector3DBase.h:8
MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
GlobalTrajectoryParameters::position
GlobalPoint position() const
Definition: GlobalTrajectoryParameters.h:60
TwoTrackMinimumDistanceLineLine::hPos
GlobalPoint hPos
Definition: TwoTrackMinimumDistanceLineLine.h:40
GlobalTrajectoryParameters::charge
TrackCharge charge() const
Definition: GlobalTrajectoryParameters.h:72
TwoTrackMinimumDistanceLineLine::phiH
double phiH
Definition: TwoTrackMinimumDistanceLineLine.h:38
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
TwoTrackMinimumDistanceLineLine::gPos
GlobalPoint gPos
Definition: TwoTrackMinimumDistanceLineLine.h:40
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
GlobalTrajectoryParameters::momentum
GlobalVector momentum() const
Definition: GlobalTrajectoryParameters.h:65
edm::LogWarning
Definition: MessageLogger.h:141
TwoTrackMinimumDistanceLineLine::pathH
double pathH
Definition: TwoTrackMinimumDistanceLineLine.h:39
TwoTrackMinimumDistanceLineLine::phiG
double phiG
Definition: TwoTrackMinimumDistanceLineLine.h:38
Vector3DBase::dot
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
TwoTrackMinimumDistanceLineLine::pathG
double pathG
Definition: TwoTrackMinimumDistanceLineLine.h:39
GlobalTrajectoryParameters::magneticField
const MagneticField & magneticField() const
Definition: GlobalTrajectoryParameters.h:106
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66