4
4
5
5
6
6
#include " DataFormats/GeometryVector/interface/Pi.h"
7
- #include " Math/VectorUtil .h"
7
+ #include " DataFormats/ Math/interface/deltaR .h"
8
8
#include < cmath>
9
9
10
10
11
11
namespace Geom {
12
+ using reco::deltaPhi;
13
+ using reco::deltaR2;
14
+ using reco::deltaR;
12
15
13
- /* *
14
- Find aximutal Angle difference between two generic vectors ( v2.Phi() - v1.Phi() )
15
- The only requirements on the Vector classes is that they implement the Phi() method
16
- \param v1 Vector of any type implementing the Phi() operator
17
- \param v2 Vector of any type implementing the Phi() operator
18
- \return Phi difference
19
- \f[ \Delta \phi = \phi_2 - \phi_1 \f]
20
- */
21
- inline double deltaBarePhi (double phi1, double phi2) {
22
- double dphi = phi2-phi1;
23
- if ( dphi > M_PI ) {
24
- dphi -= 2.0 *M_PI;
25
- } else if ( dphi <= -M_PI ) {
26
- dphi += 2.0 *M_PI;
27
- }
28
- return dphi;
29
- }
30
- inline double deltaPhi (float phi1, float phi2) {
31
- using ROOT::Math::VectorUtil::Phi_mpi_pi;
32
- return deltaBarePhi (Phi_mpi_pi (phi2),Phi_mpi_pi (phi1));
33
- }
34
- inline double deltaPhi (double phi1, double phi2) {
35
- using ROOT::Math::VectorUtil::Phi_mpi_pi;
36
- return deltaBarePhi (Phi_mpi_pi (phi2),Phi_mpi_pi (phi1));
37
- }
38
- template <class Vector1 , class Vector2 >
39
- double deltaPhi ( const Vector1 & v1, const Vector2 & v2) {
40
- return deltaBarePhi (v1.phi (),v2.phi ());
41
- }
42
16
43
17
44
18
/* * Definition of ordering of azimuthal angles.
45
19
* phi1 is less than phi2 if the angle covered by a point going from
46
20
* phi1 to phi2 in the counterclockwise direction is smaller than pi.
47
21
* It makes sense only if ALL phis are in a single hemisphere...
48
22
*/
49
- /*
50
- inline bool phiLess( float phi1, float phi2) {
51
- float diff = fmod(phi2 - phi1, 2.0*M_PI);
52
- // float diff = phi2-phi1;
53
- if ( diff < 0) diff += 2*M_PI;
54
- return diff < M_PI;
55
- }
56
- */
57
23
inline bool phiLess (float phi1, float phi2) {
58
24
return deltaPhi (phi1,phi2)<0 ;
59
25
}
@@ -62,29 +28,10 @@ namespace Geom {
62
28
}
63
29
template <class Vector1 , class Vector2 >
64
30
bool phiLess (const Vector1 & v1, const Vector2 & v2) {
65
- return deltaPhi (v1,v2)<0 .;
31
+ return deltaPhi (v1. phi () ,v2. phi () )<0 .;
66
32
}
67
33
68
34
69
- /* *
70
- Find difference in pseudorapidity (Eta) and Phi betwen two generic vectors
71
- The only requirements on the Vector classes is that they implement the Phi() and Eta() method
72
- \param v1 Vector 1
73
- \param v2 Vector 2
74
- \return Angle between the two vectors
75
- \f[ \Delta R = \sqrt{ ( \Delta \phi )^2 + ( \Delta \eta )^2 } \f]
76
- */
77
- template <class Vector1 , class Vector2 >
78
- double deltaR2 ( const Vector1 & v1, const Vector2 & v2) {
79
- double dphi = deltaPhi (v1,v2);
80
- double deta = v2.eta () - v1.eta ();
81
- return dphi*dphi + deta*deta;
82
- }
83
- template <class Vector1 , class Vector2 >
84
- double deltaR ( const Vector1 & v1, const Vector2 & v2) {
85
- return std::sqrt ( deltaR2 (v1,v2));
86
- }
87
-
88
35
}
89
36
90
37
#endif
0 commit comments