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

# Content
1 // $Id: MathUtils.cc,v 1.4 2008/11/24 14:23:01 loizides Exp $
2
3 #include "MitCommon/MathTools/interface/MathUtils.h"
4
5 using namespace mithep;
6
7 //--------------------------------------------------------------------------------------------------
8 Double_t MathUtils::AddInQuadrature(Double_t a, Double_t b)
9 {
10 // Add quantities in quadrature.
11
12 return(TMath::Sqrt(a*a + b*b));
13 }
14
15 //--------------------------------------------------------------------------------------------------
16 Double_t MathUtils::DeltaPhi(Double_t phi1, Double_t phi2)
17 {
18 // Compute DeltaPhi between two given angles. Results is in [-pi/2,pi/2].
19
20 Double_t dphi = TMath::Abs(phi1-phi2);
21 while (dphi>TMath::Pi())
22 dphi = TMath::Abs(dphi - TMath::TwoPi());
23 return(dphi);
24 }
25
26 //--------------------------------------------------------------------------------------------------
27 Double_t MathUtils::DeltaPhi(const FourVector &v1, const FourVector &v2)
28 {
29 // 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 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 // Compute DeltaR between two given points in the eta/phi plane.
46
47 Double_t dphi = DeltaPhi(phi1, phi2);
48 Double_t deta = eta1-eta2;
49 Double_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
50 return(dR);
51 }
52
53 //--------------------------------------------------------------------------------------------------
54 Double_t MathUtils::DeltaR(const FourVector &v1, const FourVector &v2)
55 {
56 // 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 return MathUtils::DeltaR(v1.Phi(),v1.Eta(),v2.Phi(),v2.Eta());
67 }
68
69 //--------------------------------------------------------------------------------------------------
70 Double_t MathUtils::Eta2Theta(Double_t eta)
71 {
72 // Compute theta from given eta value.
73
74 return 2.*TMath::ATan(exp(-eta));
75 }
76
77 //--------------------------------------------------------------------------------------------------
78 Double_t MathUtils::Theta2Eta(Double_t theta)
79 {
80 // Compute eta from given theta value.
81
82 return -TMath::Log(TMath::Tan(theta/2.));
83 }