CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TwoTrackMinimumDistanceHelixHelix Class Reference

#include <TwoTrackMinimumDistanceHelixHelix.h>

List of all members.

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,
GlobalPoint
points () const
double secondAngle () const
 TwoTrackMinimumDistanceHelixHelix ()
 ~TwoTrackMinimumDistanceHelixHelix ()

Private Member Functions

void finalPoints () const
bool oneIteration (double &, double &) const
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
double theg
GlobalTrajectoryParameters const * 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 ( )

Definition at line 33 of file TwoTrackMinimumDistanceHelixHelix.cc.

                                                                    :
theH(0), theG(0), pointsUpdated(false), themaxjump(20),thesingjacI(1./0.1), themaxiter(4)
{ }
TwoTrackMinimumDistanceHelixHelix::~TwoTrackMinimumDistanceHelixHelix ( )

Definition at line 37 of file TwoTrackMinimumDistanceHelixHelix.cc.

{}

Member Function Documentation

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

Definition at line 142 of file TwoTrackMinimumDistanceHelixHelix.cc.

References cmsDriverOptions::counter, oneIteration(), pointsUpdated, GlobalTrajectoryParameters::position(), theG, theg, theH, theh, themaxiter, themaxjump, thepG, thepG0, thepH, thepH0, and updateCoeffs().

                                                                                                           {
  pointsUpdated = false;
  theG= &G;
  theH= &H;
  bool retval=false;
  
  if ( updateCoeffs ( theG->position(), theH->position() ) ) return true;
  
  thepG = thepG0;
  thepH = thepH0;
  
  int counter=0;
  double pH=0; double pG=0;
  do {
    retval=oneIteration ( pG, pH );
    if ( std::isinf(pG) || std::isinf(pH) ) retval=true;
    if ( counter++>themaxiter ) retval=true;
  } while ( (!retval) && ( fabs(pG) > qual || fabs(pH) > qual ));
  if ( fabs ( theg * ( thepG - thepG0 ) ) > themaxjump ) retval=true;
  if ( fabs ( theh * ( thepH - thepH0 ) ) > themaxjump ) retval=true;
  return retval;
}
void TwoTrackMinimumDistanceHelixHelix::finalPoints ( ) const [private]
double TwoTrackMinimumDistanceHelixHelix::firstAngle ( ) const [inline]

Definition at line 40 of file TwoTrackMinimumDistanceHelixHelix.h.

References thepG.

{return thepG;}
bool TwoTrackMinimumDistanceHelixHelix::oneIteration ( double &  dH,
double &  dG 
) const [private]

Definition at line 101 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, and thesinpH.

Referenced by calculate().

                                                                                    {
  thesinpH=sin(thepH);
  thecospH=cos(thepH);
  thesinpG=sin(thepG);
  thecospG=cos(thepG);
  
  const double A11= theh * ( - thesinpH * ( thea - theg * thesinpG ) +
                             thecospH * ( theb + theg * thecospG ) + thec1);
  if (A11 < 0) { return true; };
  const double A22= -theg * (- thesinpG * ( thea + theh * thesinpH ) +
                             thecospG*( theb - theh * thecospH ) + thec2);
  if (A22 < 0) { return true; };
  const double A12= theh * (-theg * thecospG * thecospH -
                            theg * thesinpH * thesinpG + thed1);
  const double A21= -theg * (theh * thecospG * thecospH +
                             theh * thesinpH * thesinpG + thed2);
  const double detaI = 1./(A11 * A22 - A12 * A21);
  const double z1=theh * ( thecospH * ( thea - theg * thesinpG ) + thesinpH *
                           ( theb + theg*thecospG ) + thec1 * thepH + thed1 * thepG + thee1);
  const double z2=-theg * (thecospG * ( thea + theh * thesinpH ) + thesinpG *
                           ( theb - theh*thecospH ) + thec2 * thepG + thed2 * thepH + thee2);
  
  dH=( z1 * A22 - z2 * A12 ) * detaI;
  dG=( z2 * A11 - z1 * A21 ) * detaI;
  if ( fabs(detaI) > thesingjacI ) { return true; };
  
  thepH -= dH;
  thepG -= dG;
  return false;
}
std::pair<double, double> TwoTrackMinimumDistanceHelixHelix::pathLength ( ) const [inline]

Definition at line 33 of file TwoTrackMinimumDistanceHelixHelix.h.

References finalPoints(), pathG, pathH, and pointsUpdated.

                                              {
    if (!pointsUpdated) finalPoints();
    return std::pair <double, double> ( pathG, pathH);
  }
std::pair<GlobalPoint, GlobalPoint> TwoTrackMinimumDistanceHelixHelix::points ( ) const [inline]

Definition at line 28 of file TwoTrackMinimumDistanceHelixHelix.h.

References finalPoints(), pointG, pointH, and pointsUpdated.

                                                    {
    if (!pointsUpdated) finalPoints();
    return std::pair<GlobalPoint, GlobalPoint> (pointG, pointH);
  }
double TwoTrackMinimumDistanceHelixHelix::secondAngle ( ) const [inline]

Definition at line 41 of file TwoTrackMinimumDistanceHelixHelix.h.

References thepH.

{return thepH;}
bool TwoTrackMinimumDistanceHelixHelix::updateCoeffs ( const GlobalPoint gpH,
const GlobalPoint gpG 
) [private]

Definition at line 39 of file TwoTrackMinimumDistanceHelixHelix.cc.

References GlobalTrajectoryParameters::charge(), ora::Gt, 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().

                                                       {

  const double Bc2kH = theH->magneticField().inInverseGeV(gpH).z();
  const double Bc2kG = theG->magneticField().inInverseGeV(gpG).z();
  const double Ht= theH->momentum().perp();
  const double Gt= theG->momentum().perp();
  //  thelambdaH=asin ( theH->momentum().z() / Hn );
  
  if ( Ht == 0. || Gt == 0. ) {
    edm::LogWarning ("TwoTrackMinimumDistanceHelixHelix")
      << "transverse momentum of input trajectory is zero.";
    return true;
  };
  
  if ( theH->charge() == 0. || theG->charge() == 0. ) {
    edm::LogWarning ("TwoTrackMinimumDistanceHelixHelix")
      << "charge of input track is zero.";
    return true;
  };
  
  if ( Bc2kG == 0.) {
    edm::LogWarning ("TwoTrackMinimumDistanceHelixHelix")
      << "magnetic field at point " << gpG << " is zero.";
    return true;
  };
  
  if ( Bc2kH == 0. ) {
    edm::LogWarning ("TwoTrackMinimumDistanceHelixHelix")
      << "magnetic field at point " << gpH << " is zero.";
    return true;
  };
  
  theh= Ht / (theH->charge() * Bc2kH );
  thesinpH0= - theH->momentum().y() / ( Ht );
  thecospH0= - theH->momentum().x() / ( Ht );
  thetanlambdaH = - theH->momentum().z() / ( Ht);
  thepH0 = atan2 ( thesinpH0 , thecospH0 );
  
  // thelambdaG=asin ( theG->momentum().z()/( Gn ) );
  
  theg= Gt / (theG->charge() * Bc2kG );
  thesinpG0= - theG->momentum().y() / ( Gt);
  thecospG0= - theG->momentum().x() / (Gt);
  thetanlambdaG = - theG->momentum().z() / ( Gt);
  thepG0 = atan2 ( thesinpG0 , thecospG0 );
  
  thea=theH->position().x() - theG->position().x() + theg * thesinpG0 -
    theh * thesinpH0;
  theb=theH->position().y() - theG->position().y() - theg * thecospG0 +
    theh * thecospH0;
  thec1=  theh * thetanlambdaH * thetanlambdaH;
  thec2= -theg * thetanlambdaG * thetanlambdaG;
  thed1= -theg * thetanlambdaG * thetanlambdaH;
  thed2=  theh * thetanlambdaG * thetanlambdaH;
  thee1= thetanlambdaH * ( theH->position().z() - theG->position().z() -
                           theh * thepH0 * thetanlambdaH + theg * thepG0 * thetanlambdaG );
  thee2= thetanlambdaG * ( theH->position().z() - theG->position().z() -
                           theh * thepH0 * thetanlambdaH + theg * thepG0 * thetanlambdaG );
  return false;
}

Member Data Documentation

double TwoTrackMinimumDistanceHelixHelix::pathG [mutable, private]

Definition at line 66 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and pathLength().

double TwoTrackMinimumDistanceHelixHelix::pathH [mutable, private]

Definition at line 66 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and pathLength().

Definition at line 65 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and points().

Definition at line 65 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and points().

Definition at line 67 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate(), finalPoints(), pathLength(), and points().

Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

Definition at line 64 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

Definition at line 56 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

Definition at line 64 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

Definition at line 57 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

Definition at line 53 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration(), and updateCoeffs().

Definition at line 51 of file TwoTrackMinimumDistanceHelixHelix.h.

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

Definition at line 51 of file TwoTrackMinimumDistanceHelixHelix.h.

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

Definition at line 70 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate().

Definition at line 69 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by calculate().

double TwoTrackMinimumDistanceHelixHelix::thepG [mutable, private]

Definition at line 58 of file TwoTrackMinimumDistanceHelixHelix.h.

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

double TwoTrackMinimumDistanceHelixHelix::thepH [mutable, private]

Definition at line 58 of file TwoTrackMinimumDistanceHelixHelix.h.

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

Definition at line 69 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

Definition at line 63 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

Definition at line 56 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

Definition at line 63 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by oneIteration().

Definition at line 57 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

Definition at line 55 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().

Definition at line 55 of file TwoTrackMinimumDistanceHelixHelix.h.

Referenced by finalPoints(), and updateCoeffs().