CMS 3D CMS Logo

Public Member Functions | Private Attributes

TwoTrackMinimumDistanceLineLine Class Reference

#include <TwoTrackMinimumDistanceLineLine.h>

List of all members.

Public Member Functions

bool calculate (const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &)
double firstAngle () const
std::pair< double, double > pathLength () const
std::pair< GlobalPoint,
GlobalPoint
points () 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 18 of file TwoTrackMinimumDistanceLineLine.h.


Member Function Documentation

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 8 of file TwoTrackMinimumDistanceLineLine.cc.

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

{
  GlobalPoint gOrig = theG.position();
  GlobalPoint hOrig = theH.position();
  bool isLineG = theG.magneticField().inTesla(gOrig).z() == 0 || theG.charge() == 0;
  bool isLineH = theH.magneticField().inTesla(hOrig).z() == 0 || theH.charge() == 0;
  if ( ! (isLineG && isLineH) )
  {
    edm::LogWarning ("TwoTrackMinimumDistanceLineLine")
      << "charge of input track is not zero or field non zero"
      << "\n positions: "<<gOrig<<" , "<<hOrig
      << "\n Bz fields: "<<theG.magneticField().inTesla(gOrig).z()<<" , "<<theH.magneticField().inTesla(hOrig).z()
      << "\n charges: "<<theG.charge()<<" , "<<theH.charge();
    return true;
  };

  GlobalVector gVec = theG.momentum();
  const double gMag= theG.momentum().mag(); double gMag2 = gMag*gMag;
  GlobalVector hVec = theH.momentum();
  const double hMag= theH.momentum().mag(); double hMag2 = hMag*hMag;

  if ( gMag == 0. || hMag == 0. )
  {
    edm::LogWarning ("TwoTrackMinimumDistanceLineLine")
      << "momentum of input trajectory is zero.";
    return true;
  };

  phiG = theG.momentum().phi();
  phiH = theH.momentum().phi();

  double gVec_Dot_hVec = gVec.dot(hVec);
  double norm  = gVec_Dot_hVec*gVec_Dot_hVec - gMag2*hMag2;

  if ( norm == 0 )
  {
    edm::LogWarning ("TwoTrackMinimumDistanceLineLine")
      << "Tracks are parallel.";
    return true;
  }

  GlobalVector posDiff = gOrig - hOrig;

  double tG = (posDiff.dot(gVec) * hMag2 - gVec_Dot_hVec * posDiff.dot(hVec))/ norm;
  double tH = (gVec_Dot_hVec * posDiff.dot(gVec) - posDiff.dot(hVec) * gMag2)/ norm;

  gPos = GlobalPoint ( gOrig + tG * gVec);
  hPos = GlobalPoint ( hOrig + tH * hVec);
//   cout << "TwoTrackMinimumDistanceLineLine "<<gPos<<hPos<<endl;

  pathG = tG * gMag;
  pathH = tH * hMag;
  return false;
}
double TwoTrackMinimumDistanceLineLine::firstAngle ( ) const [inline]

Definition at line 36 of file TwoTrackMinimumDistanceLineLine.h.

References phiG.

{return phiG;}
std::pair< double, double > TwoTrackMinimumDistanceLineLine::pathLength ( ) const

Definition at line 70 of file TwoTrackMinimumDistanceLineLine.cc.

References pathG, and pathH.

{
  return std::pair<double, double> ( pathG, pathH);
}
std::pair< GlobalPoint, GlobalPoint > TwoTrackMinimumDistanceLineLine::points ( ) const

Definition at line 65 of file TwoTrackMinimumDistanceLineLine.cc.

References gPos, and hPos.

{
  return std::pair<GlobalPoint, GlobalPoint > ( gPos, hPos );
}
double TwoTrackMinimumDistanceLineLine::secondAngle ( ) const [inline]

Definition at line 37 of file TwoTrackMinimumDistanceLineLine.h.

References phiH.

{return phiH;}

Member Data Documentation

Definition at line 41 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and points().

Definition at line 41 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and points().

Definition at line 40 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and pathLength().

Definition at line 40 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and pathLength().

Definition at line 39 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and firstAngle().

Definition at line 39 of file TwoTrackMinimumDistanceLineLine.h.

Referenced by calculate(), and secondAngle().