CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/DataFormats/Math/interface/angle.h

Go to the documentation of this file.
00001 #ifndef Math_angle_h
00002 #define Math_angle_h
00003 /* function to compute 3D angle 
00004  *
00005  * Ported from original code in RecoJets 
00006  * by Fedor Ratnikov, FNAL
00007  */
00008 #include <cmath>
00009 
00010 template <class T>
00011 T angle (T x1, T y1, T z1, T x2, T y2, T z2) {
00012   return acos((x1*x2 + y1*y2 + z1*z2)/sqrt((x1*x1 + y1*y1 + z1*z1)*(x2*x2 + y2*y2 + z2*z2)));
00013 }
00014 
00015 template<typename T1, typename T2>
00016 double angle( const T1 & t1, const T2 & t2 ) {
00017   return angle( t1.x(), t1.y(), t1.z(), t2.x(), t2.y(), t2.z() );
00018 } 
00019 
00020 #endif