ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/MathTools/src/MathUtils.cc
Revision: 1.5
Committed: Wed Feb 18 15:38:26 2009 UTC (16 years, 2 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_008pre2, Mit_008pre1
Changes since 1.4: +31 -1 lines
Log Message:
Added FourVectorM functions.

File Contents

# User Rev Content
1 loizides 1.5 // $Id: MathUtils.cc,v 1.4 2008/11/24 14:23:01 loizides Exp $
2 sixie 1.1
3     #include "MitCommon/MathTools/interface/MathUtils.h"
4    
5 loizides 1.3 using namespace mithep;
6 sixie 1.1
7 loizides 1.2 //--------------------------------------------------------------------------------------------------
8 loizides 1.4 Double_t MathUtils::AddInQuadrature(Double_t a, Double_t b)
9 loizides 1.2 {
10 loizides 1.5 // Add quantities in quadrature.
11    
12 loizides 1.2 return(TMath::Sqrt(a*a + b*b));
13     }
14 sixie 1.1
15 loizides 1.2 //--------------------------------------------------------------------------------------------------
16 loizides 1.4 Double_t MathUtils::DeltaPhi(Double_t phi1, Double_t phi2)
17 sixie 1.1 {
18 loizides 1.5 // Compute DeltaPhi between two given angles. Results is in [-pi/2,pi/2].
19    
20 loizides 1.4 Double_t dphi = TMath::Abs(phi1-phi2);
21     while (dphi>TMath::Pi())
22     dphi = TMath::Abs(dphi - TMath::TwoPi());
23     return(dphi);
24 sixie 1.1 }
25    
26 loizides 1.2 //--------------------------------------------------------------------------------------------------
27 loizides 1.4 Double_t MathUtils::DeltaPhi(const FourVector &v1, const FourVector &v2)
28 sixie 1.1 {
29 loizides 1.5 // Compute DeltaPhi between two given angles. Results is in [-pi/2,pi/2].
30    
31     return DeltaPhi(v1.Phi(),v2.Phi());
32     }
33    
34     //--------------------------------------------------------------------------------------------------
35     Double_t MathUtils::DeltaPhi(const FourVectorM &v1, const FourVectorM &v2)
36     {
37     // Compute DeltaPhi between two given angles. Results is in [-pi/2,pi/2].
38    
39 loizides 1.4 return DeltaPhi(v1.Phi(),v2.Phi());
40     }
41    
42     //--------------------------------------------------------------------------------------------------
43     Double_t MathUtils::DeltaR(Double_t phi1, Double_t eta1, Double_t phi2, Double_t eta2)
44     {
45 loizides 1.5 // Compute DeltaR between two given points in the eta/phi plane.
46    
47 loizides 1.4 Double_t dphi = DeltaPhi(phi1, phi2);
48     Double_t deta = eta1-eta2;
49     Double_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
50 sixie 1.1 return(dR);
51     }
52    
53 loizides 1.2 //--------------------------------------------------------------------------------------------------
54 loizides 1.4 Double_t MathUtils::DeltaR(const FourVector &v1, const FourVector &v2)
55 sixie 1.1 {
56 loizides 1.5 // Compute DeltaR between two given points in the eta/phi plane.
57    
58     return MathUtils::DeltaR(v1.Phi(),v1.Eta(),v2.Phi(),v2.Eta());
59     }
60    
61     //--------------------------------------------------------------------------------------------------
62     Double_t MathUtils::DeltaR(const FourVectorM &v1, const FourVectorM &v2)
63     {
64     // Compute DeltaR between two given points in the eta/phi plane.
65    
66 loizides 1.2 return MathUtils::DeltaR(v1.Phi(),v1.Eta(),v2.Phi(),v2.Eta());
67 sixie 1.1 }
68    
69 loizides 1.2 //--------------------------------------------------------------------------------------------------
70 loizides 1.4 Double_t MathUtils::Eta2Theta(Double_t eta)
71 loizides 1.2 {
72 loizides 1.5 // Compute theta from given eta value.
73    
74 loizides 1.2 return 2.*TMath::ATan(exp(-eta));
75 sixie 1.1 }
76    
77 loizides 1.2 //--------------------------------------------------------------------------------------------------
78 loizides 1.4 Double_t MathUtils::Theta2Eta(Double_t theta)
79 loizides 1.2 {
80 loizides 1.5 // Compute eta from given theta value.
81    
82 loizides 1.2 return -TMath::Log(TMath::Tan(theta/2.));
83 sixie 1.1 }