ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/MathTools/interface/MathUtils.h
Revision: 1.8
Committed: Mon May 11 08:23:06 2009 UTC (15 years, 11 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009c, Mit_009b, Mit_009a
Changes since 1.7: +13 -1 lines
Log Message:
Added DeltaR2 to save computation of SQRT if possible.

File Contents

# User Rev Content
1 sixie 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.8 // $Id: MathUtils.h,v 1.7 2009/03/20 13:33:19 loizides Exp $
3 sixie 1.1 //
4     // MathUtils
5     //
6 loizides 1.2 // Math utility functions.
7 sixie 1.1 //
8 loizides 1.2 // Authors: S.Xie, C.Loizides
9 sixie 1.1 //--------------------------------------------------------------------------------------------------
10    
11 loizides 1.2 #ifndef MITCOMMON_MATHTOOLS_MATHUTILS_H
12     #define MITCOMMON_MATHTOOLS_MATHUTILS_H
13 sixie 1.1
14 loizides 1.2 #include "MitCommon/DataFormats/interface/Types.h"
15 sixie 1.1 #include <TMath.h>
16    
17 loizides 1.3 namespace mithep
18 sixie 1.1 {
19 loizides 1.2 class MathUtils {
20     public:
21 loizides 1.4 static Double_t AddInQuadrature(Double_t a, Double_t b);
22     static Double_t DeltaPhi(Double_t phi1, Double_t phi2);
23 loizides 1.7 template<class V1, class V2>
24     static Double_t DeltaPhi(const V1 &v1, const V2 &v2);
25 loizides 1.4 static Double_t DeltaR(Double_t phi1, Double_t eta1, Double_t phi2, Double_t eta2);
26 loizides 1.7 template<class V1, class V2>
27     static Double_t DeltaR(const V1 &v1, const V2 &v2);
28 loizides 1.8 static Double_t DeltaR2(Double_t phi1, Double_t eta1, Double_t phi2, Double_t eta2);
29     template<class V1, class V2>
30     static Double_t DeltaR2(const V1 &v1, const V2 &v2);
31 loizides 1.4 static Double_t Eta2Theta(Double_t eta);
32     static Double_t Theta2Eta(Double_t theta);
33 loizides 1.2 };
34 sixie 1.1 }
35 bendavid 1.6
36     //--------------------------------------------------------------------------------------------------
37     template<class V1, class V2>
38 loizides 1.7 Double_t mithep::MathUtils::DeltaPhi(const V1 &v1, const V2 &v2)
39     {
40     // DeltaPhi between two given objects
41    
42     return mithep::MathUtils::DeltaPhi(v1.Phi(),v2.Phi());
43     }
44    
45     //--------------------------------------------------------------------------------------------------
46     template<class V1, class V2>
47 bendavid 1.6 Double_t mithep::MathUtils::DeltaR(const V1 &v1, const V2 &v2)
48     {
49 loizides 1.7 // DeltaR between two given objects
50 bendavid 1.6
51     return mithep::MathUtils::DeltaR(v1.Phi(),v1.Eta(),v2.Phi(),v2.Eta());
52     }
53 loizides 1.8
54     //--------------------------------------------------------------------------------------------------
55     template<class V1, class V2>
56     Double_t mithep::MathUtils::DeltaR2(const V1 &v1, const V2 &v2)
57     {
58     // DeltaR between two given objects
59    
60     return mithep::MathUtils::DeltaR2(v1.Phi(),v1.Eta(),v2.Phi(),v2.Eta());
61     }
62 sixie 1.1 #endif