// $Id$ // // File: DVector3.h // // This header file is a replacement of TVector3 using sse2 SIMD instructions // #ifndef _DVector3_ #define _DVector3_ #ifndef USE_SSE2 #include typedef TVector3 DVector3; #else #include #include #include #include #define RAD2DEG 180./M_PI using namespace std; class DVector3{ public: DVector3(){ xy.v=_mm_setr_pd(0.,0.); zx.v=_mm_setr_pd(0.,0.); }; DVector3(const double x,const double y,const double z){ xy.v=_mm_setr_pd(x,y); zx.v=_mm_setr_pd(z,x); }; DVector3(__m128d v1,__m128d v2){ xy.v=v1; zx.v=v2; } ~DVector3(){}; // Routines to set the components of the vector void SetXY(const double x,const double y){ xy.v=_mm_setr_pd(x,y); } void SetXYZ(const double x,const double y,const double z){ xy.v=_mm_setr_pd(x,y); zx.v=_mm_setr_pd(z,x); } void SetMagThetaPhi(const double p, const double theta, const double phi){ double my_p=fabs(p); double pt=my_p*sin(theta); xy.d[0]=zx.d[1]=pt*cos(phi); xy.d[1]=pt*sin(phi); zx.d[0]=my_p*cos(theta); } // Set phi keeping theta and magnitude fixed void SetPhi(const double phi){ double pt=Perp(); xy.d[0]=zx.d[1]=pt*cos(phi); xy.d[1]=pt*sin(phi); } void SetX(const double x){ xy.d[0]=zx.d[1]=x; } void SetY(const double y){ xy.d[1]=y; } void SetZ(const double z){ zx.d[0]=z; } // Get component by index double operator () (int ind) const { switch (ind){ case 0: return x(); break; case 1: return y(); break; case 2: return z(); default: // cerr << "Invalid index." <0. && v1mag > 0.){ double costheta=Dot(v)/v1mag/v2mag; // Due to round-off errors, costheta could be epsilon greater than 1... if (costheta>1.) return 0.; if (costheta<-1.) return M_PI; return acos(costheta); } return 0.; } // Print the components to the screen void Print() const{ cout << "DVector3 (x,y,z)=("<