CMS 3D CMS Logo

TwoTrackMinimumDistanceHelixHelix.cc
Go to the documentation of this file.
7 
8 using namespace std;
9 
11  : theH(nullptr), theG(nullptr), pointsUpdated(false), themaxjump(20), thesingjacI(1. / 0.1), themaxiter(4) {}
12 
14 
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 }
68 
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 }
101 
102 /*
103 bool TwoTrackMinimumDistanceHelixHelix::parallelTracks() const {
104  return (fabs(theH->momentum().x() - theG->momentum().x()) < .00000001 )
105  && (fabs(theH->momentum().y() - theG->momentum().y()) < .00000001 )
106  && (fabs(theH->momentum().z() - theG->momentum().z()) < .00000001 )
107  && (theH->charge()==theG->charge())
108  ;
109 }
110 */
111 
114  const float qual) {
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 }
147 
149  if (pointsUpdated)
150  return;
152  pointG = theG->position() + theg * tmpG;
154 
156  pointH = theH->position() + theh * tmpH;
158 
159  pointsUpdated = true;
160 }
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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
bool updateCoeffs(const GlobalPoint &, const GlobalPoint &)
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool calculate(const GlobalTrajectoryParameters &, const GlobalTrajectoryParameters &, const float qual=.001)
const MagneticField & magneticField() const
Log< level::Warning, false > LogWarning