CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
TwoTrackMinimumDistance Class Referencefinal

#include <TwoTrackMinimumDistance.h>

Inheritance diagram for TwoTrackMinimumDistance:
ClosestApproachOnHelices

Public Types

enum  Mode { FastMode =0, SlowMode =1 }
 

Public Member Functions

bool calculate (const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
 
bool calculate (const FreeTrajectoryState &sta, const FreeTrajectoryState &stb) override
 
virtual bool calculate (const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
 
TwoTrackMinimumDistanceclone () const override
 
GlobalPoint crossingPoint () const override
 
float distance () const override
 
double firstAngle () const
 
std::pair< double, double > pathLength () const
 
std::pair< GlobalPoint, GlobalPointpoints () const override
 
double secondAngle () const
 
bool status () const override
 
 TwoTrackMinimumDistance (const Mode m=FastMode)
 
 ~TwoTrackMinimumDistance () override
 
- 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, GlobalPointpoints_
 
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 funct::m, status_, and theModus.

Referenced by clone().

TwoTrackMinimumDistance::~TwoTrackMinimumDistance ( )
inlineoverride

Definition at line 26 of file TwoTrackMinimumDistance.h.

References calculate().

26 {}

Member Function Documentation

bool TwoTrackMinimumDistance::calculate ( const TrajectoryStateOnSurface sta,
const TrajectoryStateOnSurface stb 
)
overridevirtual
bool TwoTrackMinimumDistance::calculate ( const FreeTrajectoryState sta,
const FreeTrajectoryState stb 
)
overridevirtual

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 }
const GlobalTrajectoryParameters & parameters() const
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
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(), and GlobalTrajectoryParameters::position().

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 }
bool pointsHelixLine(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
bool pointsLineLine(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const MagneticField & magneticField() const
bool pointsHelixHelix(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
TwoTrackMinimumDistance* TwoTrackMinimumDistance::clone ( void  ) const
inlineoverridevirtual

Clone method

Implements ClosestApproachOnHelices.

Definition at line 55 of file TwoTrackMinimumDistance.h.

References firstAngle(), pathLength(), secondAngle(), and TwoTrackMinimumDistance().

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

arithmetic mean of the two points of closest approach

Implements ClosestApproachOnHelices.

Definition at line 185 of file TwoTrackMinimumDistance.cc.

References SiStripPI::mean.

Referenced by btagbtvdeep::TrackPairInfoBuilder::buildTrackPairInfo(), PFDisplacedVertexCandidateFinder::link(), TracksClusteringFromDisplacedSeed::nearTracks(), and status().

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

distance between the two points of closest approach in 3D

Implements ClosestApproachOnHelices.

Definition at line 191 of file TwoTrackMinimumDistance.cc.

Referenced by btagbtvdeep::TrackPairInfoBuilder::buildTrackPairInfo(), PFDisplacedVertexCandidateFinder::link(), TracksClusteringFromDisplacedSeed::nearTracks(), and status().

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

Definition at line 20 of file TwoTrackMinimumDistance.cc.

References Exception, and AlignmentTrackSelector_cfi::theCharge.

Referenced by clone(), 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 Exception, and AlignmentTrackSelector_cfi::theCharge.

Referenced by clone(), and 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
overridevirtual

Returns the two PCA on the trajectories.

Implements ClosestApproachOnHelices.

Definition at line 57 of file TwoTrackMinimumDistance.cc.

References Exception.

Referenced by btagbtvdeep::TrackPairInfoBuilder::buildTrackPairInfo(), BPHWriteSpecificDecay::fill(), CrossingPtBasedLinearizationPointFinder::getLinearizationPoint(), TracksClusteringFromDisplacedSeed::nearTracks(), TSCBLBuilderNoMaterial::operator()(), Onia2MuMuPAT::produce(), status(), 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(), MillePedeFileConverter_cfg::e, f, mag2(), GlobalTrajectoryParameters::momentum(), GlobalTrajectoryParameters::position(), and AlignmentTrackSelector_cfi::theCharge.

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 &)
TwoTrackMinimumDistanceHelixLine theTTMDhl
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
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
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.

References AlignmentTrackSelector_cfi::theCharge.

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.

References AlignmentTrackSelector_cfi::theCharge.

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 Exception, and AlignmentTrackSelector_cfi::theCharge.

Referenced by clone().

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
bool TwoTrackMinimumDistance::status ( void  ) const
inlineoverridevirtual

Implements ClosestApproachOnHelices.

Definition at line 37 of file TwoTrackMinimumDistance.h.

References crossingPoint(), distance(), points(), and 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
private

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
private

Definition at line 68 of file TwoTrackMinimumDistance.h.

TwoTrackMinimumDistanceHelixLine TwoTrackMinimumDistance::theTTMDhl
private

Definition at line 70 of file TwoTrackMinimumDistance.h.

TwoTrackMinimumDistanceLineLine TwoTrackMinimumDistance::theTTMDll
private

Definition at line 69 of file TwoTrackMinimumDistance.h.