#include <TrackingTools/PatternTools/interface/TwoTrackMinimumDistanceHelixHelix.h>
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.
TwoTrackMinimumDistanceHelixHelix::TwoTrackMinimumDistanceHelixHelix | ( | ) |
Definition at line 33 of file TwoTrackMinimumDistanceHelixHelix.cc.
00033 : 00034 theH(), theG(), pointsUpdated(false), themaxjump(20),thesingjac(.1), themaxiter(4) 00035 { }
TwoTrackMinimumDistanceHelixHelix::~TwoTrackMinimumDistanceHelixHelix | ( | ) |
bool TwoTrackMinimumDistanceHelixHelix::calculate | ( | const GlobalTrajectoryParameters & | G, | |
const GlobalTrajectoryParameters & | H, | |||
const float | qual = .001 | |||
) |
Definition at line 152 of file TwoTrackMinimumDistanceHelixHelix.cc.
References counter(), oneIteration(), pointsUpdated, GlobalTrajectoryParameters::position(), theG, theg, theH, theh, themaxiter, themaxjump, thepG, thepG0, thepH, thepH0, and updateCoeffs().
Referenced by TwoTrackMinimumDistance::pointsHelixHelix().
00155 { 00156 pointsUpdated = false; 00157 theG= (GlobalTrajectoryParameters *) &G; 00158 theH= (GlobalTrajectoryParameters *) &H; 00159 bool retval=false; 00160 00161 if ( updateCoeffs ( theG->position(), theH->position() ) ) 00162 { 00163 return true; 00164 }; 00165 00166 thepG = thepG0; 00167 thepH = thepH0; 00168 00169 int counter=0; 00170 double pH=0; double pG=0; 00171 do { 00172 retval=oneIteration ( pG, pH ); 00173 if ( !finite(pG) || !finite(pH) ) retval=true; 00174 if ( counter++>themaxiter ) retval=true; 00175 } while ( (!retval) && ( fabs(pG) > qual || fabs(pH) > qual )); 00176 if ( fabs ( theg * ( thepG - thepG0 ) ) > themaxjump ) retval=true; 00177 if ( fabs ( theh * ( thepH - thepH0 ) ) > themaxjump ) retval=true; 00178 return retval; 00179 }
void TwoTrackMinimumDistanceHelixHelix::finalPoints | ( | ) | const [private] |
Definition at line 191 of file TwoTrackMinimumDistanceHelixHelix.cc.
References funct::cos(), pathG, pathH, pointG, pointH, pointsUpdated, GlobalTrajectoryParameters::position(), funct::sin(), funct::sqrt(), thecospG0, thecospH0, theG, theg, theH, theh, thepG, thepG0, thepH, thepH0, thesinpG0, thesinpH0, thetanlambdaG, thetanlambdaH, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
Referenced by pathLength(), and points().
00192 { 00193 pointG = GlobalPoint ( 00194 theG->position().x() + theg * ( sin ( thepG) - thesinpG0) , 00195 theG->position().y() + theg * ( - cos ( thepG) + thecospG0 ), 00196 theG->position().z() + theg * ( thetanlambdaG * ( thepG- thepG0 )) 00197 ); 00198 pathG = ( thepG- thepG0 ) * (theg*sqrt(1+thetanlambdaG*thetanlambdaG)) ; 00199 00200 pointH = GlobalPoint ( 00201 theH->position().x() + theh * ( sin ( thepH) - thesinpH0 ), 00202 theH->position().y() + theh * ( - cos ( thepH) + thecospH0 ), 00203 theH->position().z() + theh * ( thetanlambdaH * ( thepH- thepH0 )) 00204 ); 00205 pathH = ( thepH- thepH0 ) * (theh*sqrt(1+thetanlambdaH*thetanlambdaH)) ; 00206 pointsUpdated = true; 00207 }
double TwoTrackMinimumDistanceHelixHelix::firstAngle | ( | ) | const |
Definition at line 181 of file TwoTrackMinimumDistanceHelixHelix.cc.
References thepG.
Referenced by TwoTrackMinimumDistance::firstAngle().
00182 { 00183 return thepG; 00184 }
bool TwoTrackMinimumDistanceHelixHelix::oneIteration | ( | double & | dH, | |
double & | dG | |||
) | const [private] |
Definition at line 108 of file TwoTrackMinimumDistanceHelixHelix.cc.
References A11, A12, A21, A22, funct::cos(), funct::sin(), thea, theb, thec1, thec2, thecospG, thecospH, thed1, thed2, thee1, thee2, theg, theh, thepG, thepH, thesingjac, thesinpG, and thesinpH.
Referenced by calculate().
00110 { 00111 thesinpH=sin(thepH); 00112 thecospH=cos(thepH); 00113 thesinpG=sin(thepG); 00114 thecospG=cos(thepG); 00115 00116 const double A11= theh * ( - thesinpH * ( thea - theg * thesinpG ) + 00117 thecospH * ( theb + theg * thecospG ) + thec1); 00118 if (A11 < 0) { return true; }; 00119 const double A22= -theg * (- thesinpG * ( thea + theh * thesinpH ) + 00120 thecospG*( theb - theh * thecospH ) + thec2); 00121 if (A22 < 0) { return true; }; 00122 const double A12= theh * (-theg * thecospG * thecospH - 00123 theg * thesinpH * thesinpG + thed1); 00124 const double A21= -theg * (theh * thecospG * thecospH + 00125 theh * thesinpH * thesinpG + thed2); 00126 const double deta = A11 * A22 - A12 * A21; 00127 const double z1=theh * ( thecospH * ( thea - theg * thesinpG ) + thesinpH * 00128 ( theb + theg*thecospG ) + thec1 * thepH + thed1 * thepG + thee1); 00129 const double z2=-theg * (thecospG * ( thea + theh * thesinpH ) + thesinpG * 00130 ( theb - theh*thecospH ) + thec2 * thepG + thed2 * thepH + thee2); 00131 00132 dH=( z1 * A22 - z2 * A12 ) / deta; 00133 dG=( z2 * A11 - z1 * A21 ) / deta; 00134 if ( fabs(deta) < thesingjac ) { return true; }; 00135 00136 thepH -= dH; 00137 thepG -= dG; 00138 return false; 00139 }
bool TwoTrackMinimumDistanceHelixHelix::parallelTracks | ( | ) | const [inline, private] |
Definition at line 141 of file TwoTrackMinimumDistanceHelixHelix.cc.
References GlobalTrajectoryParameters::charge(), GlobalTrajectoryParameters::momentum(), theG, theH, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
00142 { 00143 bool retval=false; 00144 if (fabs(theH->momentum().x() - theG->momentum().x()) < .00000001 ) 00145 if (fabs(theH->momentum().y() - theG->momentum().y()) < .00000001 ) 00146 if (fabs(theH->momentum().z() - theG->momentum().z()) < .00000001 ) 00147 if (theH->charge()==theG->charge()) retval=true; 00148 return retval; 00149 }
pair< double, double > TwoTrackMinimumDistanceHelixHelix::pathLength | ( | ) | const |
Definition at line 209 of file TwoTrackMinimumDistanceHelixHelix.cc.
References finalPoints(), pathG, pathH, and pointsUpdated.
Referenced by TwoTrackMinimumDistance::pathLength().
00210 { 00211 if (!pointsUpdated)finalPoints(); 00212 return pair <double, double> ( pathG, pathH); 00213 }
pair< GlobalPoint, GlobalPoint > TwoTrackMinimumDistanceHelixHelix::points | ( | ) | const |
Definition at line 215 of file TwoTrackMinimumDistanceHelixHelix.cc.
References finalPoints(), pointG, pointH, and pointsUpdated.
Referenced by TwoTrackMinimumDistance::pointsHelixHelix().
00217 { 00218 if (!pointsUpdated)finalPoints(); 00219 return pair<GlobalPoint, GlobalPoint> (pointG, pointH); 00220 }
double TwoTrackMinimumDistanceHelixHelix::secondAngle | ( | ) | const |
Definition at line 186 of file TwoTrackMinimumDistanceHelixHelix.cc.
References thepH.
Referenced by TwoTrackMinimumDistance::secondAngle().
00187 { 00188 return thepH; 00189 }
bool TwoTrackMinimumDistanceHelixHelix::updateCoeffs | ( | const GlobalPoint & | gpH, | |
const GlobalPoint & | gpG | |||
) | [private] |
Definition at line 39 of file TwoTrackMinimumDistanceHelixHelix.cc.
References GlobalTrajectoryParameters::charge(), MagneticField::inTesla(), PV3DBase< T, PVType, FrameType >::mag(), GlobalTrajectoryParameters::magneticField(), GlobalTrajectoryParameters::momentum(), GlobalTrajectoryParameters::position(), funct::sqrt(), square(), thea, theb, thec1, thec2, thecospG0, thecospH0, thed1, thed2, thee1, thee2, theG, theg, theH, theh, thelambdaG, thelambdaH, 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().
00041 { 00042 // const double Bc2kH = MagneticField::inInverseGeV ( gpH ).z(); 00043 const double Bc2kH = theH->magneticField().inTesla(gpH).z() * 2.99792458e-3; 00044 // const double Bc2kG = MagneticField::inInverseGeV ( gpG ).z(); 00045 const double Bc2kG = theG->magneticField().inTesla(gpG).z() * 2.99792458e-3; 00046 const double Hn= theH->momentum().mag(); 00047 const double Gn= theG->momentum().mag(); 00048 thelambdaH=asin ( theH->momentum().z() / Hn ); 00049 00050 if ( Hn == 0. || Gn == 0. ) 00051 { 00052 edm::LogWarning ("TwoTrackMinimumDistanceHelixHelix") 00053 << "momentum of input trajectory is zero."; 00054 return true; 00055 }; 00056 00057 if ( theH->charge() == 0. || theG->charge() == 0. ) 00058 { 00059 edm::LogWarning ("TwoTrackMinimumDistanceHelixHelix") 00060 << "charge of input track is zero."; 00061 return true; 00062 }; 00063 00064 if ( Bc2kG == 0. ) 00065 { 00066 edm::LogWarning ("TwoTrackMinimumDistanceHelixHelix") 00067 << "magnetic field at point " << gpG << " is zero."; 00068 return true; 00069 }; 00070 00071 if ( Bc2kH == 0. ) 00072 { 00073 edm::LogWarning ("TwoTrackMinimumDistanceHelixHelix") 00074 << "magnetic field at point " << gpH << " is zero."; 00075 return true; 00076 }; 00077 00078 theh= Hn / (theH->charge() * Bc2kH ) * 00079 sqrt( 1 - square ( ( theH->momentum().z() / Hn ))); 00080 thesinpH0= - theH->momentum().y() / ( theH->charge() * Bc2kH * theh ); 00081 thecospH0= - theH->momentum().x() / ( theH->charge() * Bc2kH * theh ); 00082 thetanlambdaH = - theH->momentum().z() / ( theH->charge() * Bc2kH * theh); 00083 thepH0 = atan2 ( thesinpH0 , thecospH0 ); 00084 thelambdaG=asin ( theG->momentum().z()/( Gn ) ); 00085 theg= Gn / (theG->charge() * Bc2kG ) * 00086 sqrt( 1 - square ( ( theG->momentum().z() / Gn ))); 00087 thesinpG0= - theG->momentum().y() / ( theG->charge()* Bc2kG * theg ); 00088 thecospG0= - theG->momentum().x() / ( theG->charge() * Bc2kG * theg ); 00089 thetanlambdaG = - theG->momentum().z() / ( theG->charge() * Bc2kG * theg); 00090 00091 thepG0 = atan2 ( thesinpG0 , thecospG0 ); 00092 00093 thea=theH->position().x() - theG->position().x() + theg * thesinpG0 - 00094 theh * thesinpH0; 00095 theb=theH->position().y() - theG->position().y() - theg * thecospG0 + 00096 theh * thecospH0; 00097 thec1= theh * thetanlambdaH * thetanlambdaH; 00098 thec2= -theg * thetanlambdaG * thetanlambdaG; 00099 thed1= -theg * thetanlambdaG * thetanlambdaH; 00100 thed2= theh * thetanlambdaG * thetanlambdaH; 00101 thee1= thetanlambdaH * ( theH->position().z() - theG->position().z() - 00102 theh * thepH0 * thetanlambdaH + theg * thepG0 * thetanlambdaG ); 00103 thee2= thetanlambdaG * ( theH->position().z() - theG->position().z() - 00104 theh * thepH0 * thetanlambdaH + theg * thepG0 * thetanlambdaG ); 00105 return false; 00106 }
double TwoTrackMinimumDistanceHelixHelix::pathG [mutable, private] |
Definition at line 57 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and pathLength().
double TwoTrackMinimumDistanceHelixHelix::pathH [mutable, private] |
Definition at line 57 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and pathLength().
GlobalPoint TwoTrackMinimumDistanceHelixHelix::pointG [mutable, private] |
Definition at line 56 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and points().
GlobalPoint TwoTrackMinimumDistanceHelixHelix::pointH [mutable, private] |
Definition at line 56 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and points().
bool TwoTrackMinimumDistanceHelixHelix::pointsUpdated [mutable, private] |
Definition at line 58 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), pathLength(), and points().
double TwoTrackMinimumDistanceHelixHelix::thea [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by oneIteration(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::theb [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by oneIteration(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thec1 [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by oneIteration(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thec2 [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by oneIteration(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thecospG [mutable, private] |
double TwoTrackMinimumDistanceHelixHelix::thecospG0 [private] |
Definition at line 47 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thecospH [mutable, private] |
double TwoTrackMinimumDistanceHelixHelix::thecospH0 [private] |
Definition at line 48 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thed1 [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by oneIteration(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thed2 [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by oneIteration(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thee1 [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by oneIteration(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thee2 [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by oneIteration(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::theg [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), oneIteration(), and updateCoeffs().
Definition at line 42 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), parallelTracks(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::theh [private] |
Definition at line 44 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), oneIteration(), and updateCoeffs().
Definition at line 42 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), parallelTracks(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thelambdaG [private] |
double TwoTrackMinimumDistanceHelixHelix::thelambdaH [private] |
double TwoTrackMinimumDistanceHelixHelix::themaxjump [private] |
double TwoTrackMinimumDistanceHelixHelix::thepG [mutable, private] |
Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), firstAngle(), and oneIteration().
double TwoTrackMinimumDistanceHelixHelix::thepG0 [private] |
Definition at line 49 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thepH [mutable, private] |
Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), oneIteration(), and secondAngle().
double TwoTrackMinimumDistanceHelixHelix::thepH0 [private] |
Definition at line 49 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by calculate(), finalPoints(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thesingjac [private] |
double TwoTrackMinimumDistanceHelixHelix::thesinpG [mutable, private] |
double TwoTrackMinimumDistanceHelixHelix::thesinpG0 [private] |
Definition at line 47 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thesinpH [mutable, private] |
double TwoTrackMinimumDistanceHelixHelix::thesinpH0 [private] |
Definition at line 48 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thetanlambdaG [private] |
Definition at line 46 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and updateCoeffs().
double TwoTrackMinimumDistanceHelixHelix::thetanlambdaH [private] |
Definition at line 46 of file TwoTrackMinimumDistanceHelixHelix.h.
Referenced by finalPoints(), and updateCoeffs().