Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:40

0001 #ifndef Math_angle_h
0002 #define Math_angle_h
0003 /* function to compute 3D angle 
0004  *
0005  * Ported from original code in RecoJets 
0006  * by Fedor Ratnikov, FNAL
0007  */
0008 #include <cmath>
0009 
0010 template <class T>
0011 T angle(T x1, T y1, T z1, T x2, T y2, T z2) {
0012   return std::acos((x1 * x2 + y1 * y2 + z1 * z2) /
0013                    std::sqrt((x1 * x1 + y1 * y1 + z1 * z1) * (x2 * x2 + y2 * y2 + z2 * z2)));
0014 }
0015 
0016 template <typename T1, typename T2>
0017 double angle(const T1& t1, const T2& t2) {
0018   return angle(t1.x(), t1.y(), t1.z(), t2.x(), t2.y(), t2.z());
0019 }
0020 
0021 #endif