00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: DifFourVector.h,v 1.3 2009/12/23 02:59:56 zhangy Exp $ 00004 // 00005 // Description: 00006 // Class Header for |DifVector| 00007 // A 4-vector based on differential numbers 00008 // 00009 // Environment: 00010 // Software developed for the BaBar Detector at the SLAC B-Factory. 00011 // 00012 // Author List: 00013 // A. Snyder 00014 // 00015 // Copyright Information: 00016 // Copyright (C) 2002 SLAC 00017 // 00018 // History: 00019 // Migration for BESIII MDC 00020 // 00021 //------------------------------------------------------------------------ 00022 00023 #ifndef DifFourVector_H 00024 #define DifFourVector_H 00025 00026 #include <vector> 00027 00028 #include "MdcRecoUtil/DifNumber.h" 00029 #include "MdcRecoUtil/DifVector.h" 00030 #include "CLHEP/Vector/ThreeVector.h" 00031 #include <iosfwd> 00032 class DifRotation; 00033 using CLHEP::Hep3Vector; 00034 class DifFourVector { 00035 00036 public: 00037 00038 //constructors 00039 DifFourVector(); // null - default 00040 DifFourVector // construct from components 00041 (const DifNumber& mass,const DifVector& p); 00042 DifFourVector // construct from components 00043 (const double& mass,const DifVector& p); 00044 00045 DifFourVector(const DifFourVector& v); // copy 00046 00047 //destructor 00048 ~DifFourVector() {} // destroy 00049 00050 //given error on parameters calculate error on vector 00051 HepSymMatrix errorMatrix // caclulate error matrix 00052 (const HepSymMatrix& e)const; 00053 00054 //give jacobian transformation matrix wrt independent parameters; 00055 HepMatrix jacobian()const; 00056 00057 //operators 00058 inline DifFourVector& operator+=(const DifFourVector& v); 00059 inline DifFourVector& operator-=(const DifFourVector& v); 00060 inline DifFourVector& operator=(const DifFourVector & v); 00061 inline DifFourVector operator-()const; 00062 00063 inline friend DifFourVector operator+ // vector sum 00064 (const DifFourVector& a,const DifFourVector& b); 00065 inline friend DifFourVector operator- // vector difference 00066 (const DifFourVector& a,const DifFourVector& b); 00067 inline friend DifNumber operator* // scalar product 00068 (const DifFourVector& a,const DifFourVector& b); 00069 00070 00071 00072 //access 00073 inline int nPar()const; // return number of params 00074 inline DifVector direction()const; 00075 inline DifNumber pMag()const {return P.length();} 00076 inline DifNumber massSq()const {return E*E-P*P;} 00077 inline DifNumber mass()const { 00078 DifNumber temp=massSq(); 00079 if(temp>=0) return sqrt(temp); 00080 return -sqrt(-massSq()); 00081 } 00082 00083 00084 //i/o 00085 void print(/*std::ostream& o*/)const; // print out 00086 00087 00088 //manipulations 00089 00090 //misc 00091 inline DifFourVector& zeroDerivatives(); // zero derivatives 00092 00093 00094 //boost 00095 00096 00097 void boostTo(const DifFourVector&); 00098 void boostFrom(const DifFourVector&); 00099 00100 void boostToMe 00101 (std::vector<DifFourVector*>& listToBoost)const; 00102 void boostFromMe 00103 (std::vector<DifFourVector*>& listToBoost)const; 00104 00105 00106 //algebra 00107 00108 00109 //data members - public .. yes, folks that's intentional! 00110 public: 00111 00112 // energy-momentum components of a 4-vector 00113 00114 DifNumber E; // energy-like component 00115 DifVector P; // momentum-like compoent 00116 00117 00118 }; 00119 00120 //io 00121 /*SKIP 00122 inline std::ostream& operator<<(std::ostream& o,const DifFourVector& n) { 00123 n.print(o); 00124 return o; 00125 } 00126 */ 00127 #include "MdcRecoUtil/DifFourVector.icc" 00128 00129 #endif 00130 00131 00132 00133 00134 00135 00136 00137 00138