00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: TrkDifPoca.h,v 1.2 2006/03/28 01:02:36 zhangy Exp $ 00004 // 00005 // Description: 00006 // Calculate the point of closest approach between two trajectories. 00007 // Calculates (in ctor) the distance and the flight lengths alongs 00008 // the two trajectories; calculated values are obtained through accessors. 00009 // "Precision" is maximum allowed error on distance (in cm). 00010 // The input flightlengths are used as a starting point; the 00011 // code will find the point-of-closest-approach that is closest to that 00012 // point. (A good starting point also reduces CPU time.) 00013 // Note that distance is a signed quantity for two trajectories. 00014 // 00015 // Environment: 00016 // Software developed for the BaBar Detector at the SLAC B-Factory. 00017 // 00018 // Author(s): Steve Schaffner; core algorithm stolen from Art Snyder 00019 // 00020 //------------------------------------------------------------------------ 00021 #ifndef TRKDIFPOCA_H 00022 #define TRKDIFPOCA_H 00023 #include "TrkBase/TrkPocaBase.h" 00024 #include "MdcRecoUtil/DifNumber.h" 00025 #include "CLHEP/Matrix/Vector.h" 00026 using CLHEP::HepVector; 00027 00028 class TrkDifTraj; 00029 00030 // Class interface // 00031 class TrkDifPoca : public TrkPocaBase { 00032 00033 public: 00034 TrkDifPoca(const TrkDifTraj& traj1, double flt1, 00035 const Trajectory& traj2, double flt2, 00036 double precision=1.e-5); 00037 TrkDifPoca(const TrkDifTraj& traj, double flt, 00038 const HepPoint3D& pt, double precision=1.e-5); 00039 ~TrkDifPoca() {}; 00040 00041 inline const DifNumber& difDoca() const; // distance of closest approach 00042 inline double doca() const; // ditto 00043 inline const HepVector derivs() const; //deriv of doca w/r/t track params 00044 inline void fetchDerivs(HepVector&) const; // faster version 00045 00046 // The following inherited functions are also available: 00047 //const TrkErrCode& status() const; // did the calculation succeed? 00048 //double flt1() const; // path length on traj 1 @ poca 00049 //double flt2() const; 00050 //double precision(); // In case anyone wants to know: 00051 00052 private: 00053 DifNumber _doca; 00054 00055 void calcDist(const TrkDifTraj& traj1, const Trajectory& traj2); 00056 void calcDist(const TrkDifTraj& , const HepPoint3D& ); 00057 00058 // Preempt 00059 // TrkDifPoca& operator= (const TrkDifPoca&); 00060 // TrkDifPoca(const TrkDifPoca &); 00061 }; 00062 00063 // Inlined functions 00064 double TrkDifPoca::doca() const {return _doca.number();} 00065 const DifNumber& TrkDifPoca::difDoca() const {return _doca;} 00066 const HepVector TrkDifPoca::derivs() const {return _doca.derivatives();} 00067 void TrkDifPoca::fetchDerivs(HepVector& dv) const {_doca.fetchDerivatives(dv);} 00068 #endif