CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TwoTrackMinimumDistanceHelixHelix Class Reference

#include <TwoTrackMinimumDistanceHelixHelix.h>

Public Member Functions

bool calculate (const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &, const float qual=.001)
 
double firstAngle () const
 
std::pair< double, double > pathLength () const
 
std::pair< GlobalPoint, GlobalPointpoints () const
 
double secondAngle () const
 
 TwoTrackMinimumDistanceHelixHelix ()
 
 ~TwoTrackMinimumDistanceHelixHelix ()
 

Private Member Functions

void finalPoints ()
 
bool oneIteration (double &, double &)
 
bool updateCoeffs (const GlobalPoint &, const GlobalPoint &)
 

Private Attributes

double pathG
 
double pathH
 
GlobalPoint pointG
 
GlobalPoint pointH
 
bool pointsUpdated
 
double thea
 
double theb
 
double thec1
 
double thec2
 
double thecospG
 
double thecospG0
 
double thecospH
 
double thecospH0
 
double thed1
 
double thed2
 
double thee1
 
double thee2
 
GlobalTrajectoryParameters const * theG
 
double theg
 
GlobalTrajectoryParameters const * theH
 
double theh
 
int themaxiter
 
double themaxjump
 
double thepG
 
double thepG0
 
double thepH
 
double thepH0
 
double thesingjacI
 
double thesinpG
 
double thesinpG0
 
double thesinpH
 
double thesinpH0
 
double thetanlambdaG
 
double thetanlambdaH
 

Detailed Description

This is a helper class for TwoTrackMinimumDistance. No user should need direct access to this class. It actually implements a Newton-Kantorowitsch method for finding the minimum distance between two tracks.

Definition at line 18 of file TwoTrackMinimumDistanceHelixHelix.h.

Constructor & Destructor Documentation

◆ TwoTrackMinimumDistanceHelixHelix()

TwoTrackMinimumDistanceHelixHelix::TwoTrackMinimumDistanceHelixHelix ( )

◆ ~TwoTrackMinimumDistanceHelixHelix()

TwoTrackMinimumDistanceHelixHelix::~TwoTrackMinimumDistanceHelixHelix ( )

Definition at line 13 of file TwoTrackMinimumDistanceHelixHelix.cc.

13 {}

Member Function Documentation

◆ calculate()

bool TwoTrackMinimumDistanceHelixHelix::calculate ( const GlobalTrajectoryParameters G,
const GlobalTrajectoryParameters H,
const float  qual = .001 
)

Definition at line 112 of file TwoTrackMinimumDistanceHelixHelix.cc.

References finalPoints(), cmssw_cycle_finder::G, data-class-funcs::H, edm::isNotFinite(), oneIteration(), pointsUpdated, GlobalTrajectoryParameters::position(), theG, theg, theH, theh, themaxiter, themaxjump, thepG, thepG0, thepH, thepH0, and updateCoeffs().

114  {
115  pointsUpdated = false;
116  theG = &G;
117  theH = &H;
118  bool retval = false;
119 
120  if (updateCoeffs(theG->position(), theH->position())) {
121  finalPoints();
122  return true;
123  }
124 
125  thepG = thepG0;
126  thepH = thepH0;
127 
128  int counter = 0;
129  double pH = 0;
130  double pG = 0;
131  do {
132  retval = oneIteration(pG, pH);
133  if (edm::isNotFinite(pG) || edm::isNotFinite(pH))
134  retval = true;
135  if (counter++ > themaxiter)
136  retval = true;
137  } while ((!retval) && (fabs(pG) > qual || fabs(pH) > qual));
138  if (fabs(theg * (thepG - thepG0)) > themaxjump)
139  retval = true;
140  if (fabs(theh * (thepH - thepH0)) > themaxjump)
141  retval = true;
142 
143  finalPoints();
144 
145  return retval;
146 }
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
bool updateCoeffs(const GlobalPoint &, const GlobalPoint &)

◆ finalPoints()

void TwoTrackMinimumDistanceHelixHelix::finalPoints ( )
private

Definition at line 148 of file TwoTrackMinimumDistanceHelixHelix.cc.

References funct::cos(), pathG, pathH, pointG, pointH, pointsUpdated, GlobalTrajectoryParameters::position(), funct::sin(), mathSSE::sqrt(), thecospG0, thecospH0, theG, theg, theH, theh, thepG, thepG0, thepH, thepH0, thesinpG0, thesinpH0, thetanlambdaG, and thetanlambdaH.

Referenced by calculate().

148  {
149  if (pointsUpdated)
150  return;
152  pointG = theG->position() + theg * tmpG;
154 
156  pointH = theH->position() + theh * tmpH;
158 
159  pointsUpdated = true;
160 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

◆ firstAngle()

double TwoTrackMinimumDistanceHelixHelix::firstAngle ( ) const
inline

Definition at line 31 of file TwoTrackMinimumDistanceHelixHelix.h.

References thepG.

◆ oneIteration()

bool TwoTrackMinimumDistanceHelixHelix::oneIteration ( double &  dH,
double &  dG 
)
private

Definition at line 69 of file TwoTrackMinimumDistanceHelixHelix.cc.

References funct::cos(), funct::sin(), thea, theb, thec1, thec2, thecospG, thecospH, thed1, thed2, thee1, thee2, theg, theh, thepG, thepH, thesingjacI, thesinpG, thesinpH, and testProducerWithPsetDescEmpty_cfi::z2.

Referenced by calculate().

69  {
70  thesinpH = sin(thepH);
71  thecospH = cos(thepH);
72  thesinpG = sin(thepG);
73  thecospG = cos(thepG);
74 
75  const double A11 = theh * (-thesinpH * (thea - theg * thesinpG) + thecospH * (theb + theg * thecospG) + thec1);
76  if (A11 < 0) {
77  return true;
78  };
79  const double A22 = -theg * (-thesinpG * (thea + theh * thesinpH) + thecospG * (theb - theh * thecospH) + thec2);
80  if (A22 < 0) {
81  return true;
82  };
83  const double A12 = theh * (-theg * thecospG * thecospH - theg * thesinpH * thesinpG + thed1);
84  const double A21 = -theg * (theh * thecospG * thecospH + theh * thesinpH * thesinpG + thed2);
85  const double detaI = 1. / (A11 * A22 - A12 * A21);
86  const double z1 = theh * (thecospH * (thea - theg * thesinpG) + thesinpH * (theb + theg * thecospG) + thec1 * thepH +
87  thed1 * thepG + thee1);
88  const double z2 = -theg * (thecospG * (thea + theh * thesinpH) + thesinpG * (theb - theh * thecospH) + thec2 * thepG +
89  thed2 * thepH + thee2);
90 
91  dH = (z1 * A22 - z2 * A12) * detaI;
92  dG = (z2 * A11 - z1 * A21) * detaI;
93  if (fabs(detaI) > thesingjacI) {
94  return true;
95  };
96 
97  thepH -= dH;
98  thepG -= dG;
99  return false;
100 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

◆ pathLength()

std::pair<double, double> TwoTrackMinimumDistanceHelixHelix::pathLength ( ) const
inline

Definition at line 29 of file TwoTrackMinimumDistanceHelixHelix.h.

References pathG, and pathH.

◆ points()

std::pair<GlobalPoint, GlobalPoint> TwoTrackMinimumDistanceHelixHelix::points ( ) const
inline

Definition at line 27 of file TwoTrackMinimumDistanceHelixHelix.h.

References pointG, and pointH.

27 { return std::pair<GlobalPoint, GlobalPoint>(pointG, pointH); }

◆ secondAngle()

double TwoTrackMinimumDistanceHelixHelix::secondAngle ( ) const
inline

Definition at line 32 of file TwoTrackMinimumDistanceHelixHelix.h.

References thepH.

◆ updateCoeffs()

bool TwoTrackMinimumDistanceHelixHelix::updateCoeffs ( const GlobalPoint gpH,
const GlobalPoint gpG 
)
private

Definition at line 15 of file TwoTrackMinimumDistanceHelixHelix.cc.

References GlobalTrajectoryParameters::charge(), MagneticField::inInverseGeV(), GlobalTrajectoryParameters::magneticField(), GlobalTrajectoryParameters::momentum(), PV3DBase< T, PVType, FrameType >::perp(), GlobalTrajectoryParameters::position(), thea, theb, thec1, thec2, thecospG0, thecospH0, thed1, thed2, thee1, thee2, theG, theg, theH, theh, thepG0, thepH0, thesinpG0, thesinpH0, thetanlambdaG, thetanlambdaH, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by calculate().

15  {
16  const double Bc2kH = theH->magneticField().inInverseGeV(gpH).z();
17  const double Bc2kG = theG->magneticField().inInverseGeV(gpG).z();
18  const double Ht = theH->momentum().perp();
19  const double Gt = theG->momentum().perp();
20  // thelambdaH=asin ( theH->momentum().z() / Hn );
21 
22  if (Ht == 0. || Gt == 0.) {
23  edm::LogWarning("TwoTrackMinimumDistanceHelixHelix") << "transverse momentum of input trajectory is zero.";
24  return true;
25  };
26 
27  if (theH->charge() == 0. || theG->charge() == 0.) {
28  edm::LogWarning("TwoTrackMinimumDistanceHelixHelix") << "charge of input track is zero.";
29  return true;
30  };
31 
32  if (Bc2kG == 0.) {
33  edm::LogWarning("TwoTrackMinimumDistanceHelixHelix") << "magnetic field at point " << gpG << " is zero.";
34  return true;
35  };
36 
37  if (Bc2kH == 0.) {
38  edm::LogWarning("TwoTrackMinimumDistanceHelixHelix") << "magnetic field at point " << gpH << " is zero.";
39  return true;
40  };
41 
42  theh = Ht / (theH->charge() * Bc2kH);
43  thesinpH0 = -theH->momentum().y() / (Ht);
44  thecospH0 = -theH->momentum().x() / (Ht);
45  thetanlambdaH = -theH->momentum().z() / (Ht);
46  thepH0 = atan2(thesinpH0, thecospH0);
47 
48  // thelambdaG=asin ( theG->momentum().z()/( Gn ) );
49 
50  theg = Gt / (theG->charge() * Bc2kG);
51  thesinpG0 = -theG->momentum().y() / (Gt);
52  thecospG0 = -theG->momentum().x() / (Gt);
53  thetanlambdaG = -theG->momentum().z() / (Gt);
54  thepG0 = atan2(thesinpG0, thecospG0);
55 
56  thea = theH->position().x() - theG->position().x() + theg * thesinpG0 - theh * thesinpH0;
57  theb = theH->position().y() - theG->position().y() - theg * thecospG0 + theh * thecospH0;
66  return false;
67 }
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:36
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
const MagneticField & magneticField() const
Log< level::Warning, false > LogWarning

Member Data Documentation

◆ pathG

double TwoTrackMinimumDistanceHelixHelix::pathG
private

Definition at line 57 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and pathLength().

◆ pathH

double TwoTrackMinimumDistanceHelixHelix::pathH
private

Definition at line 57 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and pathLength().

◆ pointG

GlobalPoint TwoTrackMinimumDistanceHelixHelix::pointG
private

Definition at line 56 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and points().

◆ pointH

GlobalPoint TwoTrackMinimumDistanceHelixHelix::pointH
private

Definition at line 56 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and points().

◆ pointsUpdated

bool TwoTrackMinimumDistanceHelixHelix::pointsUpdated
private

Definition at line 58 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate(), and finalPoints().

◆ thea

double TwoTrackMinimumDistanceHelixHelix::thea
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

◆ theb

double TwoTrackMinimumDistanceHelixHelix::theb
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

◆ thec1

double TwoTrackMinimumDistanceHelixHelix::thec1
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

◆ thec2

double TwoTrackMinimumDistanceHelixHelix::thec2
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

◆ thecospG

double TwoTrackMinimumDistanceHelixHelix::thecospG
private

Definition at line 55 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

◆ thecospG0

double TwoTrackMinimumDistanceHelixHelix::thecospG0
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

◆ thecospH

double TwoTrackMinimumDistanceHelixHelix::thecospH
private

Definition at line 55 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

◆ thecospH0

double TwoTrackMinimumDistanceHelixHelix::thecospH0
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

◆ thed1

double TwoTrackMinimumDistanceHelixHelix::thed1
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

◆ thed2

double TwoTrackMinimumDistanceHelixHelix::thed2
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

◆ thee1

double TwoTrackMinimumDistanceHelixHelix::thee1
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

◆ thee2

double TwoTrackMinimumDistanceHelixHelix::thee2
private

Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

◆ theG

GlobalTrajectoryParameters const * TwoTrackMinimumDistanceHelixHelix::theG
private

Definition at line 42 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate(), finalPoints(), and updateCoeffs().

◆ theg

double TwoTrackMinimumDistanceHelixHelix::theg
private

◆ theH

GlobalTrajectoryParameters const* TwoTrackMinimumDistanceHelixHelix::theH
private

Definition at line 42 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate(), finalPoints(), and updateCoeffs().

◆ theh

double TwoTrackMinimumDistanceHelixHelix::theh
private

◆ themaxiter

int TwoTrackMinimumDistanceHelixHelix::themaxiter
private

Definition at line 61 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate().

◆ themaxjump

double TwoTrackMinimumDistanceHelixHelix::themaxjump
private

Definition at line 60 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate().

◆ thepG

double TwoTrackMinimumDistanceHelixHelix::thepG
private

◆ thepG0

double TwoTrackMinimumDistanceHelixHelix::thepG0
private

Definition at line 49 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate(), finalPoints(), and updateCoeffs().

◆ thepH

double TwoTrackMinimumDistanceHelixHelix::thepH
private

◆ thepH0

double TwoTrackMinimumDistanceHelixHelix::thepH0
private

Definition at line 49 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate(), finalPoints(), and updateCoeffs().

◆ thesingjacI

double TwoTrackMinimumDistanceHelixHelix::thesingjacI
private

Definition at line 60 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

◆ thesinpG

double TwoTrackMinimumDistanceHelixHelix::thesinpG
private

Definition at line 54 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

◆ thesinpG0

double TwoTrackMinimumDistanceHelixHelix::thesinpG0
private

Definition at line 47 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

◆ thesinpH

double TwoTrackMinimumDistanceHelixHelix::thesinpH
private

Definition at line 54 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

◆ thesinpH0

double TwoTrackMinimumDistanceHelixHelix::thesinpH0
private

Definition at line 48 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

◆ thetanlambdaG

double TwoTrackMinimumDistanceHelixHelix::thetanlambdaG
private

Definition at line 46 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

◆ thetanlambdaH

double TwoTrackMinimumDistanceHelixHelix::thetanlambdaH
private

Definition at line 46 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().