CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/TrackPropagation/RungeKutta/src/CurvilinearState.h

Go to the documentation of this file.
00001 #ifndef CurvilinearState_H
00002 #define CurvilinearState_H
00003 
00004 #include "FWCore/Utilities/interface/Visibility.h"
00005 #include "DataFormats/GeometryVector/interface/Basic2DVector.h"
00006 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00007 #include "VectorDoublet.h"
00008 
00021 class dso_internal CurvilinearState {
00022 public:
00023 
00024   typedef double                            Scalar;
00025   typedef Basic2DVector<Scalar>             Vector2D;
00026   typedef Basic3DVector<Scalar>             Vector3D;
00027   typedef VectorDoublet<Vector2D,Vector3D>  Vector;
00028 
00029   CurvilinearState() {}
00030 
00031   CurvilinearState( const Vector& v, Scalar z, Scalar pzsign) : 
00032     par_(v), z_(z), pzSign_(pzsign) {}
00033 
00034   CurvilinearState( const Vector3D& pos, const Vector3D& p, Scalar ch) : 
00035     par_(Vector2D(pos.x(),pos.y()), Vector3D( p.x()/p.z(), p.y()/p.z(), ch/p.mag())), 
00036     z_(pos.z()), pzSign_(p.z()>0. ? 1.:-1.) {}
00037        
00038   const Vector3D position() const { 
00039     return Vector3D(par_.first().x(),par_.first().y(),z_);
00040   }
00041 
00042   const Vector3D momentum() const {
00043     Scalar p = 1./fabs(par_.second().z());
00044     if ( p>1.e9 )  p = 1.e9;
00045     Scalar dxdz = par_.second().x();
00046     Scalar dydz = par_.second().y();
00047     Scalar dz = pzSign_/sqrt(1. + dxdz*dxdz + dydz*dydz);
00048     Scalar dx = dz*dxdz;
00049     Scalar dy = dz*dydz;
00050     return Vector3D(dx*p, dy*p, dz*p);
00051   }
00052 
00053   const Vector& parameters() const { return par_;}
00054 
00055   Scalar charge() const { return par_.second().z()>0 ? 1 : -1;}
00056 
00057   Scalar z() const {return z_;}
00058 
00059   double pzSign() const {return pzSign_;}
00060 
00061 private:
00062 
00063   Vector par_;
00064   Scalar z_;
00065   Scalar pzSign_; 
00066 
00067 };
00068 
00069 inline CurvilinearState
00070 operator+( const CurvilinearState& a, const CurvilinearState& b) {
00071   return CurvilinearState(a.parameters()+b.parameters(), a.z()+b.z(), a.pzSign());
00072 }
00073 
00074 inline CurvilinearState
00075 operator-( const CurvilinearState& a, const CurvilinearState& b) {
00076   return CurvilinearState(a.parameters()-b.parameters(), a.z()-b.z(), a.pzSign());
00077 }
00078 
00079 inline CurvilinearState operator*( const CurvilinearState& v, 
00080                                    const CurvilinearState::Scalar& s) {
00081   return CurvilinearState( v.parameters()*s, v.z()*s, v.pzSign());
00082 }
00083 inline CurvilinearState operator*( const CurvilinearState::Scalar& s,
00084                                    const CurvilinearState& v) {
00085   return CurvilinearState( v.parameters()*s, v.z()*s, v.pzSign());
00086 }
00087 
00088 inline CurvilinearState operator/( const CurvilinearState& v, 
00089                                    const CurvilinearState::Scalar& s) {
00090   return CurvilinearState( v.parameters()/s, v.z()/s, v.pzSign());
00091 }
00092 
00093 
00094 #endif