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
TwoTrackMinimumDistance::~TwoTrackMinimumDistance ( )
inlineoverride

Definition at line 27 of file TwoTrackMinimumDistance.h.

References calculate().

27 {}

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 87 of file TwoTrackMinimumDistance.cc.

References FreeTrajectoryState::parameters().

87  {
88  // pair<GlobalPoint, GlobalPoint> ret = theIniAlgo.points ( sta, stb );
89  return calculate(sta.parameters(), stb.parameters());
90 }
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 92 of file TwoTrackMinimumDistance.cc.

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

92  {
93  bool isHelixA = (sta.magneticField().inTesla(sta.position()).z() != 0.) && sta.charge() != 0.;
94  bool isHelixB = (stb.magneticField().inTesla(stb.position()).z() != 0.) && stb.charge() != 0.;
95  if (!isHelixA && !isHelixB) {
96  status_ = pointsLineLine(sta, stb);
97  } else if (isHelixA && isHelixB) {
98  status_ = pointsHelixHelix(sta, stb);
99  } else {
100  status_ = pointsHelixLine(sta, stb);
101  }
102  return status_;
103 }
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 52 of file TwoTrackMinimumDistance.h.

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

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

arithmetic mean of the two points of closest approach

Implements ClosestApproachOnHelices.

Definition at line 187 of file TwoTrackMinimumDistance.cc.

References SiStripPI::mean.

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

187 { return mean(points_); }
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 189 of file TwoTrackMinimumDistance.cc.

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

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

Definition at line 18 of file TwoTrackMinimumDistance.cc.

References Exception, and AlignmentTrackSelector_cfi::theCharge.

Referenced by clone(), and TSCBLBuilderNoMaterial::operator()().

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

Definition at line 56 of file TwoTrackMinimumDistance.cc.

References Exception, and AlignmentTrackSelector_cfi::theCharge.

Referenced by clone(), and TSCBLBuilderNoMaterial::operator()().

56  {
57  if (!status_)
58  throw cms::Exception(
59  "TrackingTools/PatternTools",
60  "TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
61  switch (theCharge) {
62  case (hh):
63  return theTTMDhh.pathLength();
64  break;
65  case (hl):
66  return theTTMDhl.pathLength();
67  break;
68  case (ll):
69  return theTTMDll.pathLength();
70  break;
71  }
72  return std::pair<double, double>(0, 0);
73 }
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 75 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().

75  {
76  if (!status_)
77  throw cms::Exception(
78  "TrackingTools/PatternTools",
79  "TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
80  return points_;
81 }
std::pair< GlobalPoint, GlobalPoint > points_
bool TwoTrackMinimumDistance::pointsHelixHelix ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
)
private

Definition at line 123 of file TwoTrackMinimumDistance.cc.

References GlobalTrajectoryParameters::charge(), MillePedeFileConverter_cfg::e, f, mag2(), GlobalTrajectoryParameters::momentum(), GlobalTrajectoryParameters::position(), and AlignmentTrackSelector_cfi::theCharge.

124  {
125  if ((sta.position() - stb.position()).mag2() < 1e-7f && (sta.momentum() - stb.momentum()).mag2() < 1e-7f &&
126  sta.charge() == stb.charge()) {
127  edm::LogWarning("TwoTrackMinimumDistance") << "comparing track with itself!";
128  };
129 
130  theCharge = hh;
131  if (theModus == FastMode) {
132  // first we try directly - in FastMode only ...
133  if (!(theTTMDhh.calculate(sta, stb, .0001))) {
135  return true;
136  };
137  };
138 
139  // okay. did not work. so we use CAIR, and then TTMD again.
140  bool cairStat = theIniAlgo.calculate(sta, stb);
141 
142  if (!cairStat) { // yes. CAIR may fail.
143  edm::LogWarning("TwoTrackMinimumDistance") << "Computation HelixHelix::CAIR failed.";
144  if (theModus == SlowMode) { // we can still try ttmd here.
145  if (!(theTTMDhh.calculate(sta, stb, .0001))) {
147  return true;
148  }
149  };
150  // we can try with more sloppy settings
151  if (!(theTTMDhh.calculate(sta, stb, .1))) {
153  return true;
154  }
155  return false;
156  edm::LogWarning("TwoTrackMinimumDistance") << "TwoTrackMinimumDistanceHelixHelix failed";
157  };
158 
159  pair<GlobalTrajectoryParameters, GlobalTrajectoryParameters> ini = theIniAlgo.trajectoryParameters();
160 
161  pair<GlobalPoint, GlobalPoint> inip(ini.first.position(), ini.second.position());
162  bool isFirstALine = ini.first.charge() == 0. || ini.first.magneticField().inTesla(ini.first.position()).z() == 0.;
163  bool isSecondALine = ini.second.charge() == 0. || ini.second.magneticField().inTesla(ini.second.position()).z() == 0.;
164  bool gotDist = false;
165  if (!isFirstALine && !isSecondALine)
166  gotDist = theTTMDhh.calculate(ini.first, ini.second, .0001);
167  else if (isFirstALine && isSecondALine)
168  gotDist = theTTMDll.calculate(ini.first, ini.second);
169  else
170  gotDist = theTTMDhl.calculate(ini.first, ini.second, .0001);
171  if (gotDist) {
172  points_ = inip;
173  } else {
174  if (!isFirstALine && !isSecondALine)
176  else if (isFirstALine && isSecondALine)
178  else
180  // if we are still worse than CAIR, we use CAIR results.
181  if (dist(points_) > dist(inip))
182  points_ = inip;
183  };
184  return true;
185 }
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 114 of file TwoTrackMinimumDistance.cc.

References AlignmentTrackSelector_cfi::theCharge.

115  {
116  theCharge = hl;
117  if (theTTMDhl.calculate(sta, stb, 0.000001))
118  return false;
120  return true;
121 }
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 105 of file TwoTrackMinimumDistance.cc.

References AlignmentTrackSelector_cfi::theCharge.

106  {
107  theCharge = ll;
108  if (theTTMDll.calculate(sta, stb))
109  return false;
111  return true;
112 }
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 37 of file TwoTrackMinimumDistance.cc.

References Exception, and AlignmentTrackSelector_cfi::theCharge.

Referenced by clone().

37  {
38  if (!status_)
39  throw cms::Exception(
40  "TrackingTools/PatternTools",
41  "TwoTrackMinimumDistance::could not compute track crossing. Check status before calling this method!");
42  switch (theCharge) {
43  case (hh):
44  return theTTMDhh.secondAngle();
45  break;
46  case (hl):
47  return theTTMDhl.secondAngle();
48  break;
49  case (ll):
50  return theTTMDll.secondAngle();
51  break;
52  }
53  return 0;
54 }
TwoTrackMinimumDistanceHelixLine theTTMDhl
TwoTrackMinimumDistanceHelixHelix theTTMDhh
TwoTrackMinimumDistanceLineLine theTTMDll
bool TwoTrackMinimumDistance::status ( void  ) const
inlineoverridevirtual

Implements ClosestApproachOnHelices.

Definition at line 35 of file TwoTrackMinimumDistance.h.

References crossingPoint(), distance(), points(), and status_.

Member Data Documentation

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

Definition at line 67 of file TwoTrackMinimumDistance.h.

bool TwoTrackMinimumDistance::status_
private

Definition at line 66 of file TwoTrackMinimumDistance.h.

Referenced by status(), and TwoTrackMinimumDistance().

Charge TwoTrackMinimumDistance::theCharge
private

Definition at line 61 of file TwoTrackMinimumDistance.h.

ClosestApproachInRPhi TwoTrackMinimumDistance::theIniAlgo
private

Definition at line 62 of file TwoTrackMinimumDistance.h.

Mode TwoTrackMinimumDistance::theModus
private

Definition at line 60 of file TwoTrackMinimumDistance.h.

Referenced by TwoTrackMinimumDistance().

TwoTrackMinimumDistanceHelixHelix TwoTrackMinimumDistance::theTTMDhh
private

Definition at line 63 of file TwoTrackMinimumDistance.h.

TwoTrackMinimumDistanceHelixLine TwoTrackMinimumDistance::theTTMDhl
private

Definition at line 65 of file TwoTrackMinimumDistance.h.

TwoTrackMinimumDistanceLineLine TwoTrackMinimumDistance::theTTMDll
private

Definition at line 64 of file TwoTrackMinimumDistance.h.