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