CMS 3D CMS Logo

Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes

TwoTrackMinimumDistance Class Reference

#include <TwoTrackMinimumDistance.h>

Inheritance diagram for TwoTrackMinimumDistance:
ClosestApproachOnHelices

List of all members.

Public Types

enum  Mode { FastMode = 0, SlowMode = 1 }

Public Member Functions

virtual bool calculate (const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
virtual bool calculate (const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
virtual bool calculate (const FreeTrajectoryState &sta, const FreeTrajectoryState &stb)
virtual TwoTrackMinimumDistanceclone () const
virtual GlobalPoint crossingPoint () const
virtual float distance () const
double firstAngle () const
std::pair< double, double > pathLength () const
virtual std::pair< GlobalPoint,
GlobalPoint
points () const
double secondAngle () const
virtual bool status () const
 TwoTrackMinimumDistance (const Mode m=FastMode)

Private Types

enum  Charge { hh, hl, ll }

Private Member Functions

bool pointsHelixHelix (const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
bool pointsHelixLine (const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
bool pointsLineLine (const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)

Private Attributes

std::pair< GlobalPoint,
GlobalPoint
points_
bool status_
Charge theCharge
ClosestApproachInRPhi theIniAlgo
Mode theModus
TwoTrackMinimumDistanceHelixHelix theTTMDhh
TwoTrackMinimumDistanceHelixLine theTTMDhl
TwoTrackMinimumDistanceLineLine theTTMDll

Detailed Description

General interface to calculate the PCA of two tracks. According to the charge of the tracks, the correct algorithm is used:

Definition at line 19 of file TwoTrackMinimumDistance.h.


Member Enumeration Documentation

Enumerator:
hh 
hl 
ll 

Definition at line 63 of file TwoTrackMinimumDistance.h.

{ hh, hl, ll };
Enumerator:
FastMode 
SlowMode 

Definition at line 23 of file TwoTrackMinimumDistance.h.

{ FastMode=0, SlowMode=1 };

Constructor & Destructor Documentation

TwoTrackMinimumDistance::TwoTrackMinimumDistance ( const Mode  m = FastMode) [inline]

Definition at line 25 of file TwoTrackMinimumDistance.h.

References m, status_, and theModus.

Referenced by clone().

{ theModus=m; status_ = false;};

Member Function Documentation

bool TwoTrackMinimumDistance::calculate ( const TrajectoryStateOnSurface sta,
const TrajectoryStateOnSurface stb 
) [virtual]
bool TwoTrackMinimumDistance::calculate ( const FreeTrajectoryState sta,
const FreeTrajectoryState stb 
) [virtual]

Implements ClosestApproachOnHelices.

Definition at line 73 of file TwoTrackMinimumDistance.cc.

References FreeTrajectoryState::parameters().

{
//  pair<GlobalPoint, GlobalPoint> ret  = theIniAlgo.points ( sta, stb );
  return calculate ( sta.parameters(), stb.parameters() );
}
bool TwoTrackMinimumDistance::calculate ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
) [virtual]

Definition at line 81 of file TwoTrackMinimumDistance.cc.

References GlobalTrajectoryParameters::charge(), MagneticField::inTesla(), GlobalTrajectoryParameters::magneticField(), GlobalTrajectoryParameters::position(), and z.

{
  bool isHelixA = (sta.magneticField().inTesla(sta.position()).z() != 0.)
    && sta.charge() != 0.;
  bool isHelixB = (stb.magneticField().inTesla(stb.position()).z() != 0.)
    && stb.charge() != 0.;
  if (! isHelixA && ! isHelixB) {
    status_ = pointsLineLine(sta, stb);
  } else if ( isHelixA && isHelixB ) {
    status_ = pointsHelixHelix(sta, stb);
  } else {
    status_ = pointsHelixLine(sta, stb);
  }
  return status_;
}
virtual TwoTrackMinimumDistance* TwoTrackMinimumDistance::clone ( void  ) const [inline, virtual]

Clone method

Implements ClosestApproachOnHelices.

Definition at line 54 of file TwoTrackMinimumDistance.h.

References TwoTrackMinimumDistance().

                                                  {
    return new TwoTrackMinimumDistance(* this);
  }
GlobalPoint TwoTrackMinimumDistance::crossingPoint ( ) const [virtual]

arithmetic mean of the two points of closest approach

Implements ClosestApproachOnHelices.

Definition at line 183 of file TwoTrackMinimumDistance.cc.

References timingPdfMaker::mean.

Referenced by VZeroFinder::checkTrackPair(), and InclusiveVertexFinder::nearTracks().

{
  return mean ( points_ );
}
float TwoTrackMinimumDistance::distance ( ) const [virtual]

distance between the two points of closest approach in 3D

Implements ClosestApproachOnHelices.

Definition at line 189 of file TwoTrackMinimumDistance.cc.

Referenced by VZeroFinder::checkTrackPair(), and InclusiveVertexFinder::nearTracks().

{
  return dist ( points_ );
}
double TwoTrackMinimumDistance::firstAngle ( ) const

Definition at line 20 of file TwoTrackMinimumDistance.cc.

References Exception.

Referenced by VZeroFinder::checkTrackPair(), and TSCBLBuilderNoMaterial::operator()().

{
  if (!status_)
    throw cms::Exception("TrackingTools/PatternTools","TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
  switch ( theCharge ) {
   case (hh): return theTTMDhh.firstAngle(); break;
   case (hl): return theTTMDhl.firstAngle(); break;
   case (ll): return theTTMDll.firstAngle(); break;
  }
  return 0;
}
pair< double, double > TwoTrackMinimumDistance::pathLength ( ) const

Definition at line 45 of file TwoTrackMinimumDistance.cc.

References Exception.

Referenced by TSCBLBuilderNoMaterial::operator()().

{
  if (!status_)
    throw cms::Exception("TrackingTools/PatternTools","TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
  switch ( theCharge ) {
   case (hh): return theTTMDhh.pathLength(); break;
   case (hl): return theTTMDhl.pathLength(); break;
   case (ll): return theTTMDll.pathLength(); break;
  }
  return std::pair<double,double>(0,0);
}
pair< GlobalPoint, GlobalPoint > TwoTrackMinimumDistance::points ( ) const [virtual]

Returns the two PCA on the trajectories.

Implements ClosestApproachOnHelices.

Definition at line 57 of file TwoTrackMinimumDistance.cc.

References Exception.

Referenced by CrossingPtBasedLinearizationPointFinder::getLinearizationPoint(), InclusiveVertexFinder::nearTracks(), TSCBLBuilderNoMaterial::operator()(), and CrossingPtBasedLinearizationPointFinder::useAllTracks().

{
  if (!status_)
    throw cms::Exception("TrackingTools/PatternTools","TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
  return points_;
}
bool TwoTrackMinimumDistance::pointsHelixHelix ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
) [private]

Definition at line 119 of file TwoTrackMinimumDistance.cc.

References GlobalTrajectoryParameters::charge(), alignCSCRings::e, f, mag2(), GlobalTrajectoryParameters::momentum(), GlobalTrajectoryParameters::position(), and z.

{
  if ( ( sta.position() - stb.position() ).mag2() < 1e-7f &&
       ( sta.momentum() - stb.momentum() ).mag2() < 1e-7f &&
       sta.charge()==stb.charge()
       )
  {
    edm::LogWarning ( "TwoTrackMinimumDistance") << "comparing track with itself!";
  };

  theCharge = hh;
  if ( theModus == FastMode )
  {
    // first we try directly - in FastMode only ...
    if ( !(theTTMDhh.calculate ( sta, stb, .0001 )) )
    {
      points_ = theTTMDhh.points();
      return true;
    };
  };

  // okay. did not work. so we use CAIR, and then TTMD again.
  bool cairStat = theIniAlgo.calculate ( sta, stb );
  
  if (!cairStat) { // yes. CAIR may fail.
    edm::LogWarning ( "TwoTrackMinimumDistance" ) << "Computation HelixHelix::CAIR failed.";
    if ( theModus == SlowMode ) { // we can still try ttmd here.
      if ( !(theTTMDhh.calculate ( sta, stb, .0001 )) ) {
        points_ = theTTMDhh.points();
        return true;
      }
    };
    // we can try with more sloppy settings
    if ( !(theTTMDhh.calculate ( sta, stb, .1 )) ) {
        points_ = theTTMDhh.points();
        return true;
      }
    return false;
    edm::LogWarning ( "TwoTrackMinimumDistance" ) << "TwoTrackMinimumDistanceHelixHelix failed";
  };

  pair<GlobalTrajectoryParameters, GlobalTrajectoryParameters >
        ini = theIniAlgo.trajectoryParameters();

  pair<GlobalPoint, GlobalPoint> inip ( ini.first.position(), 
      ini.second.position() );
  bool isFirstALine = ini.first.charge() == 0. || ini.first.magneticField().inTesla(ini.first.position()).z() == 0.;
  bool isSecondALine = ini.second.charge() == 0. || ini.second.magneticField().inTesla(ini.second.position()).z() == 0.;
  bool gotDist = false;
  if (!isFirstALine && !isSecondALine) gotDist = theTTMDhh.calculate ( ini.first, ini.second, .0001 );
  else if ( isFirstALine && isSecondALine) gotDist = theTTMDll.calculate ( ini.first, ini.second );
  else gotDist = theTTMDhl.calculate ( ini.first, ini.second, .0001 );
  if ( gotDist ) {
    points_ = inip;
  } else {
    points_ = theTTMDhh.points();
    // if we are still worse than CAIR, we use CAIR results.
    if ( dist ( points_ ) > dist ( inip ) ) points_ = inip;
  };
  return true;
}
bool TwoTrackMinimumDistance::pointsHelixLine ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
) [private]

Definition at line 109 of file TwoTrackMinimumDistance.cc.

{
  theCharge = hl;
  if (theTTMDhl.calculate(sta, stb, 0.000001)) return false;
  points_ = theTTMDhl.points();
  return true;
}
bool TwoTrackMinimumDistance::pointsLineLine ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
) [private]

Definition at line 99 of file TwoTrackMinimumDistance.cc.

{
  theCharge = ll;
  if (theTTMDll.calculate(sta, stb)) return false;
  points_ = theTTMDll.points();
  return true;
}
double TwoTrackMinimumDistance::secondAngle ( ) const

Definition at line 32 of file TwoTrackMinimumDistance.cc.

References Exception.

Referenced by VZeroFinder::checkTrackPair().

{
  if (!status_)
    throw cms::Exception("TrackingTools/PatternTools","TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
  switch ( theCharge ) {
   case (hh): return theTTMDhh.secondAngle(); break;
   case (hl): return theTTMDhl.secondAngle(); break;
   case (ll): return theTTMDll.secondAngle(); break;
  }
  return 0;
}
virtual bool TwoTrackMinimumDistance::status ( void  ) const [inline, virtual]

Implements ClosestApproachOnHelices.

Definition at line 36 of file TwoTrackMinimumDistance.h.

References status_.

{return status_;}

Member Data Documentation

Definition at line 71 of file TwoTrackMinimumDistance.h.

Definition at line 70 of file TwoTrackMinimumDistance.h.

Referenced by status(), and TwoTrackMinimumDistance().

Definition at line 65 of file TwoTrackMinimumDistance.h.

Definition at line 66 of file TwoTrackMinimumDistance.h.

Definition at line 64 of file TwoTrackMinimumDistance.h.

Referenced by TwoTrackMinimumDistance().

Definition at line 67 of file TwoTrackMinimumDistance.h.

Definition at line 69 of file TwoTrackMinimumDistance.h.

Definition at line 68 of file TwoTrackMinimumDistance.h.