ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/MathTools/src/MathUtils.cc
Revision: 1.1
Committed: Mon Aug 18 14:57:43 2008 UTC (16 years, 8 months ago) by sixie
Content type: text/plain
Branch: MAIN
Log Message:
Common Tools for the MIT Analysis Code

File Contents

# User Rev Content
1 sixie 1.1 // $Id $
2    
3     #include "MitCommon/MathTools/interface/MathUtils.h"
4    
5     using namespace mitMath;
6    
7     //ClassImp(mitMath::MathUtils)
8    
9     double mitMath::deltaPhi(double phi1, double phi2)
10     {
11     double ans = fabs(phi1-phi2);
12     while(ans>M_PI)
13     ans = fabs(ans - 2*M_PI);
14     return(ans);
15     }
16    
17     double mitMath::phiEtaDeltaR(double phi1, double eta1, double phi2, double eta2)
18     {
19     double dphi = fabs(phi1-phi2);
20     while(dphi>M_PI) dphi = fabs(2*M_PI-dphi);
21     double deta = fabs(eta1-eta2);
22     double dR = TMath::Sqrt(dphi*dphi + deta*deta);
23     return(dR);
24     }
25    
26     double mitMath::deltaR(mithep::FourVector v1, mithep::FourVector v2)
27     {
28     return mitMath::phiEtaDeltaR(v1.Phi(),v1.Eta(),v2.Phi(),v2.Eta());
29     }
30    
31     double mitMath::addInQuadrature(double a, double b)
32     {
33     return(TMath::Sqrt(a*a + b*b));
34     }
35    
36     std::string mitMath::ftoa(double x)
37     {
38     char a[100];
39     sprintf(a,"%g",x);
40     return(a);
41     }
42    
43     double mitMath::Eta2Theta(double eta) { return 2.*atan(exp(-eta)) ; }
44     double mitMath::Theta2Eta(double theta) { return -log(tan(theta/2.)) ; }