-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalibMath.h
39 lines (30 loc) · 852 Bytes
/
CalibMath.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef CalibMath_h
#define CalibMath_h
#include <cmath>
#include <TMath.h>
template <class T>
T deltaPhi (T phi1, T phi2) {
T result = phi1 - phi2;
while (result > TMath::Pi()) result -= 2*M_PI;
while (result <= -TMath::Pi()) result += 2*M_PI;
return result;
}
template <class T>
T deltaR2 (T eta1, T phi1, T eta2, T phi2) {
T deta = eta1 - eta2;
T dphi = deltaPhi (phi1, phi2);
return deta*deta + dphi*dphi;
}
template <class T>
T deltaR (T eta1, T phi1, T eta2, T phi2) {
return sqrt (deltaR2 (eta1, phi1, eta2, phi2));
}
template<typename T1, typename T2>
double deltaR2( const T1 & t1, const T2 & t2 ) {
return deltaR2( t1.eta(), t1.phi(), t2.eta(), t2.phi() );
}
template<typename T1, typename T2>
double deltaR( const T1 & t1, const T2 & t2 ) {
return deltaR( t1.eta(), t1.phi(), t2.eta(), t2.phi() );
}
#endif