ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/MathTools/src/MathUtils.cc
Revision: 1.4
Committed: Mon Nov 24 14:23:01 2008 UTC (16 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006b, Mit_006a
Changes since 1.3: +20 -15 lines
Log Message:
Cleanup

File Contents

# User Rev Content
1 loizides 1.4 // $Id: MathUtils.cc,v 1.3 2008/09/10 03:27:35 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     return(TMath::Sqrt(a*a + b*b));
11     }
12 sixie 1.1
13 loizides 1.2 //--------------------------------------------------------------------------------------------------
14 loizides 1.4 Double_t MathUtils::DeltaPhi(Double_t phi1, Double_t phi2)
15 sixie 1.1 {
16 loizides 1.4 Double_t dphi = TMath::Abs(phi1-phi2);
17     while (dphi>TMath::Pi())
18     dphi = TMath::Abs(dphi - TMath::TwoPi());
19     return(dphi);
20 sixie 1.1 }
21    
22 loizides 1.2 //--------------------------------------------------------------------------------------------------
23 loizides 1.4 Double_t MathUtils::DeltaPhi(const FourVector &v1, const FourVector &v2)
24 sixie 1.1 {
25 loizides 1.4 return DeltaPhi(v1.Phi(),v2.Phi());
26     }
27    
28     //--------------------------------------------------------------------------------------------------
29     Double_t MathUtils::DeltaR(Double_t phi1, Double_t eta1, Double_t phi2, Double_t eta2)
30     {
31     Double_t dphi = DeltaPhi(phi1, phi2);
32     Double_t deta = eta1-eta2;
33     Double_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
34 sixie 1.1 return(dR);
35     }
36    
37 loizides 1.2 //--------------------------------------------------------------------------------------------------
38 loizides 1.4 Double_t MathUtils::DeltaR(const FourVector &v1, const FourVector &v2)
39 sixie 1.1 {
40 loizides 1.2 return MathUtils::DeltaR(v1.Phi(),v1.Eta(),v2.Phi(),v2.Eta());
41 sixie 1.1 }
42    
43 loizides 1.2 //--------------------------------------------------------------------------------------------------
44 loizides 1.4 Double_t MathUtils::Eta2Theta(Double_t eta)
45 loizides 1.2 {
46     return 2.*TMath::ATan(exp(-eta));
47 sixie 1.1 }
48    
49 loizides 1.2 //--------------------------------------------------------------------------------------------------
50 loizides 1.4 Double_t MathUtils::Theta2Eta(Double_t theta)
51 loizides 1.2 {
52     return -TMath::Log(TMath::Tan(theta/2.));
53 sixie 1.1 }