ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/MathTools/src/MathUtils.cc
Revision: 1.6
Committed: Fri Mar 20 13:33:19 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009
Changes since 1.5: +1 -33 lines
Log Message:
Cleanup

File Contents

# User Rev Content
1 loizides 1.6 // $Id: MathUtils.cc,v 1.5 2009/02/18 15:38:26 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 loizides 1.5 // Add quantities in quadrature.
11    
12 loizides 1.2 return(TMath::Sqrt(a*a + b*b));
13     }
14 sixie 1.1
15 loizides 1.2 //--------------------------------------------------------------------------------------------------
16 loizides 1.4 Double_t MathUtils::DeltaPhi(Double_t phi1, Double_t phi2)
17 sixie 1.1 {
18 loizides 1.5 // Compute DeltaPhi between two given angles. Results is in [-pi/2,pi/2].
19    
20 loizides 1.4 Double_t dphi = TMath::Abs(phi1-phi2);
21     while (dphi>TMath::Pi())
22     dphi = TMath::Abs(dphi - TMath::TwoPi());
23     return(dphi);
24 sixie 1.1 }
25    
26 loizides 1.2 //--------------------------------------------------------------------------------------------------
27 loizides 1.4 Double_t MathUtils::DeltaR(Double_t phi1, Double_t eta1, Double_t phi2, Double_t eta2)
28     {
29 loizides 1.5 // Compute DeltaR between two given points in the eta/phi plane.
30    
31 loizides 1.4 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::Eta2Theta(Double_t eta)
39 loizides 1.2 {
40 loizides 1.5 // Compute theta from given eta value.
41    
42 loizides 1.2 return 2.*TMath::ATan(exp(-eta));
43 sixie 1.1 }
44    
45 loizides 1.2 //--------------------------------------------------------------------------------------------------
46 loizides 1.4 Double_t MathUtils::Theta2Eta(Double_t theta)
47 loizides 1.2 {
48 loizides 1.5 // Compute eta from given theta value.
49    
50 loizides 1.2 return -TMath::Log(TMath::Tan(theta/2.));
51 sixie 1.1 }