CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
TwoTrackMinimumDistance Class Reference

#include <TwoTrackMinimumDistance.h>

Inheritance diagram for TwoTrackMinimumDistance:
ClosestApproachOnHelices

Public Types

enum  Mode { FastMode =0, SlowMode =1 }
 

Public Member Functions

virtual bool calculate (const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
 
virtual bool calculate (const FreeTrajectoryState &sta, const FreeTrajectoryState &stb)
 
virtual bool calculate (const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &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)
 
 ~TwoTrackMinimumDistance ()
 
- Public Member Functions inherited from ClosestApproachOnHelices
 ClosestApproachOnHelices ()
 
virtual ~ClosestApproachOnHelices ()
 

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

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().

TwoTrackMinimumDistance::~TwoTrackMinimumDistance ( )
inline

Definition at line 26 of file TwoTrackMinimumDistance.h.

26 {}

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().

75 {
76 // pair<GlobalPoint, GlobalPoint> ret = theIniAlgo.points ( sta, stb );
77  return calculate ( sta.parameters(), stb.parameters() );
78 }
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
const GlobalTrajectoryParameters & parameters() const
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 detailsBasic3DVector::z.

83 {
84  bool isHelixA = (sta.magneticField().inTesla(sta.position()).z() != 0.)
85  && sta.charge() != 0.;
86  bool isHelixB = (stb.magneticField().inTesla(stb.position()).z() != 0.)
87  && stb.charge() != 0.;
88  if (! isHelixA && ! isHelixB) {
89  status_ = pointsLineLine(sta, stb);
90  } else if ( isHelixA && isHelixB ) {
91  status_ = pointsHelixHelix(sta, stb);
92  } else {
93  status_ = pointsHelixLine(sta, stb);
94  }
95  return status_;
96 }
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
float float float z
bool pointsHelixLine(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
bool pointsLineLine(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
const MagneticField & magneticField() const
bool pointsHelixHelix(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
virtual TwoTrackMinimumDistance* TwoTrackMinimumDistance::clone ( void  ) const
inlinevirtual

Clone method

Implements ClosestApproachOnHelices.

Definition at line 55 of file TwoTrackMinimumDistance.h.

References TwoTrackMinimumDistance().

55  {
56  return new TwoTrackMinimumDistance(* this);
57  }
TwoTrackMinimumDistance(const Mode m=FastMode)
GlobalPoint TwoTrackMinimumDistance::crossingPoint ( ) const
virtual

arithmetic mean of the two points of closest approach

Implements ClosestApproachOnHelices.

Definition at line 185 of file TwoTrackMinimumDistance.cc.

References timingPdfMaker::mean.

Referenced by VZeroFinder::checkTrackPair(), PFDisplacedVertexCandidateFinder::link(), and TracksClusteringFromDisplacedSeed::nearTracks().

186 {
187  return mean ( points_ );
188 }
std::pair< GlobalPoint, GlobalPoint > points_
float TwoTrackMinimumDistance::distance ( ) const
virtual

distance between the two points of closest approach in 3D

Implements ClosestApproachOnHelices.

Definition at line 191 of file TwoTrackMinimumDistance.cc.

Referenced by VZeroFinder::checkTrackPair(), PFDisplacedVertexCandidateFinder::link(), and TracksClusteringFromDisplacedSeed::nearTracks().

192 {
193  return dist ( points_ );
194 }
std::pair< GlobalPoint, GlobalPoint > points_
double TwoTrackMinimumDistance::firstAngle ( ) const

Definition at line 20 of file TwoTrackMinimumDistance.cc.

References edm::hlt::Exception.

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

21 {
22  if (!status_)
23  throw cms::Exception("TrackingTools/PatternTools","TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
24  switch ( theCharge ) {
25  case (hh): return theTTMDhh.firstAngle(); break;
26  case (hl): return theTTMDhl.firstAngle(); break;
27  case (ll): return theTTMDll.firstAngle(); break;
28  }
29  return 0;
30 }
TwoTrackMinimumDistanceHelixLine theTTMDhl
TwoTrackMinimumDistanceHelixHelix theTTMDhh
TwoTrackMinimumDistanceLineLine theTTMDll
pair< double, double > TwoTrackMinimumDistance::pathLength ( ) const

Definition at line 45 of file TwoTrackMinimumDistance.cc.

References edm::hlt::Exception.

Referenced by TSCBLBuilderNoMaterial::operator()().

46 {
47  if (!status_)
48  throw cms::Exception("TrackingTools/PatternTools","TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
49  switch ( theCharge ) {
50  case (hh): return theTTMDhh.pathLength(); break;
51  case (hl): return theTTMDhl.pathLength(); break;
52  case (ll): return theTTMDll.pathLength(); break;
53  }
54  return std::pair<double,double>(0,0);
55 }
std::pair< double, double > pathLength() const
std::pair< double, double > pathLength() const
TwoTrackMinimumDistanceHelixLine theTTMDhl
TwoTrackMinimumDistanceHelixHelix theTTMDhh
std::pair< double, double > pathLength() const
TwoTrackMinimumDistanceLineLine theTTMDll
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 edm::hlt::Exception.

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

58 {
59  if (!status_)
60  throw cms::Exception("TrackingTools/PatternTools","TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
61  return points_;
62 }
std::pair< GlobalPoint, GlobalPoint > 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 detailsBasic3DVector::z.

121 {
122  if ( ( sta.position() - stb.position() ).mag2() < 1e-7f &&
123  ( sta.momentum() - stb.momentum() ).mag2() < 1e-7f &&
124  sta.charge()==stb.charge()
125  )
126  {
127  edm::LogWarning ( "TwoTrackMinimumDistance") << "comparing track with itself!";
128  };
129 
130  theCharge = hh;
131  if ( theModus == FastMode )
132  {
133  // first we try directly - in FastMode only ...
134  if ( !(theTTMDhh.calculate ( sta, stb, .0001 )) )
135  {
137  return true;
138  };
139  };
140 
141  // okay. did not work. so we use CAIR, and then TTMD again.
142  bool cairStat = theIniAlgo.calculate ( sta, stb );
143 
144  if (!cairStat) { // yes. CAIR may fail.
145  edm::LogWarning ( "TwoTrackMinimumDistance" ) << "Computation HelixHelix::CAIR failed.";
146  if ( theModus == SlowMode ) { // we can still try ttmd here.
147  if ( !(theTTMDhh.calculate ( sta, stb, .0001 )) ) {
149  return true;
150  }
151  };
152  // we can try with more sloppy settings
153  if ( !(theTTMDhh.calculate ( sta, stb, .1 )) ) {
155  return true;
156  }
157  return false;
158  edm::LogWarning ( "TwoTrackMinimumDistance" ) << "TwoTrackMinimumDistanceHelixHelix failed";
159  };
160 
161  pair<GlobalTrajectoryParameters, GlobalTrajectoryParameters >
163 
164  pair<GlobalPoint, GlobalPoint> inip ( ini.first.position(),
165  ini.second.position() );
166  bool isFirstALine = ini.first.charge() == 0. || ini.first.magneticField().inTesla(ini.first.position()).z() == 0.;
167  bool isSecondALine = ini.second.charge() == 0. || ini.second.magneticField().inTesla(ini.second.position()).z() == 0.;
168  bool gotDist = false;
169  if (!isFirstALine && !isSecondALine) gotDist = theTTMDhh.calculate ( ini.first, ini.second, .0001 );
170  else if ( isFirstALine && isSecondALine) gotDist = theTTMDll.calculate ( ini.first, ini.second );
171  else gotDist = theTTMDhl.calculate ( ini.first, ini.second, .0001 );
172  if ( gotDist ) {
173  points_ = inip;
174  } else {
175  if (!isFirstALine && !isSecondALine) points_ = theTTMDhh.points ();
176  else if ( isFirstALine && isSecondALine) points_ = theTTMDll.points ();
177  else points_ = theTTMDhl.points ();
178  // if we are still worse than CAIR, we use CAIR results.
179  if ( dist ( points_ ) > dist ( inip ) ) points_ = inip;
180  };
181  return true;
182 }
std::pair< GlobalTrajectoryParameters, GlobalTrajectoryParameters > trajectoryParameters() const
std::pair< GlobalPoint, GlobalPoint > points() const
std::pair< GlobalPoint, GlobalPoint > points_
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &)
float float float z
TwoTrackMinimumDistanceHelixLine theTTMDhl
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &, const float qual=.001)
double f[11][100]
TwoTrackMinimumDistanceHelixHelix theTTMDhh
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
ClosestApproachInRPhi theIniAlgo
std::pair< GlobalPoint, GlobalPoint > points() const
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &, const float qual=.0001)
std::pair< GlobalPoint, GlobalPoint > points() const
TwoTrackMinimumDistanceLineLine theTTMDll
bool TwoTrackMinimumDistance::pointsHelixLine ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
)
private

Definition at line 109 of file TwoTrackMinimumDistance.cc.

111 {
112  theCharge = hl;
113  if (theTTMDhl.calculate(sta, stb, 0.000001)) return false;
115  return true;
116 }
std::pair< GlobalPoint, GlobalPoint > points_
TwoTrackMinimumDistanceHelixLine theTTMDhl
std::pair< GlobalPoint, GlobalPoint > points() const
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &, const float qual=.0001)
bool TwoTrackMinimumDistance::pointsLineLine ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
)
private

Definition at line 99 of file TwoTrackMinimumDistance.cc.

101 {
102  theCharge = ll;
103  if (theTTMDll.calculate(sta, stb)) return false;
105  return true;
106 }
std::pair< GlobalPoint, GlobalPoint > points() const
std::pair< GlobalPoint, GlobalPoint > points_
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &)
TwoTrackMinimumDistanceLineLine theTTMDll
double TwoTrackMinimumDistance::secondAngle ( ) const

Definition at line 32 of file TwoTrackMinimumDistance.cc.

References edm::hlt::Exception.

Referenced by VZeroFinder::checkTrackPair().

33 {
34  if (!status_)
35  throw cms::Exception("TrackingTools/PatternTools","TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
36  switch ( theCharge ) {
37  case (hh): return theTTMDhh.secondAngle(); break;
38  case (hl): return theTTMDhl.secondAngle(); break;
39  case (ll): return theTTMDll.secondAngle(); break;
40  }
41  return 0;
42 }
TwoTrackMinimumDistanceHelixLine theTTMDhl
TwoTrackMinimumDistanceHelixHelix theTTMDhh
TwoTrackMinimumDistanceLineLine theTTMDll
virtual bool TwoTrackMinimumDistance::status ( void  ) const
inlinevirtual

Implements ClosestApproachOnHelices.

Definition at line 37 of file TwoTrackMinimumDistance.h.

References status_.

Member Data Documentation

std::pair<GlobalPoint, GlobalPoint> TwoTrackMinimumDistance::points_
private

Definition at line 72 of file TwoTrackMinimumDistance.h.

bool TwoTrackMinimumDistance::status_
private

Definition at line 71 of file TwoTrackMinimumDistance.h.

Referenced by status(), and TwoTrackMinimumDistance().

Charge TwoTrackMinimumDistance::theCharge
mutableprivate

Definition at line 66 of file TwoTrackMinimumDistance.h.

ClosestApproachInRPhi TwoTrackMinimumDistance::theIniAlgo
private

Definition at line 67 of file TwoTrackMinimumDistance.h.

Mode TwoTrackMinimumDistance::theModus
private

Definition at line 65 of file TwoTrackMinimumDistance.h.

Referenced by TwoTrackMinimumDistance().

TwoTrackMinimumDistanceHelixHelix TwoTrackMinimumDistance::theTTMDhh
mutableprivate

Definition at line 68 of file TwoTrackMinimumDistance.h.

TwoTrackMinimumDistanceHelixLine TwoTrackMinimumDistance::theTTMDhl
mutableprivate

Definition at line 70 of file TwoTrackMinimumDistance.h.

TwoTrackMinimumDistanceLineLine TwoTrackMinimumDistance::theTTMDll
mutableprivate

Definition at line 69 of file TwoTrackMinimumDistance.h.