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.)) ; }
|