/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Generator/BesEvtGen/BesEvtGen-00-03-58/src/EvtGen/EvtGenBase/EvtVector3R.cc

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //
00003 // Environment:
00004 //      This software is part of the EvtGen package developed jointly
00005 //      for the BaBar and CLEO collaborations.  If you use all or part
00006 //      of it, please give an appropriate acknowledgement.
00007 //
00008 // Copyright Information: See EvtGen/COPYRIGHT
00009 //      Copyright (C) 1998      Caltech, UCSB
00010 //
00011 // Module: EvtVector3R.cc
00012 //
00013 // Description: Real implementation of 3-vectors
00014 //
00015 // Modification history:
00016 //    pingrg    Feb. 22, 2011           correct EvtVector3R::dot  
00017 //
00018 //    RYD       September 5, 1997       Module created
00019 //
00020 //------------------------------------------------------------------------
00021 // 
00022 #include "EvtGenBase/EvtPatches.hh"
00023 #include <iostream>
00024 #include <math.h>
00025 #include "EvtGenBase/EvtVector3R.hh"
00026 using std::ostream;
00027 
00028 
00029 
00030 EvtVector3R::~EvtVector3R(){}
00031 
00032 EvtVector3R::EvtVector3R(){
00033   
00034   v[0]=v[1]=v[2]=0.0;
00035 }
00036 
00037 
00038 EvtVector3R::EvtVector3R(double x,double y, double z){
00039   
00040   v[0]=x; v[1]=y; v[2]=z;
00041 }
00042 
00043 EvtVector3R rotateEuler(const EvtVector3R& v,
00044                         double alpha,double beta,double gamma){
00045 
00046   EvtVector3R tmp(v);
00047   tmp.applyRotateEuler(alpha,beta,gamma);
00048   return tmp;
00049 
00050 }
00051 
00052 
00053 void EvtVector3R::applyRotateEuler(double phi,double theta,double ksi){
00054 
00055   double temp[3];
00056   double sp,st,sk,cp,ct,ck;
00057 
00058   sp=sin(phi);
00059   st=sin(theta);
00060   sk=sin(ksi);
00061   cp=cos(phi);
00062   ct=cos(theta);
00063   ck=cos(ksi);
00064 
00065   temp[0]=( ck*ct*cp-sk*sp)*v[0]+( -sk*ct*cp-ck*sp)*v[1]+st*cp*v[2];
00066   temp[1]=( ck*ct*sp+sk*cp)*v[0]+(-sk*ct*sp+ck*cp)*v[1]+st*sp*v[2];
00067   temp[2]=-ck*st*v[0]+sk*st*v[1]+ct*v[2];
00068 
00069 
00070   v[0]=temp[0];
00071   v[1]=temp[1];
00072   v[2]=temp[2];
00073 }
00074 
00075 ostream& operator<<(ostream& s,const EvtVector3R& v){
00076  
00077   s<<"("<<v.v[0]<<","<<v.v[1]<<","<<v.v[2]<<")";
00078 
00079   return s;
00080 
00081 }
00082 
00083 
00084 EvtVector3R cross( const EvtVector3R& p1,const EvtVector3R& p2 ){
00085 
00086   //Calcs the cross product.  Added by djl on July 27, 1995.
00087   //Modified for real vectros by ryd Aug 28-96
00088 
00089   return EvtVector3R(p1.v[1]*p2.v[2] - p1.v[2]*p2.v[1],
00090                      p1.v[2]*p2.v[0] - p1.v[0]*p2.v[2],
00091                      p1.v[0]*p2.v[1] - p1.v[1]*p2.v[0]);
00092 
00093 }
00094 
00095 double EvtVector3R::d3mag() const
00096 
00097 // returns the 3 momentum mag.
00098 {
00099   double temp;
00100 
00101   temp = v[0]*v[0]+v[1]*v[1]+v[2]*v[2];
00102   temp = sqrt( temp );
00103 
00104   return temp;
00105 } // r3mag
00106 
00107 double EvtVector3R::dot ( const EvtVector3R& p2 ){
00108 
00109   double temp;
00110 
00111   temp = v[0]*p2.v[0];
00112   temp += v[1]*p2.v[1];  //2010-2-22,pingrg: corrected 
00113   temp += v[2]*p2.v[2];  
00114  
00115   return temp;
00116 } //dot
00117 
00118 
00119 
00120 
00121 

Generated on Tue Nov 29 23:12:16 2016 for BOSS_7.0.2 by  doxygen 1.4.7