00001 #ifndef GeometryVector_Vector3DBase_h
00002 #define GeometryVector_Vector3DBase_h
00003
00004
00005 #include "DataFormats/GeometryVector/interface/VectorTag.h"
00006 #include "DataFormats/GeometryVector/interface/PV3DBase.h"
00007
00008 template <class T, class FrameTag>
00009 class Vector3DBase : public PV3DBase<T, VectorTag, FrameTag> {
00010 public:
00011
00012 typedef PV3DBase<T, VectorTag, FrameTag> BaseClass;
00013 typedef Vector3DBase< T, FrameTag> VectorType;
00014 typedef typename BaseClass::Cylindrical Cylindrical;
00015 typedef typename BaseClass::Spherical Spherical;
00016 typedef typename BaseClass::Polar Polar;
00017 typedef typename BaseClass::BasicVectorType BasicVectorType;
00018
00023 Vector3DBase() {}
00024
00028 template <class U>
00029 Vector3DBase( const Vector3DBase<U,FrameTag>& v) : BaseClass( v.basicVector()) {}
00030
00032 Vector3DBase(const T& x, const T& y, const T& z) : BaseClass(x, y, z) {}
00033
00036 explicit Vector3DBase( const Cylindrical& set) : BaseClass( set) {}
00037
00039 explicit Vector3DBase( const Polar& set) : BaseClass( set) {}
00040
00044 Vector3DBase(const Geom::Theta<T>& th,
00045 const Geom::Phi<T>& ph, const T& r) : BaseClass(th,ph,r) {}
00046
00051 template <class U>
00052 explicit Vector3DBase( const Basic3DVector<U>& v) : BaseClass(v) {}
00053
00057 Vector3DBase unit() const { return Vector3DBase( this->basicVector().unit());}
00058
00059
00060 bool operator==(const Vector3DBase & rh) const {
00061 return this->basicVector()==rh.basicVector();
00062 }
00063
00064
00068 template <class U>
00069 Vector3DBase& operator+= ( const Vector3DBase< U, FrameTag>& v) {
00070 this->theVector += v.basicVector();
00071 return *this;
00072 }
00073
00077 template <class U>
00078 Vector3DBase& operator-= ( const Vector3DBase< U, FrameTag>& v) {
00079 this->theVector -= v.basicVector();
00080 return *this;
00081 }
00082
00084 Vector3DBase operator-() const { return Vector3DBase(-this->basicVector());}
00085
00086
00088 Vector3DBase& operator*= ( const T& t) {
00089 this->theVector *= t;
00090 return *this;
00091 }
00092
00094 Vector3DBase& operator/= ( const T& t) {
00095 this->theVector /= t;
00096 return *this;
00097 }
00098
00105 template <class U>
00106 typename PreciseFloatType<T,U>::Type
00107 dot( const Vector3DBase< U, FrameTag>& v) const {
00108 return this->theVector.dot( v.basicVector());
00109 }
00110
00117 template <class U>
00118 Vector3DBase< typename PreciseFloatType<T,U>::Type, FrameTag>
00119 cross( const Vector3DBase< U, FrameTag>& v) const {
00120 typedef Vector3DBase< typename PreciseFloatType<T,U>::Type, FrameTag> RT;
00121 return RT( this->theVector.cross( v.basicVector()));
00122 }
00123
00124 };
00125
00127 template <class T, class U, class FrameTag>
00128 inline Vector3DBase<typename PreciseFloatType<T,U>::Type, FrameTag>
00129 operator+( const Vector3DBase<T, FrameTag>& v1, const Vector3DBase<U, FrameTag>& v2) {
00130 typedef Vector3DBase<typename PreciseFloatType<T,U>::Type, FrameTag> RT;
00131 return RT(v1.basicVector() + v2.basicVector());
00132 }
00133
00134 template <class T, class U, class FrameTag>
00135 inline Vector3DBase<typename PreciseFloatType<T,U>::Type, FrameTag>
00136 operator-( const Vector3DBase<T, FrameTag>& v1, const Vector3DBase<U, FrameTag>& v2) {
00137 typedef Vector3DBase<typename PreciseFloatType<T,U>::Type, FrameTag> RT;
00138 return RT(v1.basicVector() - v2.basicVector());
00139 }
00140
00142 template <class T, class U, class FrameTag>
00143 inline typename PreciseFloatType<T,U>::Type
00144 operator*( const Vector3DBase<T, FrameTag>& v1, const Vector3DBase<U, FrameTag>& v2) {
00145 return v1.basicVector() * v2.basicVector();
00146 }
00147
00151 template <class T, class FrameTag, class Scalar>
00152 inline Vector3DBase<T, FrameTag>
00153 operator*( const Vector3DBase<T, FrameTag>& v, const Scalar& s) {
00154 return Vector3DBase<T, FrameTag>( v.basicVector() * s);
00155 }
00156
00158 template <class T, class FrameTag, class Scalar>
00159 inline Vector3DBase<T, FrameTag>
00160 operator*( const Scalar& s, const Vector3DBase<T, FrameTag>& v) {
00161 return Vector3DBase<T, FrameTag>( v.basicVector() * s);
00162 }
00163
00167 template <class T, class FrameTag, class Scalar>
00168 inline Vector3DBase<T, FrameTag>
00169 operator/( const Vector3DBase<T, FrameTag>& v, const Scalar& s) {
00170 return Vector3DBase<T, FrameTag>( v.basicVector() / s);
00171 }
00172
00173 #endif // GeometryVector_Vector3DBase_h