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 FreeTrajectoryState &sta, const FreeTrajectoryState &stb) override
 
virtual bool calculate (const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
 
bool calculate (const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
 
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 20 of file TwoTrackMinimumDistance.h.

Member Enumeration Documentation

◆ Charge

Enumerator
hh 
hl 
ll 

Definition at line 60 of file TwoTrackMinimumDistance.h.

60 { hh, hl, ll };

◆ Mode

Enumerator
FastMode 
SlowMode 

Definition at line 22 of file TwoTrackMinimumDistance.h.

22 { FastMode = 0, SlowMode = 1 };

Constructor & Destructor Documentation

◆ TwoTrackMinimumDistance()

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

Definition at line 24 of file TwoTrackMinimumDistance.h.

24  {
25  theModus = m;
26  status_ = false;
27  };

References visualization-live-secondInstance_cfg::m, status_, and theModus.

Referenced by clone().

◆ ~TwoTrackMinimumDistance()

TwoTrackMinimumDistance::~TwoTrackMinimumDistance ( )
inlineoverride

Definition at line 28 of file TwoTrackMinimumDistance.h.

28 {}

Member Function Documentation

◆ calculate() [1/3]

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

Implements ClosestApproachOnHelices.

Definition at line 87 of file TwoTrackMinimumDistance.cc.

87  {
88  // pair<GlobalPoint, GlobalPoint> ret = theIniAlgo.points ( sta, stb );
89  return calculate(sta.parameters(), stb.parameters());
90 }

References FreeTrajectoryState::parameters().

◆ calculate() [2/3]

bool TwoTrackMinimumDistance::calculate ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
)
virtual

Definition at line 92 of file TwoTrackMinimumDistance.cc.

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 }

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

◆ calculate() [3/3]

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

◆ clone()

TwoTrackMinimumDistance* TwoTrackMinimumDistance::clone ( void  ) const
inlineoverridevirtual

Clone method

Implements ClosestApproachOnHelices.

Definition at line 53 of file TwoTrackMinimumDistance.h.

53 { return new TwoTrackMinimumDistance(*this); }

References TwoTrackMinimumDistance().

◆ crossingPoint()

GlobalPoint TwoTrackMinimumDistance::crossingPoint ( ) const
overridevirtual

arithmetic mean of the two points of closest approach

Implements ClosestApproachOnHelices.

Definition at line 187 of file TwoTrackMinimumDistance.cc.

187 { return mean(points_); }

References SiStripPI::mean.

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

◆ distance()

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.

189 { return dist(points_); }

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

◆ firstAngle()

double TwoTrackMinimumDistance::firstAngle ( ) const

Definition at line 18 of file TwoTrackMinimumDistance.cc.

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 }

References Exception, hh, and AlignmentTrackSelector_cfi::theCharge.

Referenced by TSCBLBuilderNoMaterial::operator()().

◆ pathLength()

pair< double, double > TwoTrackMinimumDistance::pathLength ( ) const

Definition at line 56 of file TwoTrackMinimumDistance.cc.

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 }

References Exception, hh, and AlignmentTrackSelector_cfi::theCharge.

Referenced by TSCBLBuilderNoMaterial::operator()().

◆ points()

pair< GlobalPoint, GlobalPoint > TwoTrackMinimumDistance::points ( ) const
overridevirtual

Returns the two PCA on the trajectories.

Implements ClosestApproachOnHelices.

Definition at line 75 of file TwoTrackMinimumDistance.cc.

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 }

References Exception.

Referenced by btagbtvdeep::TrackPairInfoBuilder::buildTrackPairInfo(), BPHWriteSpecificDecay::fill(), CrossingPtBasedLinearizationPointFinder::getLinearizationPoint(), TracksClusteringFromDisplacedSeed::nearTracks(), TSCBLBuilderNoMaterial::operator()(), Onia2MuMuPAT::produce(), and CrossingPtBasedLinearizationPointFinder::useAllTracks().

◆ pointsHelixHelix()

bool TwoTrackMinimumDistance::pointsHelixHelix ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
)
private

Definition at line 123 of file TwoTrackMinimumDistance.cc.

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 }

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

◆ pointsHelixLine()

bool TwoTrackMinimumDistance::pointsHelixLine ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
)
private

Definition at line 114 of file TwoTrackMinimumDistance.cc.

115  {
116  theCharge = hl;
117  if (theTTMDhl.calculate(sta, stb, 0.000001))
118  return false;
120  return true;
121 }

References AlignmentTrackSelector_cfi::theCharge.

◆ pointsLineLine()

bool TwoTrackMinimumDistance::pointsLineLine ( const GlobalTrajectoryParameters sta,
const GlobalTrajectoryParameters stb 
)
private

Definition at line 105 of file TwoTrackMinimumDistance.cc.

106  {
107  theCharge = ll;
108  if (theTTMDll.calculate(sta, stb))
109  return false;
111  return true;
112 }

References AlignmentTrackSelector_cfi::theCharge.

◆ secondAngle()

double TwoTrackMinimumDistance::secondAngle ( ) const

Definition at line 37 of file TwoTrackMinimumDistance.cc.

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 }

References Exception, hh, and AlignmentTrackSelector_cfi::theCharge.

◆ status()

bool TwoTrackMinimumDistance::status ( void  ) const
inlineoverridevirtual

Implements ClosestApproachOnHelices.

Definition at line 36 of file TwoTrackMinimumDistance.h.

36 { return status_; }

References status_.

Member Data Documentation

◆ points_

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

Definition at line 68 of file TwoTrackMinimumDistance.h.

◆ status_

bool TwoTrackMinimumDistance::status_
private

Definition at line 67 of file TwoTrackMinimumDistance.h.

Referenced by status(), and TwoTrackMinimumDistance().

◆ theCharge

Charge TwoTrackMinimumDistance::theCharge
private

Definition at line 62 of file TwoTrackMinimumDistance.h.

◆ theIniAlgo

ClosestApproachInRPhi TwoTrackMinimumDistance::theIniAlgo
private

Definition at line 63 of file TwoTrackMinimumDistance.h.

◆ theModus

Mode TwoTrackMinimumDistance::theModus
private

Definition at line 61 of file TwoTrackMinimumDistance.h.

Referenced by TwoTrackMinimumDistance().

◆ theTTMDhh

TwoTrackMinimumDistanceHelixHelix TwoTrackMinimumDistance::theTTMDhh
private

Definition at line 64 of file TwoTrackMinimumDistance.h.

◆ theTTMDhl

TwoTrackMinimumDistanceHelixLine TwoTrackMinimumDistance::theTTMDhl
private

Definition at line 66 of file TwoTrackMinimumDistance.h.

◆ theTTMDll

TwoTrackMinimumDistanceLineLine TwoTrackMinimumDistance::theTTMDll
private

Definition at line 65 of file TwoTrackMinimumDistance.h.

TwoTrackMinimumDistance::points_
std::pair< GlobalPoint, GlobalPoint > points_
Definition: TwoTrackMinimumDistance.h:68
TwoTrackMinimumDistanceHelixHelix::firstAngle
double firstAngle() const
Definition: TwoTrackMinimumDistanceHelixHelix.h:31
TwoTrackMinimumDistanceLineLine::pathLength
std::pair< double, double > pathLength() const
Definition: TwoTrackMinimumDistanceLineLine.cc:63
MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
TwoTrackMinimumDistanceHelixHelix::pathLength
std::pair< double, double > pathLength() const
Definition: TwoTrackMinimumDistanceHelixHelix.h:29
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
TwoTrackMinimumDistance::FastMode
Definition: TwoTrackMinimumDistance.h:22
TwoTrackMinimumDistance::pointsHelixHelix
bool pointsHelixHelix(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
Definition: TwoTrackMinimumDistance.cc:123
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
GlobalTrajectoryParameters::position
GlobalPoint position() const
Definition: GlobalTrajectoryParameters.h:60
TwoTrackMinimumDistance::ll
Definition: TwoTrackMinimumDistance.h:60
TwoTrackMinimumDistance::theTTMDll
TwoTrackMinimumDistanceLineLine theTTMDll
Definition: TwoTrackMinimumDistance.h:65
TwoTrackMinimumDistanceHelixLine::firstAngle
double firstAngle() const
Definition: TwoTrackMinimumDistanceHelixLine.cc:139
GlobalTrajectoryParameters::charge
TrackCharge charge() const
Definition: GlobalTrajectoryParameters.h:72
TwoTrackMinimumDistance::SlowMode
Definition: TwoTrackMinimumDistance.h:22
TwoTrackMinimumDistance::theModus
Mode theModus
Definition: TwoTrackMinimumDistance.h:61
TwoTrackMinimumDistance::theTTMDhl
TwoTrackMinimumDistanceHelixLine theTTMDhl
Definition: TwoTrackMinimumDistance.h:66
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
TwoTrackMinimumDistance::pointsHelixLine
bool pointsHelixLine(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
Definition: TwoTrackMinimumDistance.cc:114
TwoTrackMinimumDistance::calculate
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
Definition: TwoTrackMinimumDistance.cc:83
TwoTrackMinimumDistance::hl
Definition: TwoTrackMinimumDistance.h:60
ClosestApproachInRPhi::calculate
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
Definition: ClosestApproachInRPhi.cc:8
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
DDAxes::z
TwoTrackMinimumDistance::status_
bool status_
Definition: TwoTrackMinimumDistance.h:67
TwoTrackMinimumDistanceHelixLine::points
std::pair< GlobalPoint, GlobalPoint > points() const
Definition: TwoTrackMinimumDistanceHelixLine.cc:153
GlobalTrajectoryParameters::momentum
GlobalVector momentum() const
Definition: GlobalTrajectoryParameters.h:65
TwoTrackMinimumDistanceHelixHelix::secondAngle
double secondAngle() const
Definition: TwoTrackMinimumDistanceHelixHelix.h:32
FreeTrajectoryState::parameters
const GlobalTrajectoryParameters & parameters() const
Definition: FreeTrajectoryState.h:79
TwoTrackMinimumDistance::pointsLineLine
bool pointsLineLine(const GlobalTrajectoryParameters &sta, const GlobalTrajectoryParameters &stb)
Definition: TwoTrackMinimumDistance.cc:105
mag2
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
Definition: Basic3DVectorLD.h:124
TwoTrackMinimumDistance::TwoTrackMinimumDistance
TwoTrackMinimumDistance(const Mode m=FastMode)
Definition: TwoTrackMinimumDistance.h:24
TwoTrackMinimumDistanceHelixLine::pathLength
std::pair< double, double > pathLength() const
Definition: TwoTrackMinimumDistanceHelixLine.cc:160
TwoTrackMinimumDistanceHelixHelix::calculate
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &, const float qual=.001)
Definition: TwoTrackMinimumDistanceHelixHelix.cc:112
TwoTrackMinimumDistance::hh
Definition: TwoTrackMinimumDistance.h:60
TwoTrackMinimumDistance::theTTMDhh
TwoTrackMinimumDistanceHelixHelix theTTMDhh
Definition: TwoTrackMinimumDistance.h:64
TwoTrackMinimumDistanceHelixHelix::points
std::pair< GlobalPoint, GlobalPoint > points() const
Definition: TwoTrackMinimumDistanceHelixHelix.h:27
ClosestApproachInRPhi::trajectoryParameters
std::pair< GlobalTrajectoryParameters, GlobalTrajectoryParameters > trajectoryParameters() const
Definition: ClosestApproachInRPhi.cc:121
Exception
Definition: hltDiff.cc:245
TwoTrackMinimumDistance::theIniAlgo
ClosestApproachInRPhi theIniAlgo
Definition: TwoTrackMinimumDistance.h:63
TwoTrackMinimumDistanceLineLine::calculate
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &)
Definition: TwoTrackMinimumDistanceLineLine.cc:7
GlobalTrajectoryParameters::magneticField
const MagneticField & magneticField() const
Definition: GlobalTrajectoryParameters.h:106
TwoTrackMinimumDistanceLineLine::firstAngle
double firstAngle() const
Definition: TwoTrackMinimumDistanceLineLine.h:34
TrajectoryStateOnSurface::globalParameters
const GlobalTrajectoryParameters & globalParameters() const
Definition: TrajectoryStateOnSurface.h:64
TwoTrackMinimumDistanceLineLine::points
std::pair< GlobalPoint, GlobalPoint > points() const
Definition: TwoTrackMinimumDistanceLineLine.cc:59
TwoTrackMinimumDistance::theCharge
Charge theCharge
Definition: TwoTrackMinimumDistance.h:62
TwoTrackMinimumDistanceLineLine::secondAngle
double secondAngle() const
Definition: TwoTrackMinimumDistanceLineLine.h:35
TwoTrackMinimumDistanceHelixLine::calculate
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &, const float qual=.0001)
Definition: TwoTrackMinimumDistanceHelixLine.cc:105
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
TwoTrackMinimumDistanceHelixLine::secondAngle
double secondAngle() const
Definition: TwoTrackMinimumDistanceHelixLine.cc:146