/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/TrkBase/TrkBase-00-01-12/src/TrkSimpTraj.cxx

Go to the documentation of this file.
00001 
00002 //--------------------------------------------------------------------------
00003 // File and Version Information:
00004 //      $Id: TrkSimpTraj.cxx,v 1.2 2005/07/18 02:56:08 zhangy Exp $
00005 //
00006 // Description:
00007 //     
00008 //
00009 // Environment:
00010 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00011 //
00012 // Author(s): Steve Schaffner
00013 //
00014 //------------------------------------------------------------------------
00015 
00016 //#include "BaBar/BaBar.h"
00017 #include "MdcGeom/Constants.h"
00018 #include "MdcGeom/BesAngle.h"
00019 #include "TrkBase/TrkSimpTraj.h"
00020 #include "TrkBase/TrkParams.h"
00021 #include "CLHEP/Matrix/SymMatrix.h"
00022 #include "TrkBase/TrkPocaXY.h"
00023 //#include "ErrLogger/ErrLog.h"
00024 using std::ostream;
00025 
00026 // statics
00027 HepPoint3D TrkSimpTraj::_theOrigin(0.0,0.0,0.0);
00028 //Constructors
00029 //----------------------------------------------------------------------------
00030 TrkSimpTraj::TrkSimpTraj(const HepVector& params, const HepSymMatrix& cov, 
00031                          const double lowlim,const double hilim,
00032                          const HepPoint3D& refpoint) :
00033 //----------------------------------------------------------------------------
00034   TrkDifTraj(lowlim, hilim),_dtparams(params, cov),_refpoint(refpoint)
00035 {;}
00036 
00037 TrkSimpTraj::TrkSimpTraj(const TrkParams& params,
00038                          const double lowlim,const double hilim,
00039                          const HepPoint3D& refpoint) :
00040 //----------------------------------------------------------------------------
00041   TrkDifTraj(lowlim, hilim),_dtparams(params),_refpoint(refpoint)
00042 {;}
00043 
00044 //----------------------------------------------------------------------------
00045 TrkSimpTraj::TrkSimpTraj(const TrkSimpTraj& other) :
00046 //----------------------------------------------------------------------------
00047   TrkDifTraj(other.lowRange(),other.hiRange()),
00048   _dtparams(other._dtparams),
00049   _refpoint(other._refpoint)
00050 {}
00051 
00052 //----------------------------------------------------------------------------
00053 TrkSimpTraj::~TrkSimpTraj()
00054 //----------------------------------------------------------------------------
00055 { }
00056 
00057 //----------------------------------------------------------------------------
00058 const TrkSimpTraj*
00059 TrkSimpTraj::localTrajectory(double fltLen, double& localFlt) const {
00060 //----------------------------------------------------------------------------
00061   localFlt = fltLen;
00062   return this;
00063 }
00064 
00065 //
00066 //  The following is the only useful function which can be implemented at this level
00067 //
00068 //----------------------------------------------------------------------------
00069 void
00070 TrkSimpTraj::changePoint(const HepPoint3D& newpoint,double& fltlen) {
00071 //----------------------------------------------------------------------------
00072   if(newpoint != _refpoint){
00073 //  find POCA to the new point
00074     TrkPocaXY endpoca(*this,fltlen,newpoint);
00075     if(endpoca.status().failure()){
00076       std::cout<<"ErrMsg(error)" << "poca failure changing reference point" << std::endl;
00077       return;
00078     } else {
00079 // update flight length
00080       fltlen = endpoca.flt1();
00081 // make a symmatrix from the covariance: temporary kludge
00082       int nrow = parameters()->covariance().num_row();
00083       HepSymMatrix cov(nrow);
00084       for(int irow=0;irow<nrow;irow++)
00085         for(int icol=0;icol<=irow;icol++)
00086           cov.fast(irow+1,icol+1) = parameters()->covariance().fast(irow+1,icol+1);
00087 //  Get the translation function
00088       TranslateParams pfunc = paramFunction();
00089 //  Use it on the SimpTraj parameters
00090       pfunc(_refpoint,newpoint,
00091             parameters()->parameter(),cov,
00092             _dtparams.parameter(),cov,
00093             fltlen);
00094 // put back the covariance
00095       _dtparams.covariance() = cov;
00096       _refpoint = newpoint;
00097 // update the flight range to correspond to the same range in space as before
00098       double newrange[2];
00099       newrange[0] = lowRange() - fltlen;
00100       newrange[1] = hiRange() - fltlen;
00101       setFlightRange(newrange);
00102     }
00103   }
00104   return;
00105 }
00106 //----------------------------------------------------------------------------
00107 void 
00108 TrkSimpTraj::printAll(ostream& os) const {
00109 //----------------------------------------------------------------------------
00110     os << "Simple ";
00111     Trajectory::printAll(os);
00112     os << "SimpTraj parameter vector = "
00113        << _dtparams.parameter();
00114     os << "  and covariance matrix =  " 
00115        << _dtparams.covariance();
00116   }
00117 //----------------------------------------------------------------------------
00118 void 
00119 TrkSimpTraj::print(ostream& os) const {
00120 //----------------------------------------------------------------------------
00121   os << "Simple ";
00122   Trajectory::print(os);
00123 }
00124 // Inversion.  This changes the flightrange from A->B to (-B)->(-A), as well
00125 // adjusting the parameters so that the same arc in space is described (just
00126 // going the opposite direction).  This is now implemented fully generically.
00127 TrkSimpTraj&
00128 TrkSimpTraj::invert()
00129 {
00130   // Invert parameters
00131   std::vector<bool> flags(parameters()->nPar(),false);
00132   invertParams(parameters(), flags);
00133   // loop over parameters and invert covariance matrix
00134   for(int iparam=0;iparam<parameters()->nPar();iparam++){
00135     bool iinvert = flags[iparam];
00136 // do covariance cross-terms too
00137     for(int jparam=iparam+1;jparam<parameters()->nPar();jparam++){
00138       bool jinvert = flags[jparam];
00139       if( (iinvert && !jinvert) || (!iinvert && jinvert) ) {
00140 // cross-terms change sign
00141         parameters()->covariance()[iparam][jparam] *= -1.0;
00142       }
00143     }
00144   }
00145 // invert the flightlength
00146   double range[2];
00147   range[0] = -hiRange();
00148   range[1] = -lowRange();
00149   setFlightRange(range);
00150 // done
00151   return *this;
00152 }
00153 
00154 
00155 bool 
00156 TrkSimpTraj::operator==(const TrkSimpTraj& x) const
00157 {
00158      if (lowRange()!=x.lowRange() || hiRange()!=x.hiRange()) return false;
00159      const HepVector &m=_dtparams.parameter(); 
00160      unsigned int mp=m.num_row();
00161      const HepVector &n=x._dtparams.parameter(); 
00162      unsigned int np=n.num_row();
00163      if (np!=mp) return false;
00164      for(unsigned i=0;i<np;++i){
00165         if(m[i] != n[i]) return false;
00166      }
00167      return _refpoint==x._refpoint;
00168 }

Generated on Tue Nov 29 23:13:41 2016 for BOSS_7.0.2 by  doxygen 1.4.7