Skip to content

Commit be3d7c1

Browse files
authored
[Math][GenVector] Substitute M_PI* with TMath function calls (#18659)
1 parent 9a5f6ca commit be3d7c1

File tree

14 files changed

+63
-53
lines changed

14 files changed

+63
-53
lines changed

math/genvector/inc/Math/GenVector/Cylindrical3D.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef ROOT_Math_GenVector_Cylindrical3D
1717
#define ROOT_Math_GenVector_Cylindrical3D 1
1818

19-
#include "Math/Math.h"
19+
#include "TMath.h"
2020

2121
#include "Math/GenVector/eta.h"
2222

@@ -109,7 +109,7 @@ public :
109109
{rho=fRho; zz=fZ; phi=fPhi;}
110110

111111
private:
112-
inline static Scalar pi() { return Scalar(M_PI); }
112+
inline static Scalar pi() { return Scalar(TMath::Pi()); }
113113
inline void Restrict()
114114
{
115115
using std::floor;

math/genvector/inc/Math/GenVector/CylindricalEta3D.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include "Math/GenVector/etaMax.h"
2626

27-
27+
#include "TMath.h"
2828
#include <limits>
2929
#include <cmath>
3030

@@ -125,7 +125,7 @@ public :
125125
{rho=fRho; eta=fEta; phi=fPhi;}
126126

127127
private:
128-
inline static Scalar pi() { return M_PI; }
128+
inline static Scalar pi() { return TMath::Pi(); }
129129
inline void Restrict() {
130130
using std::floor;
131131
if (fPhi <= -pi() || fPhi > pi()) fPhi = fPhi - floor(fPhi / (2 * pi()) + .5) * 2 * pi();

math/genvector/inc/Math/GenVector/EulerAngles.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Math/GenVector/PositionVector3D.h"
2323
#include "Math/GenVector/LorentzVector.h"
2424
#include "Math/GenVector/3DConversions.h"
25+
#include "TMath.h"
2526
#include <algorithm>
2627
#include <cassert>
2728

@@ -345,7 +346,7 @@ class EulerAngles {
345346
double fTheta; // X rotation angle (second) defined only [0,PI]
346347
double fPsi; // Z rotation angle (third) defined in [-PI,PI]
347348

348-
static double Pi() { return M_PI; }
349+
static double Pi() { return TMath::Pi(); }
349350

350351
}; // EulerAngles
351352

math/genvector/inc/Math/GenVector/Polar2D.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define ROOT_Math_GenVector_Polar2D 1
2121

2222
#include "Math/Math.h"
23+
#include "TMath.h"
2324

2425
#include "Math/GenVector/etaMax.h"
2526

@@ -131,7 +132,7 @@ public :
131132

132133

133134
private:
134-
inline static double pi() { return M_PI; }
135+
inline static double pi() { return TMath::Pi(); }
135136

136137
/**
137138
restrict abgle hi to be between -PI and PI

math/genvector/inc/Math/GenVector/Polar3D.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "Math/GenVector/eta.h"
2525

26+
#include "TMath.h"
2627
#include <cmath>
2728

2829
namespace ROOT {
@@ -158,7 +159,7 @@ public :
158159

159160

160161
private:
161-
inline static Scalar pi() { return M_PI; }
162+
inline static Scalar pi() { return TMath::Pi(); }
162163
inline void Restrict() {
163164
using std::floor;
164165
if (fPhi <= -pi() || fPhi > pi()) fPhi = fPhi - floor(fPhi / (2 * pi()) + .5) * 2 * pi();

math/genvector/inc/Math/GenVector/PtEtaPhiM4D.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define ROOT_Math_GenVector_PtEtaPhiM4D 1
2020

2121
#include "Math/Math.h"
22+
#include "TMath.h"
2223

2324
#include "Math/GenVector/etaMax.h"
2425

@@ -250,7 +251,7 @@ public :
250251
Scalar Et() const { using std::cosh; return E() / cosh(fEta); }
251252

252253
private:
253-
inline static Scalar pi() { return M_PI; }
254+
inline static Scalar pi() { return TMath::Pi(); }
254255
inline void RestrictPhi() {
255256
using std::floor;
256257
if (fPhi <= -pi() || fPhi > pi()) fPhi = fPhi - floor(fPhi / (2 * pi()) + .5) * 2 * pi();

math/genvector/inc/Math/GenVector/RotationX.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "Math/GenVector/RotationXfwd.h"
2828

29+
#include <TMath.h>
2930
#include <cmath>
3031

3132
namespace ROOT {
@@ -72,9 +73,9 @@ class RotationX {
7273
Rectify makes sure the angle is in (-pi,pi]
7374
*/
7475
void Rectify() {
75-
if ( std::fabs(fAngle) >= M_PI ) {
76-
double x = fAngle / (2.0 * M_PI);
77-
fAngle = (2.0 * M_PI) * ( x + std::floor(.5-x) );
76+
if (std::fabs(fAngle) >= TMath::Pi()) {
77+
double x = fAngle / TMath::TwoPi();
78+
fAngle = TMath::TwoPi() * (x + std::floor(.5 - x));
7879
fSin = std::sin(fAngle);
7980
fCos = std::cos(fAngle);
8081
}
@@ -195,8 +196,8 @@ class RotationX {
195196
*/
196197
RotationX operator * (const RotationX & r) const {
197198
RotationX ans;
198-
double x = (fAngle + r.fAngle) / (2.0 * M_PI);
199-
ans.fAngle = (2.0 * M_PI) * ( x + std::floor(.5-x) );
199+
double x = (fAngle + r.fAngle) / TMath::TwoPi();
200+
ans.fAngle = TMath::TwoPi() * (x + std::floor(.5 - x));
200201
ans.fSin = fSin*r.fCos + fCos*r.fSin;
201202
ans.fCos = fCos*r.fCos - fSin*r.fSin;
202203
return ans;

math/genvector/inc/Math/GenVector/RotationY.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "Math/GenVector/RotationYfwd.h"
2828

2929
#include <cmath>
30+
#include <TMath.h>
3031

3132
namespace ROOT {
3233
namespace Math {
@@ -72,9 +73,9 @@ class RotationY {
7273
Rectify makes sure the angle is in (-pi,pi]
7374
*/
7475
void Rectify() {
75-
if ( std::fabs(fAngle) >= M_PI ) {
76-
double x = fAngle / (2.0 * M_PI);
77-
fAngle = (2.0 * M_PI) * ( x + std::floor(.5-x) );
76+
if (std::fabs(fAngle) >= TMath::Pi()) {
77+
double x = fAngle / TMath::TwoPi();
78+
fAngle = TMath::TwoPi() * (x + std::floor(.5 - x));
7879
fSin = std::sin(fAngle);
7980
fCos = std::cos(fAngle);
8081
}
@@ -195,8 +196,8 @@ class RotationY {
195196
*/
196197
RotationY operator * (const RotationY & r) const {
197198
RotationY ans;
198-
double x = (fAngle + r.fAngle) / (2.0 * M_PI);
199-
ans.fAngle = (2.0 * M_PI) * ( x + std::floor(.5-x) );
199+
double x = (fAngle + r.fAngle) / TMath::TwoPi();
200+
ans.fAngle = TMath::TwoPi() * (x + std::floor(.5 - x));
200201
ans.fSin = fSin*r.fCos + fCos*r.fSin;
201202
ans.fCos = fCos*r.fCos - fSin*r.fSin;
202203
return ans;

math/genvector/inc/Math/GenVector/RotationZ.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "Math/GenVector/RotationZfwd.h"
2828

29+
#include "TMath.h"
2930
#include <cmath>
3031

3132
namespace ROOT {
@@ -72,9 +73,9 @@ class RotationZ {
7273
Rectify makes sure the angle is in (-pi,pi]
7374
*/
7475
void Rectify() {
75-
if ( std::fabs(fAngle) >= M_PI ) {
76-
double x = fAngle / (2.0 * M_PI);
77-
fAngle = (2.0 * M_PI) * ( x + std::floor(.5-x) );
76+
if (std::fabs(fAngle) >= TMath::Pi()) {
77+
double x = fAngle / TMath::TwoPi();
78+
fAngle = TMath::TwoPi() * (x + std::floor(.5 - x));
7879
fSin = std::sin(fAngle);
7980
fCos = std::cos(fAngle);
8081
}
@@ -195,8 +196,8 @@ class RotationZ {
195196
*/
196197
RotationZ operator * (const RotationZ & r) const {
197198
RotationZ ans;
198-
double x = (fAngle + r.fAngle) / (2.0 * M_PI);
199-
ans.fAngle = (2.0 * M_PI) * ( x + std::floor(.5-x) );
199+
double x = (fAngle + r.fAngle) / TMath::TwoPi();
200+
ans.fAngle = TMath::TwoPi() * (x + std::floor(.5 - x));
200201
ans.fSin = fSin*r.fCos + fCos*r.fSin;
201202
ans.fCos = fCos*r.fCos - fSin*r.fSin;
202203
return ans;

math/genvector/inc/Math/GenVector/RotationZYX.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "Math/GenVector/3DConversions.h"
3333

34+
#include "TMath.h"
3435

3536
#include <algorithm>
3637
#include <cassert>
@@ -318,7 +319,7 @@ class RotationZYX {
318319
double fTheta; // Y' rotation angle (pitch) defined in [-PI/2,PI/2]
319320
double fPsi; // X'' rotation angle (roll) defined in (-PI,PI]
320321

321-
static double Pi() { return M_PI; }
322+
static double Pi() { return TMath::Pi(); }
322323

323324
}; // RotationZYX
324325

0 commit comments

Comments
 (0)