ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/MathTools/src/MathUtils.cc
Revision: 1.3
Committed: Wed Sep 10 03:27:35 2008 UTC (16 years, 7 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006, Mit_005, Mit_004
Changes since 1.2: +2 -2 lines
Log Message:
Change back to mithep namespace for common lib since otherwise to many changes in MitAna/DataFormats would be necessary.

File Contents

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