CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h

Go to the documentation of this file.
00001 #ifndef _TRACKER_LOCALTRAJECTORYPARAMETERS_H_
00002 #define _TRACKER_LOCALTRAJECTORYPARAMETERS_H_
00003 
00004 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00005 #include "DataFormats/GeometryVector/interface/LocalVector.h"
00006 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00007 #include "DataFormats/CLHEP/interface/Migration.h" 
00008 #include "DataFormats/TrajectoryState/interface/TrackCharge.h"
00009 
00010 #include <cmath>
00011 
00026 class LocalTrajectoryParameters {
00027 public:
00028 // construct
00029 
00030   LocalTrajectoryParameters() {}
00031 
00039   LocalTrajectoryParameters(const AlgebraicVector& v, double aPzSign, bool charged = true) {
00040     theQbp  = v[0];
00041     theDxdz = v[1];
00042     theDydz = v[2];
00043     theX    = v[3];
00044     theY    = v[4];
00045     thePzSign = aPzSign;
00046     if ( charged )
00047       theCharge = theQbp>0 ? 1 : -1;
00048     else
00049       theCharge = 0;
00050   }
00051 
00059   LocalTrajectoryParameters(const AlgebraicVector5& v, double aPzSign, bool charged = true) {
00060     theQbp  = v[0];
00061     theDxdz = v[1];
00062     theDydz = v[2];
00063     theX    = v[3];
00064     theY    = v[4];
00065     thePzSign = aPzSign;
00066     if ( charged )
00067       theCharge = theQbp>0 ? 1 : -1;
00068     else
00069       theCharge = 0;
00070   }
00071 
00072 
00080   LocalTrajectoryParameters(double aQbp, double aDxdz, double aDydz,
00081                             double aX, double aY, double aPzSign, bool charged = true) :
00082     theDxdz(aDxdz), theDydz(aDydz),
00083     theX(aX), theY(aY), thePzSign(aPzSign) {
00084     if ( charged ) {
00085       theQbp = aQbp;
00086       theCharge = theQbp>0 ? 1 : -1;
00087     }
00088     else {
00089       theQbp = aQbp;
00090       theCharge = 0;
00091     }
00092   }
00093 
00095   LocalTrajectoryParameters( const LocalPoint& pos, const LocalVector& p,
00096                              TrackCharge charge) :
00097     theQbp( charge/p.mag()), theDxdz( p.x()/p.z()), theDydz( p.y()/p.z()), 
00098     theX( pos.x()), theY(pos.y()), thePzSign( p.z()>0. ? 1.:-1.), theCharge(charge) {
00099     if ( charge==0 )  theQbp = 1./p.mag();
00100   }
00101 
00102 // access
00103 
00105   LocalPoint position() const {
00106     return LocalPoint(theX, theY);
00107   }
00108 
00110   LocalVector momentum() const {
00111     double p = 1./fabs(theQbp);
00112     if ( p>1.e9 )  p = 1.e9;
00113     double dz = thePzSign/sqrt(1. + theDxdz*theDxdz + theDydz*theDydz);
00114     double dx = dz*theDxdz;
00115     double dy = dz*theDydz;
00116     return LocalVector(dx*p, dy*p, dz*p);
00117   }
00118 
00120   TrackCharge charge() const {return theCharge;}
00121 
00123   double signedInverseMomentum() const {
00124     return charge()==0 ? 0. : theQbp;
00125   }
00126 
00132   AlgebraicVector vector_old() const {
00133     AlgebraicVector v(5);
00134     v[0] = signedInverseMomentum();
00135     v[1] = theDxdz;
00136     v[2] = theDydz;
00137     v[3] = theX;
00138     v[4] = theY;
00139     return v;
00140   }
00141 
00147   AlgebraicVector5 vector() const {
00148     AlgebraicVector5 v;
00149     v[0] = signedInverseMomentum();
00150     v[1] = theDxdz;
00151     v[2] = theDydz;
00152     v[3] = theX;
00153     v[4] = theY;
00154     return v;
00155   }
00156 
00162   AlgebraicVector5 mixedFormatVector() const {
00163     AlgebraicVector5 v;
00164     v[0] = theQbp;    // signed in case of charged particles, 1/p for neutrals
00165     v[1] = theDxdz;
00166     v[2] = theDydz;
00167     v[3] = theX;
00168     v[4] = theY;
00169     return v;
00170   }
00171 
00177   AlgebraicVector mixedFormatVector_old() const {
00178     AlgebraicVector v(5);
00179     v[0] = theQbp;    // signed in case of charged particles, 1/p for neutrals
00180     v[1] = theDxdz;
00181     v[2] = theDydz;
00182     v[3] = theX;
00183     v[4] = theY;
00184     return v;
00185   }
00186 
00188   double pzSign() const {
00189     return thePzSign;
00190   }
00191 
00193   bool updateP(double dP) {
00194     double p = 1./fabs(theQbp);
00195     if ((p += dP) <= 0.) return false;
00196     double newQbp = theQbp > 0. ? 1./p : -1./p;
00197     theQbp = newQbp;
00198     return true;
00199   }
00200 
00201 
00202   double qbp() const { return theQbp;}
00203   double dxdz() const { return theDxdz;}
00204   double dydz() const { return theDydz;}
00205 
00206 
00207 private:
00208   double theQbp;    
00209   double theDxdz;   
00210   double theDydz;   
00211   double theX;      
00212   double theY;      
00213 
00214   double thePzSign; 
00215 
00216   TrackCharge theCharge; 
00217 
00218 };
00219 
00220 #endif